clean up ui, more upgrades
This commit is contained in:
parent
12f48497ae
commit
2a4f92c9b3
37
src/bar.rs
37
src/bar.rs
|
@ -1,4 +1,4 @@
|
||||||
use servicepoint::GridMut;
|
use servicepoint::{Bitmap, WindowMut};
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct Bar {
|
pub struct Bar {
|
||||||
pub progress: f64,
|
pub progress: f64,
|
||||||
|
@ -9,33 +9,38 @@ impl Bar {
|
||||||
Self { progress: 0.0 }
|
Self { progress: 0.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw<P: GridMut<bool>>(&self, bitmap: &mut P) {
|
pub fn draw(&self, mut bitmap: WindowMut<bool, Bitmap>) {
|
||||||
bitmap.fill(false);
|
bitmap.fill(false);
|
||||||
|
|
||||||
let margin = 1;
|
let padding = 1;
|
||||||
let bar_height = bitmap.height() - 2 * margin;
|
let mut bitmap = bitmap
|
||||||
let bar_width = bitmap.width() - 2 * margin;
|
.window_mut(
|
||||||
let border_thickness = 1;
|
padding,
|
||||||
|
padding,
|
||||||
|
bitmap.width() - 2 * padding,
|
||||||
|
bitmap.height() - 2 * padding,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// border top + bottom
|
// border top + bottom
|
||||||
let last_row = bitmap.height() - margin - border_thickness;
|
let last_row = bitmap.height() - 1;
|
||||||
for x in margin..bar_width {
|
for x in 0..bitmap.width() {
|
||||||
bitmap.set(x, margin, true);
|
bitmap.set(x, 0, true);
|
||||||
bitmap.set(x, last_row, true);
|
bitmap.set(x, last_row, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// border left + right
|
// border left + right
|
||||||
let last_col = bitmap.width() - margin - border_thickness;
|
let last_col = bitmap.width() - 1;
|
||||||
for y in 1..=bar_height {
|
for y in 0..bitmap.height() {
|
||||||
bitmap.set(1, y, true);
|
bitmap.set(0, y, true);
|
||||||
bitmap.set(last_col, y, true);
|
bitmap.set(last_col, y, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// progress fill
|
// progress fill
|
||||||
let fill_to = ((bar_width - 2) as f64 * self.progress) as usize;
|
let fill_to = (bitmap.width() as f64 * self.progress) as usize;
|
||||||
for y in 2..bar_height {
|
for y in 1..bitmap.height() - 1 {
|
||||||
for x in 2..=fill_to {
|
for x in 1..bitmap.width() - 1 {
|
||||||
bitmap.set(x, y, (x + y) % 2 == 0);
|
bitmap.set(x, y, x < fill_to && (x + y) % 2 == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use servicepoint::{CharGridMutExt, Grid, GridMut, TILE_SIZE, WindowMut};
|
use servicepoint::{CharGridMutExt, GridMut, TILE_SIZE, WindowMut};
|
||||||
use std::io::BufRead;
|
|
||||||
|
|
||||||
pub type BorderPattern = [bool; TILE_SIZE];
|
pub type BorderPattern = [bool; TILE_SIZE];
|
||||||
|
|
||||||
|
@ -9,7 +8,7 @@ pub const INNER_BORDER: BorderPattern = [false, false, false, true, true, false,
|
||||||
pub fn draw_border_panel<'t, C: GridMut<char>, P: GridMut<bool>>(
|
pub fn draw_border_panel<'t, C: GridMut<char>, P: GridMut<bool>>(
|
||||||
mut chars: WindowMut<'t, char, C>,
|
mut chars: WindowMut<'t, char, C>,
|
||||||
mut bitmap: WindowMut<'t, bool, P>,
|
mut bitmap: WindowMut<'t, bool, P>,
|
||||||
label: &'static str,
|
label: &str,
|
||||||
border_pattern: BorderPattern,
|
border_pattern: BorderPattern,
|
||||||
) -> (WindowMut<'t, char, C>, WindowMut<'t, bool, P>) {
|
) -> (WindowMut<'t, char, C>, WindowMut<'t, bool, P>) {
|
||||||
let tile_width = chars.width();
|
let tile_width = chars.width();
|
||||||
|
|
52
src/game.rs
52
src/game.rs
|
@ -1,10 +1,7 @@
|
||||||
use crate::border_panel::{INNER_BORDER, OUTER_BORDER, draw_border_panel};
|
use crate::border_panel::{INNER_BORDER, OUTER_BORDER, draw_border_panel};
|
||||||
use crate::row::Row;
|
use crate::row::Row;
|
||||||
use crate::{
|
use crate::{Currency, unlocks::UnlockSystem};
|
||||||
Currency,
|
use servicepoint::{Bitmap, CharGrid, TILE_SIZE, WindowMut};
|
||||||
unlocks::{Unlock, UnlockSystem},
|
|
||||||
};
|
|
||||||
use servicepoint::{Bitmap, CharGrid, CharGridMutExt, GridMut, TILE_SIZE, WindowMut};
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -23,9 +20,8 @@ pub struct State {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Game {
|
impl Game {
|
||||||
const BAR_NAMES: [&'static str; 10] = [
|
const BAR_NAMES: [&'static str; 11] = [
|
||||||
"Powering infrastructure",
|
"Powering infrastructure",
|
||||||
"Dusting ServicePoint",
|
|
||||||
"Activating colorful lights",
|
"Activating colorful lights",
|
||||||
"Dimming darkroom",
|
"Dimming darkroom",
|
||||||
"Refilling Matemat",
|
"Refilling Matemat",
|
||||||
|
@ -34,7 +30,8 @@ impl Game {
|
||||||
"Untangling 'block chain'",
|
"Untangling 'block chain'",
|
||||||
"Refilling sticker box",
|
"Refilling sticker box",
|
||||||
"Setting room to public",
|
"Setting room to public",
|
||||||
// "Welcoming creatures",
|
"Welcoming creatures",
|
||||||
|
"Making Discordia proud",
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
@ -43,7 +40,7 @@ impl Game {
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(index, name)| {
|
.map(|(index, name)| {
|
||||||
Row::new(
|
Row::new(
|
||||||
2usize.pow(index as u32) as f64,
|
5usize.pow(index as u32) as f64,
|
||||||
1.0 * (0.5f64.powi(index as i32)),
|
1.0 * (0.5f64.powi(index as i32)),
|
||||||
*name,
|
*name,
|
||||||
)
|
)
|
||||||
|
@ -90,52 +87,31 @@ impl Game {
|
||||||
);
|
);
|
||||||
|
|
||||||
let unlocks_height = 3 + 2;
|
let unlocks_height = 3 + 2;
|
||||||
let (unlocks_text, text_layer) = text_layer.split_vertical_mut(unlocks_height).unwrap();
|
let (unlocks_text, bars_text) = text_layer.split_vertical_mut(unlocks_height).unwrap();
|
||||||
let (unlocks_pixel, pixel_layer) = pixel_layer
|
let (unlocks_pixel, bars_pixel) = pixel_layer
|
||||||
.split_vertical_mut(unlocks_height * TILE_SIZE)
|
.split_vertical_mut(unlocks_height * TILE_SIZE)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
self.unlocks.draw(unlocks_text, unlocks_pixel);
|
self.unlocks.draw(unlocks_text, unlocks_pixel);
|
||||||
|
|
||||||
let bars_height = self.state.rows.len() + 2;
|
|
||||||
let (bars_text, text_layer) = text_layer.split_vertical_mut(bars_height).unwrap();
|
|
||||||
let (bars_pixel, _) = pixel_layer
|
|
||||||
.split_vertical_mut(bars_height * TILE_SIZE)
|
|
||||||
.unwrap();
|
|
||||||
self.draw_bars(bars_text, bars_pixel);
|
self.draw_bars(bars_text, bars_pixel);
|
||||||
|
|
||||||
let free_row_bottom = text_layer.height() - 1;
|
|
||||||
self.draw_stats(text_layer, free_row_bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_stats<C: GridMut<char>>(&self, text_layer: WindowMut<char, C>, row: usize) {
|
fn draw_bars(
|
||||||
let middle = text_layer.width() / 2;
|
|
||||||
let (mut left, mut right) = text_layer.split_horizontal_mut(middle).unwrap();
|
|
||||||
left.set_row_str(0, &format!("Hack Score: {:.2}", self.total_currency))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
if self.unlocks.bought() > 0 {
|
|
||||||
right
|
|
||||||
.set_row_str(0, &format!(" Unlocks: {}", self.unlocks.bought()))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_bars<C: GridMut<char>, P: GridMut<bool>>(
|
|
||||||
&self,
|
&self,
|
||||||
text_layer: WindowMut<char, C>,
|
text_layer: WindowMut<char, CharGrid>,
|
||||||
pixel_layer: WindowMut<bool, P>,
|
pixel_layer: WindowMut<bool, Bitmap>,
|
||||||
) {
|
) {
|
||||||
let (mut text_layer, mut pixel_layer) =
|
let (mut text_layer, mut pixel_layer) =
|
||||||
draw_border_panel(text_layer, pixel_layer, " Processes ", INNER_BORDER);
|
draw_border_panel(text_layer, pixel_layer, " Processes ", INNER_BORDER);
|
||||||
|
|
||||||
for (index, row) in self.state.rows.iter().enumerate() {
|
for (index, row) in self.state.rows.iter().enumerate() {
|
||||||
let mut bar_window = pixel_layer
|
let bar_window = pixel_layer
|
||||||
.window_mut(0, index * TILE_SIZE, pixel_layer.width(), TILE_SIZE)
|
.window_mut(0, index * TILE_SIZE, pixel_layer.width(), TILE_SIZE)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut label_window = text_layer
|
let label_window = text_layer
|
||||||
.window_mut(0, index, text_layer.width(), 1)
|
.window_mut(0, index, text_layer.width(), 1)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
row.draw(&mut label_window, &mut bar_window);
|
row.draw(label_window, bar_window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
31
src/main.rs
31
src/main.rs
|
@ -1,9 +1,9 @@
|
||||||
use game::Game;
|
use game::Game;
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
BinaryOperation, BitVecCommand, Bitmap, CharGrid, CharGridCommand, ClearCommand,
|
Bitmap, BitmapCommand, CharGrid, CharGridCommand, ClearCommand, TILE_HEIGHT, TILE_WIDTH,
|
||||||
CompressionCode, FRAME_PACING, TILE_HEIGHT, TILE_WIDTH, UdpSocketExt,
|
UdpSocketExt,
|
||||||
};
|
};
|
||||||
use std::{net::UdpSocket, thread::sleep, time::Instant};
|
use std::{net::UdpSocket, time::Instant};
|
||||||
|
|
||||||
mod bar;
|
mod bar;
|
||||||
mod border_panel;
|
mod border_panel;
|
||||||
|
@ -23,8 +23,8 @@ fn main() {
|
||||||
let connection = UdpSocket::bind_connect(DESTINATION).unwrap();
|
let connection = UdpSocket::bind_connect(DESTINATION).unwrap();
|
||||||
connection.send_command(ClearCommand);
|
connection.send_command(ClearCommand);
|
||||||
|
|
||||||
let mut chars = CharGrid::new(TILE_WIDTH, TILE_HEIGHT);
|
let mut bitmap_cmd = BitmapCommand::from(Bitmap::max_sized());
|
||||||
let mut pixels = Bitmap::max_sized();
|
let mut chars_cmd = CharGridCommand::from(CharGrid::new(TILE_WIDTH, TILE_HEIGHT));
|
||||||
|
|
||||||
let mut last_refresh = Instant::now();
|
let mut last_refresh = Instant::now();
|
||||||
loop {
|
loop {
|
||||||
|
@ -34,7 +34,10 @@ fn main() {
|
||||||
|
|
||||||
state.progress(delta);
|
state.progress(delta);
|
||||||
|
|
||||||
chars.fill(' ');
|
let chars = &mut chars_cmd.grid;
|
||||||
|
let pixels = &mut bitmap_cmd.bitmap;
|
||||||
|
|
||||||
|
chars.fill('\0');
|
||||||
pixels.fill(false);
|
pixels.fill(false);
|
||||||
|
|
||||||
let chars_view = chars
|
let chars_view = chars
|
||||||
|
@ -45,18 +48,8 @@ fn main() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
state.draw(chars_view, pixels_view);
|
state.draw(chars_view, pixels_view);
|
||||||
|
|
||||||
connection
|
connection.send_command(&bitmap_cmd).unwrap();
|
||||||
.send_command(CharGridCommand::from(chars.clone()))
|
connection.send_command(&chars_cmd).unwrap();
|
||||||
.unwrap();
|
//sleep(FRAME_PACING / 10);
|
||||||
connection
|
|
||||||
.send_command(BitVecCommand {
|
|
||||||
bitvec: pixels.clone().into(),
|
|
||||||
compression: CompressionCode::default(),
|
|
||||||
operation: BinaryOperation::Or,
|
|
||||||
offset: 0,
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
sleep(FRAME_PACING / 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
src/row.rs
26
src/row.rs
|
@ -1,5 +1,5 @@
|
||||||
use crate::{Currency, bar::Bar};
|
use crate::{Currency, bar::Bar};
|
||||||
use servicepoint::{CharGridMutExt, GridMut, WindowMut};
|
use servicepoint::{Bitmap, CharGrid, CharGridMutExt, GridMut, WindowMut};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
@ -39,22 +39,24 @@ impl Row {
|
||||||
completions * self.productivity
|
completions * self.productivity
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw<C: GridMut<char>, P: GridMut<bool>>(&self, chars: &mut C, bitmap: &mut P) {
|
pub fn draw(&self, mut chars: WindowMut<char, CharGrid>, mut bitmap: WindowMut<bool, Bitmap>) {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut bitmap = WindowMut::new(bitmap, 0, 0, bitmap.width() / 2, bitmap.height()).unwrap();
|
let bitmap = bitmap
|
||||||
self.bar.draw(&mut bitmap);
|
.window_mut(0, 0, bitmap.width() / 2, bitmap.height())
|
||||||
|
.unwrap();
|
||||||
|
self.bar.draw(bitmap);
|
||||||
|
|
||||||
let mut chars = WindowMut::new(
|
let mut chars = chars
|
||||||
chars,
|
.window_mut(
|
||||||
chars.width() / 2 + 1,
|
chars.width() / 2 + 1,
|
||||||
0,
|
0,
|
||||||
chars.width() / 2 - 1,
|
chars.width() / 2 - 1,
|
||||||
chars.height(),
|
chars.height(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
chars
|
chars
|
||||||
.set_row_str(
|
.set_row_str(
|
||||||
|
|
152
src/unlocks.rs
152
src/unlocks.rs
|
@ -1,11 +1,10 @@
|
||||||
use crate::border_panel::{INNER_BORDER, draw_border_panel};
|
use crate::border_panel::{INNER_BORDER, draw_border_panel};
|
||||||
use crate::{Currency, bar::Bar, game::State, row::Row};
|
use crate::{Currency, bar::Bar, game::State, row::Row};
|
||||||
use servicepoint::{CharGridMutExt, GridMut, TILE_SIZE, WindowMut};
|
use servicepoint::{Bitmap, CharGrid, CharGridMutExt, TILE_SIZE, WindowMut};
|
||||||
use std::{
|
use std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
fmt::{Debug, Formatter},
|
fmt::{Debug, Formatter},
|
||||||
iter::Map,
|
ops::Mul,
|
||||||
ops::{Mul, Range},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -15,6 +14,7 @@ pub struct UnlockSystem {
|
||||||
unlock_queue: VecDeque<Unlock>,
|
unlock_queue: VecDeque<Unlock>,
|
||||||
all_unlocks_bar: Bar,
|
all_unlocks_bar: Bar,
|
||||||
next_unlock_bar: Bar,
|
next_unlock_bar: Bar,
|
||||||
|
total_unlock_count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Unlock {
|
pub struct Unlock {
|
||||||
|
@ -34,13 +34,16 @@ impl Debug for Unlock {
|
||||||
|
|
||||||
impl UnlockSystem {
|
impl UnlockSystem {
|
||||||
pub fn new(start_state: &State) -> Self {
|
pub fn new(start_state: &State) -> Self {
|
||||||
let mut upgrades = Self::gen_bar_upgrades(&start_state.rows)
|
let mut upgrades = Self::gen_bar_enable_unlocks(&start_state.rows)
|
||||||
.chain(Self::gen_speed_upgrades())
|
.chain(Self::gen_global_speed_unlocks())
|
||||||
.chain(Self::gen_productivity_upgrades())
|
.chain(Self::gen_global_productivity_unlocks())
|
||||||
|
.chain(Self::gen_bar_speed_unlocks(&start_state.rows))
|
||||||
|
.chain(Self::gen_bar_productivity_unlocks(&start_state.rows))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
upgrades.sort_by(|l, r| l.cost.total_cmp(&r.cost));
|
upgrades.sort_by(|l, r| l.cost.total_cmp(&r.cost));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
total_unlock_count: upgrades.len(),
|
||||||
unlock_queue: upgrades.into(),
|
unlock_queue: upgrades.into(),
|
||||||
bought: 0,
|
bought: 0,
|
||||||
last_unlock: None,
|
last_unlock: None,
|
||||||
|
@ -64,52 +67,25 @@ impl UnlockSystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bought(&self) -> usize {
|
|
||||||
self.bought
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn previous(&self) -> Option<&String> {
|
pub fn previous(&self) -> Option<&String> {
|
||||||
self.last_unlock.as_ref()
|
self.last_unlock.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw<C: GridMut<char>, P: GridMut<bool>>(
|
pub fn draw(&self, chars: WindowMut<char, CharGrid>, bitmap: WindowMut<bool, Bitmap>) {
|
||||||
&self,
|
let title = format!(" Stage {}/{} ", self.bought, self.total_unlock_count);
|
||||||
chars: WindowMut<char, C>,
|
|
||||||
bitmap: WindowMut<bool, P>,
|
|
||||||
) {
|
|
||||||
let (mut chars, mut bitmap) = draw_border_panel(chars, bitmap, " Unlocks ", INNER_BORDER);
|
|
||||||
let mut free_row_bottom = chars.height() - 1;
|
|
||||||
|
|
||||||
let pixel_width = bitmap.width();
|
let (mut chars, mut bitmap) = draw_border_panel(chars, bitmap, &title, INNER_BORDER);
|
||||||
self.all_unlocks_bar.draw(
|
|
||||||
&mut WindowMut::new(
|
|
||||||
&mut bitmap,
|
|
||||||
0,
|
|
||||||
free_row_bottom * TILE_SIZE,
|
|
||||||
pixel_width,
|
|
||||||
TILE_SIZE,
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
free_row_bottom -= 1;
|
|
||||||
|
|
||||||
self.next_unlock_bar.draw(
|
let (all_unlocks_pixels, bitmap) = bitmap.split_vertical_mut(TILE_SIZE).unwrap();
|
||||||
&mut WindowMut::new(
|
self.all_unlocks_bar.draw(all_unlocks_pixels);
|
||||||
&mut bitmap,
|
|
||||||
0,
|
|
||||||
free_row_bottom * TILE_SIZE,
|
|
||||||
pixel_width,
|
|
||||||
TILE_SIZE,
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
free_row_bottom -= 1;
|
|
||||||
|
|
||||||
if let Some(prev_unlock) = self.previous() {
|
let (next_unlocks_pixels, _) = bitmap.split_vertical_mut(TILE_SIZE).unwrap();
|
||||||
let char_width = chars.width();
|
self.next_unlock_bar.draw(next_unlocks_pixels);
|
||||||
WindowMut::new(&mut chars, 0, free_row_bottom, char_width, 1)
|
|
||||||
.unwrap()
|
if let Some(next) = self.peek_next() {
|
||||||
.set_row_str(0, &format!("Unlocked: {}", prev_unlock))
|
let (_, mut next_unlock_chars) = chars.split_vertical_mut(2).unwrap();
|
||||||
|
next_unlock_chars
|
||||||
|
.set_row_str(0, &format!("Loading: {}", next.name))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,56 +100,62 @@ impl UnlockSystem {
|
||||||
self.last_unlock = Some(next_upgrade.name);
|
self.last_unlock = Some(next_upgrade.name);
|
||||||
self.bought += 1;
|
self.bought += 1;
|
||||||
|
|
||||||
let total = self.bought + self.unlock_queue.len();
|
self.all_unlocks_bar.progress = self.bought as f64 / self.total_unlock_count as f64;
|
||||||
self.all_unlocks_bar.progress = self.bought as f64 / total as f64;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_bar_upgrades(bars: &Vec<Row>) -> impl Iterator<Item = Unlock> {
|
fn gen_bar_enable_unlocks(bars: &Vec<Row>) -> impl Iterator<Item = Unlock> {
|
||||||
bars.iter().enumerate().flat_map(|(index, bar)| {
|
bars.iter().enumerate().map(|(index, bar)| Unlock {
|
||||||
let initial_cost = 10usize.pow(index as u32);
|
name: format!("Start {}", bar.name()),
|
||||||
[
|
cost: 10f64.powi(index as i32),
|
||||||
Unlock {
|
|
||||||
name: format!("Start {}", bar.name()),
|
|
||||||
cost: initial_cost as f64,
|
|
||||||
apply: Box::new(move |game| {
|
|
||||||
game.rows[index].enabled = true;
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
Unlock {
|
|
||||||
name: format!("{} productivity", bar.name()),
|
|
||||||
cost: initial_cost.mul(2) as f64,
|
|
||||||
apply: Box::new(move |game| {
|
|
||||||
game.rows[index].productivity *= 2.0;
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
Unlock {
|
|
||||||
name: format!("{} speed", bar.name()),
|
|
||||||
cost: initial_cost.mul(20) as f64,
|
|
||||||
apply: Box::new(move |game| {
|
|
||||||
game.rows[index].speed *= 1.5;
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn gen_speed_upgrades() -> impl Iterator<Item = Unlock> {
|
|
||||||
(1..10).map(|level| Unlock {
|
|
||||||
name: format!("The answer {}", level),
|
|
||||||
cost: (42usize * 10usize.pow(level)) as f64,
|
|
||||||
apply: Box::new(move |game| {
|
apply: Box::new(move |game| {
|
||||||
game.speed *= 1.1;
|
game.rows[index].enabled = true;
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_productivity_upgrades() -> Map<Range<u32>, fn(u32) -> Unlock> {
|
fn gen_global_speed_unlocks() -> impl Iterator<Item = Unlock> {
|
||||||
(1..10).map(|level| Unlock {
|
(1..32).map_while(|level| {
|
||||||
|
Some(Unlock {
|
||||||
|
name: format!("The answer {}", level),
|
||||||
|
cost: 42f64.mul(2f64.powi(level)),
|
||||||
|
apply: Box::new(move |game| {
|
||||||
|
game.speed *= 1.15;
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gen_global_productivity_unlocks() -> impl Iterator<Item = Unlock> {
|
||||||
|
(1..32).map(|level| Unlock {
|
||||||
name: format!("??? {}", level),
|
name: format!("??? {}", level),
|
||||||
cost: (23usize * 10usize.pow(level)) as f64,
|
cost: 23f64.mul(2f64.powi(level)),
|
||||||
apply: Box::new(move |game| {
|
apply: Box::new(move |game| {
|
||||||
game.productivity *= 1.1;
|
game.productivity *= 1.15;
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn gen_bar_productivity_unlocks(bars: &Vec<Row>) -> impl Iterator<Item = Unlock> {
|
||||||
|
bars.iter().enumerate().flat_map(|(index, bar)| {
|
||||||
|
(1..=20).map(move |level| Unlock {
|
||||||
|
name: format!("{} productivity {level}", bar.name()),
|
||||||
|
cost: 10f64.powi(index as i32).mul(3f64.powi(level)),
|
||||||
|
apply: Box::new(move |game| {
|
||||||
|
game.rows[index].productivity *= 1.5;
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gen_bar_speed_unlocks(bars: &Vec<Row>) -> impl Iterator<Item = Unlock> {
|
||||||
|
bars.iter().enumerate().flat_map(|(index, bar)| {
|
||||||
|
(1..=15).map(move |level| Unlock {
|
||||||
|
name: format!("{} speed {level}", bar.name()),
|
||||||
|
cost: 10f64.powi(index as i32).mul(5f64.powi(level)),
|
||||||
|
apply: Box::new(move |game| {
|
||||||
|
game.rows[index].speed *= 1.5;
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue