Add hunger

This commit is contained in:
2022-01-29 00:31:00 +01:00
parent cb17a9c356
commit 74c05f97af
10 changed files with 280 additions and 74 deletions

22
src/healing_system.rs Normal file
View File

@@ -0,0 +1,22 @@
use specs::prelude::*;
use crate::{CombatStats, GameLog, Heals};
pub struct HealingSystem {}
impl<'a> System<'a> for HealingSystem {
type SystemData = (
WriteStorage<'a, Heals>,
WriteStorage<'a, CombatStats>,
);
fn run(&mut self, data: Self::SystemData) {
let (mut heals, mut stats) = data;
for (heal, mut stats) in (&heals, &mut stats).join() {
stats.hp = i32::min(stats.max_hp, stats.hp + heal.amount.iter().sum::<i32>());
}
heals.clear();
}
}