standardises entity names
This commit is contained in:
parent
d0416b2563
commit
1d9cb04d1f
14 changed files with 131 additions and 47 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use super::{add_effect, targeting, EffectSpawner, EffectType, Entity, Targets, World};
|
||||
use super::{add_effect, get_noncursed, targeting, EffectSpawner, EffectType, Entity, Targets, World};
|
||||
use crate::{
|
||||
gamelog,
|
||||
gamesystem::{hp_per_level, mana_per_level},
|
||||
|
|
@ -40,8 +40,14 @@ pub fn inflict_damage(ecs: &mut World, damage: &EffectSpawner, target: Entity) {
|
|||
pub fn heal_damage(ecs: &mut World, heal: &EffectSpawner, target: Entity) {
|
||||
let mut pools = ecs.write_storage::<Pools>();
|
||||
if let Some(pool) = pools.get_mut(target) {
|
||||
if let EffectType::Healing { amount } = heal.effect_type {
|
||||
if let EffectType::Healing { amount, buc } = &heal.effect_type {
|
||||
let before = pool.hit_points.current;
|
||||
pool.hit_points.current = i32::min(pool.hit_points.max, pool.hit_points.current + amount);
|
||||
if pool.hit_points.current - before < *amount && get_noncursed(buc) {
|
||||
// If the heal was not fully effective, and healing source was noncursed, increase max HP by 1.
|
||||
pool.hit_points.max += 1;
|
||||
pool.hit_points.current += 1;
|
||||
}
|
||||
add_effect(
|
||||
None,
|
||||
EffectType::Particle {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ lazy_static! {
|
|||
|
||||
pub enum EffectType {
|
||||
Damage { amount: i32 },
|
||||
Healing { amount: i32 },
|
||||
Healing { amount: i32, buc: BUC },
|
||||
Confusion { turns: i32 },
|
||||
Bloodstain,
|
||||
Particle { glyph: FontCharType, fg: RGB, bg: RGB, lifespan: f32, delay: f32 },
|
||||
|
|
@ -143,3 +143,11 @@ fn affect_entity(ecs: &mut World, effect: &EffectSpawner, target: Entity) {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_noncursed(buc: &BUC) -> bool {
|
||||
if buc == &BUC::Cursed {
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ fn handle_restore_nutrition(ecs: &mut World, event: &mut EventInfo, mut logger:
|
|||
.append_n(obfuscate_name_ecs(ecs, event.entity).0)
|
||||
.colour(WHITE)
|
||||
.period()
|
||||
.buc(event.buc.clone(), Some("Blech! Rotten."), Some("Delicious."));
|
||||
.buc(event.buc.clone(), Some("Blech! Rotten"), Some("Delicious"));
|
||||
event.log = true;
|
||||
}
|
||||
return logger;
|
||||
|
|
@ -108,8 +108,13 @@ fn handle_magic_mapper(ecs: &mut World, event: &mut EventInfo, mut logger: gamel
|
|||
fn handle_healing(ecs: &mut World, event: &mut EventInfo, mut logger: gamelog::Logger) -> gamelog::Logger {
|
||||
if let Some(healing_item) = ecs.read_storage::<ProvidesHealing>().get(event.entity) {
|
||||
let mut rng = ecs.write_resource::<RandomNumberGenerator>();
|
||||
let roll = rng.roll_dice(healing_item.n_dice, healing_item.sides) + healing_item.modifier;
|
||||
add_effect(event.source, EffectType::Healing { amount: roll }, event.target.clone());
|
||||
let buc_mod = match event.buc {
|
||||
BUC::Blessed => 2,
|
||||
BUC::Cursed => -1,
|
||||
_ => 0,
|
||||
};
|
||||
let roll = rng.roll_dice(healing_item.n_dice + buc_mod, healing_item.sides) + healing_item.modifier;
|
||||
add_effect(event.source, EffectType::Healing { amount: roll, buc: event.buc.clone() }, event.target.clone());
|
||||
for target in get_entity_targets(&event.target) {
|
||||
if ecs.read_storage::<Prop>().get(target).is_some() || ecs.read_storage::<Item>().get(target).is_some() {
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue