Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chapter 66] Missing return in spell_trigger #228

Open
PierreGuyot opened this issue Jan 14, 2025 · 0 comments
Open

[Chapter 66] Missing return in spell_trigger #228

PierreGuyot opened this issue Jan 14, 2025 · 0 comments

Comments

@PierreGuyot
Copy link

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant