removes need to pass BUC to effects
This commit is contained in:
parent
1d9cb04d1f
commit
db9e04069a
4 changed files with 18 additions and 15 deletions
|
|
@ -40,10 +40,10 @@ 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, buc } = &heal.effect_type {
|
||||
if let EffectType::Healing { amount, increment_max } = &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 pool.hit_points.current - before < *amount && *increment_max {
|
||||
// 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;
|
||||
|
|
|
|||
|
|
@ -3,15 +3,9 @@ use crate::{HungerClock, BUC};
|
|||
use specs::prelude::*;
|
||||
|
||||
pub fn restore_food(ecs: &mut World, effect: &EffectSpawner, target: Entity) {
|
||||
if let EffectType::RestoreNutrition { buc } = &effect.effect_type {
|
||||
if let EffectType::RestoreNutrition { amount } = &effect.effect_type {
|
||||
if let Some(hc) = ecs.write_storage::<HungerClock>().get_mut(target) {
|
||||
if buc == &BUC::Blessed {
|
||||
hc.duration += 600;
|
||||
} else if buc == &BUC::Uncursed {
|
||||
hc.duration += 400;
|
||||
} else if buc == &BUC::Cursed {
|
||||
hc.duration += 200;
|
||||
}
|
||||
hc.duration += amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ lazy_static! {
|
|||
|
||||
pub enum EffectType {
|
||||
Damage { amount: i32 },
|
||||
Healing { amount: i32, buc: BUC },
|
||||
Healing { amount: i32, increment_max: bool },
|
||||
Confusion { turns: i32 },
|
||||
Bloodstain,
|
||||
Particle { glyph: FontCharType, fg: RGB, bg: RGB, lifespan: f32, delay: f32 },
|
||||
EntityDeath,
|
||||
ItemUse { item: Entity },
|
||||
RestoreNutrition { buc: BUC },
|
||||
RestoreNutrition { amount: i32 },
|
||||
TriggerFire { trigger: Entity },
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use super::{add_effect, spatial, EffectType, Entity, Targets, World};
|
||||
use super::{add_effect, get_noncursed, spatial, EffectType, Entity, Targets, World};
|
||||
use crate::{
|
||||
gamelog, gui::item_colour_ecs, gui::obfuscate_name_ecs, gui::renderable_colour, Beatitude, Charges, Confusion,
|
||||
Consumable, Destructible, Hidden, InflictsDamage, Item, MagicMapper, Player, Prop, ProvidesHealing,
|
||||
|
|
@ -77,7 +77,12 @@ fn event_trigger(source: Option<Entity>, entity: Entity, target: &Targets, ecs:
|
|||
|
||||
fn handle_restore_nutrition(ecs: &mut World, event: &mut EventInfo, mut logger: gamelog::Logger) -> gamelog::Logger {
|
||||
if ecs.read_storage::<ProvidesNutrition>().get(event.entity).is_some() {
|
||||
add_effect(event.source, EffectType::RestoreNutrition { buc: event.buc.clone() }, event.target.clone());
|
||||
let amount = match event.buc {
|
||||
BUC::Blessed => 600,
|
||||
BUC::Uncursed => 400,
|
||||
BUC::Cursed => 200,
|
||||
};
|
||||
add_effect(event.source, EffectType::RestoreNutrition { amount }, event.target.clone());
|
||||
logger = logger
|
||||
.append("You eat the")
|
||||
.colour(item_colour_ecs(ecs, event.entity))
|
||||
|
|
@ -114,7 +119,11 @@ fn handle_healing(ecs: &mut World, event: &mut EventInfo, mut logger: gamelog::L
|
|||
_ => 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());
|
||||
add_effect(
|
||||
event.source,
|
||||
EffectType::Healing { amount: roll, increment_max: get_noncursed(&event.buc) },
|
||||
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