Finish section 3.4
This commit is contained in:
parent
69194a2dd6
commit
87d825276e
@ -1,5 +1,6 @@
|
||||
use crate::components::{
|
||||
CombatStats, DefenseBonus, Equipped, MeleePowerBonus, Name, SufferDamage, WantsToMelee,
|
||||
CombatStats, DefenseBonus, Equipped, HungerClock, HungerState, MeleePowerBonus, Name,
|
||||
SufferDamage, WantsToMelee,
|
||||
};
|
||||
use crate::{game_log::GameLog, particle_system::ParticleBuilder, Position};
|
||||
use rltk::RGB;
|
||||
@ -21,6 +22,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
||||
ReadStorage<'a, Equipped>,
|
||||
WriteExpect<'a, ParticleBuilder>,
|
||||
ReadStorage<'a, Position>,
|
||||
ReadStorage<'a, HungerClock>,
|
||||
);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
@ -36,6 +38,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
||||
equipped,
|
||||
mut particle_builder,
|
||||
positions,
|
||||
hunger_clock,
|
||||
) = data;
|
||||
|
||||
for (entity, wants_melee, name, stats) in
|
||||
@ -51,6 +54,12 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(hc) = hunger_clock.get(entity) {
|
||||
if hc.state == HungerState::WellFed {
|
||||
offensive_bonus += 1;
|
||||
}
|
||||
}
|
||||
|
||||
let target_stats = combat_stats.get(wants_melee.target).unwrap();
|
||||
if target_stats.hp > 0 {
|
||||
let target_name = names.get(wants_melee.target).unwrap();
|
||||
|
@ -1,5 +1,6 @@
|
||||
use crate::components::{
|
||||
CombatStats, Item, Monster, Player, Position, Viewshed, WantsToMelee, WantsToPickupItem,
|
||||
CombatStats, HungerClock, HungerState, Item, Monster, Player, Position, Viewshed, WantsToMelee,
|
||||
WantsToPickupItem,
|
||||
};
|
||||
use crate::{game_log::GameLog, Map, RunState, State, TileType};
|
||||
use rltk::{Point, Rltk, VirtualKeyCode};
|
||||
@ -125,6 +126,16 @@ fn skip_turn(ecs: &mut World) -> RunState {
|
||||
}
|
||||
}
|
||||
|
||||
// Don't allow healing when hungry or starving
|
||||
let hunger_clocks = ecs.read_storage::<HungerClock>();
|
||||
if let Some(hc) = hunger_clocks.get(*player_entity) {
|
||||
match hc.state {
|
||||
HungerState::Hungry => can_heal = false,
|
||||
HungerState::Starving => can_heal = false,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
if can_heal {
|
||||
let mut health_components = ecs.write_storage::<CombatStats>();
|
||||
let player_hp = health_components.get_mut(*player_entity).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user