|
pub fn spell_trigger(creator : Option<Entity>, spell: Entity, targets : &Targets, ecs: &mut World) { |
|
if let Some(template) = ecs.read_storage::<SpellTemplate>().get(spell) { |
|
let mut pools = ecs.write_storage::<Pools>(); |
|
if let Some(caster) = creator { |
|
if let Some(pool) = pools.get_mut(caster) { |
|
if template.mana_cost <= pool.mana.current { |
|
pool.mana.current -= template.mana_cost; |
|
} |
|
} |
|
} |
|
} |
|
event_trigger(creator, spell, targets, ecs); |
|
} |
There is a missing return statement after the check on the mana pool.
Currently, if the caster lacks the mana for a spell, the pool won't be updated but the spell will still be cast.
For the player, this won't happen because the spell will be cast from the targeting menu, which has the proper check against this, but a direct call to spell_trigger could lead to an error.
(If the check is always supposed to always have been done prior to the call, then let's simply remove it here.)
rustrogueliketutorial/book/src/chapter_66.md
Lines 453 to 465 in 33872fe
There is a missing
returnstatement after the check on the mana pool.Currently, if the caster lacks the mana for a spell, the pool won't be updated but the spell will still be cast.
For the player, this won't happen because the spell will be cast from the targeting menu, which has the proper check against this, but a direct call to
spell_triggercould lead to an error.(If the check is always supposed to always have been done prior to the call, then let's simply remove it here.)