Speed with TURN_COST and slight randomisation to reduce predictability
This commit is contained in:
parent
dce40ac741
commit
aac6e0ad02
12 changed files with 200 additions and 145 deletions
|
|
@ -1,40 +1,19 @@
|
|||
use super::{gamelog, HungerClock, HungerState, RunState, SufferDamage};
|
||||
use super::{gamelog, HungerClock, HungerState, SufferDamage};
|
||||
use specs::prelude::*;
|
||||
|
||||
pub struct HungerSystem {}
|
||||
|
||||
impl<'a> System<'a> for HungerSystem {
|
||||
#[allow(clippy::type_complexity)]
|
||||
type SystemData = (
|
||||
Entities<'a>,
|
||||
WriteStorage<'a, HungerClock>,
|
||||
ReadExpect<'a, Entity>,
|
||||
ReadExpect<'a, RunState>,
|
||||
WriteStorage<'a, SufferDamage>,
|
||||
);
|
||||
type SystemData =
|
||||
(Entities<'a>, WriteStorage<'a, HungerClock>, ReadExpect<'a, Entity>, WriteStorage<'a, SufferDamage>);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (entities, mut hunger_clock, player_entity, runstate, mut inflict_damage) = data;
|
||||
let (entities, mut hunger_clock, player_entity, mut inflict_damage) = data;
|
||||
|
||||
for (entity, mut clock) in (&entities, &mut hunger_clock).join() {
|
||||
let mut proceed = false;
|
||||
|
||||
match *runstate {
|
||||
RunState::PlayerTurn => {
|
||||
if entity == *player_entity {
|
||||
proceed = true;
|
||||
}
|
||||
}
|
||||
RunState::MonsterTurn => {
|
||||
if entity != *player_entity {
|
||||
proceed = true;
|
||||
}
|
||||
}
|
||||
_ => proceed = false,
|
||||
}
|
||||
|
||||
if !proceed {
|
||||
return;
|
||||
if entity == *player_entity {
|
||||
rltk::console::log(format!("HUNGER TICK for Player [current clock: {}]", clock.duration));
|
||||
}
|
||||
clock.duration -= 1;
|
||||
if clock.duration > 0 {
|
||||
|
|
@ -44,28 +23,28 @@ impl<'a> System<'a> for HungerSystem {
|
|||
match clock.state {
|
||||
HungerState::Satiated => {
|
||||
clock.state = HungerState::Normal;
|
||||
clock.duration = 300;
|
||||
clock.duration = 1200;
|
||||
if entity == *player_entity {
|
||||
gamelog::Logger::new().append("You are no longer satiated.").log();
|
||||
}
|
||||
}
|
||||
HungerState::Normal => {
|
||||
clock.state = HungerState::Hungry;
|
||||
clock.duration = 100;
|
||||
clock.duration = 400;
|
||||
if entity == *player_entity {
|
||||
gamelog::Logger::new().colour(rltk::RED).append("You feel hungry.").log();
|
||||
}
|
||||
}
|
||||
HungerState::Hungry => {
|
||||
clock.state = HungerState::Weak;
|
||||
clock.duration = 50;
|
||||
clock.duration = 200;
|
||||
if entity == *player_entity {
|
||||
gamelog::Logger::new().colour(rltk::RED).append("You feel weak with hunger.").log();
|
||||
}
|
||||
}
|
||||
HungerState::Weak => {
|
||||
clock.state = HungerState::Fainting;
|
||||
clock.duration = 50;
|
||||
clock.duration = 200;
|
||||
if entity == *player_entity {
|
||||
gamelog::Logger::new().colour(rltk::RED).append("You feel hungry enough to faint.").log();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue