Skip to content

Commit

Permalink
replaced assert in attack action with graceful handling
Browse files Browse the repository at this point in the history
  • Loading branch information
micutio committed Dec 11, 2020
1 parent 9a9b3b4 commit d013696
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/entity/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl ActAttack {
impl Action for ActAttack {
fn perform(
&self,
_state: &mut GameState,
state: &mut GameState,
objects: &mut GameObjects,
owner: &mut Object,
) -> ActionResult {
Expand All @@ -310,13 +310,13 @@ impl Action for ActAttack {
.filter(|o| o.physics.is_blocking && o.pos.is_equal(&target_pos))
.collect();

assert!(valid_targets.len() >= 1);
if let Some(_target_obj) = valid_targets.first() {
// TODO: Take damage
ActionResult::Success {
callback: ObjectFeedback::NoFeedback,
}
} else {
state.log.add("Nothing to attack here", MsgClass::Info);
ActionResult::Failure
}
}
Expand Down

0 comments on commit d013696

Please sign in to comment.