Commit 0a775f4d authored by Rahix's avatar Rahix 🦀
Browse files

player: Add difficulty and shifts_completed stats

parent 52edc532
......@@ -2,6 +2,9 @@
pub struct Player {
pub sanity: f32,
pub collected_hours: u32,
pub shifts_completed: u32,
pub difficulty: f32,
}
impl Player {
......@@ -9,6 +12,8 @@ impl Player {
Player {
sanity: 1.0,
collected_hours: 0,
shifts_completed: 0,
difficulty: 0.0,
}
}
}
......@@ -21,7 +21,7 @@ impl HeavenState {
pub fn new(player: Option<components::Player>) -> HeavenState {
let (node_world, resources, node_schedule) = init_orbiting_nodes();
let player = player.unwrap_or_else(|| {
let mut player = player.unwrap_or_else(|| {
// Initialize the game as this is the first run.
components::Player::new()
});
......@@ -46,6 +46,9 @@ impl HeavenState {
// Assign a random shift
let assigned_shift = angel_shifts::generate_random_shift(&mut rand::thread_rng());
// Decide difficulty for the next shift
player.difficulty = ((player.shifts_completed as f32 + 1.0) * 0.1).min(1.0);
// Display the shift info
let shift_meta = assigned_shift.metadata();
utils::get_element_by_id::<web_sys::Element>("heaven-shift-title")
......
......@@ -169,7 +169,11 @@ impl gamestate::State for InGameState {
let player: &components::Player = <&components::Player>::query()
.get(&self.world, player_ent)
.unwrap();
gamestate::Transition::replace(states::HeavenState::new(Some(player.clone())))
let mut player = player.clone();
player.shifts_completed += 1;
gamestate::Transition::replace(states::HeavenState::new(Some(player)))
} else if game_manager.wants_game_over() {
gamestate::Transition::replace(states::GameOverState::new())
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment