diff --git a/src/core/battle.rs b/src/core/battle.rs index bd09b457..c02cc771 100644 --- a/src/core/battle.rs +++ b/src/core/battle.rs @@ -49,11 +49,13 @@ pub enum Weight { Heavy = 1, Immovable = 2, } + impl Default for Weight { fn default() -> Self { Weight::Normal } } + impl fmt::Display for Weight { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { diff --git a/src/core/battle/execute.rs b/src/core/battle/execute.rs index 79cf9644..0b86a63c 100644 --- a/src/core/battle/execute.rs +++ b/src/core/battle/execute.rs @@ -943,14 +943,12 @@ fn execute_use_ability_explode_push( let to = Dir::get_neighbor_pos(pos, dir); let mut effects = Vec::new(); if state.map().is_inboard(to) && !state::is_tile_blocked(state, to) { - effects.push( - effect::Knockback { - from: pos, - to, - strength: PushStrength { 0: Weight::Normal }, - } - .into(), - ); + let effect = effect::Knockback { + from: pos, + to, + strength: PushStrength(Weight::Normal), + }; + effects.push(effect.into()); context.moved_actor_ids.push(id); } context.instant_effects.push((id, effects)); diff --git a/src/core/battle/state/apply.rs b/src/core/battle/state/apply.rs index 992dccd3..34098185 100644 --- a/src/core/battle/state/apply.rs +++ b/src/core/battle/state/apply.rs @@ -339,7 +339,6 @@ fn apply_effect_wound(state: &mut State, id: Id, effect: &effect::Wound) { fn apply_effect_knockback(state: &mut State, id: Id, effect: &effect::Knockback) { assert!(state.map().is_inboard(effect.from)); assert!(state.map().is_inboard(effect.to)); - assert!(!state::is_tile_blocked(state, effect.to)); let parts = state.parts_mut(); if effect.strength.can_push(parts.blocker.get(id).weight) { diff --git a/src/core/battle/tests.rs b/src/core/battle/tests.rs index c6dd4c84..43b99c08 100644 --- a/src/core/battle/tests.rs +++ b/src/core/battle/tests.rs @@ -1343,6 +1343,7 @@ fn throw_bomb_push_normal() { }, ], ); + assert_eq!(state.parts().pos.get(Id(1)).0, PosHex { q: 0, r: 4 }); } #[test] fn throw_bomb_push_heavy() { @@ -1359,15 +1360,16 @@ fn throw_bomb_push_heavy() { [ component_agent_dull(), component_strength(1), - component_blocker(Weight::Normal), + component_blocker(Weight::Heavy), ] .to_vec(), ), ("bomb_push", Vec::new()), ]); + let initial_heavy_position = PosHex { q: 1, r: 2 }; let scenario = scenario::default() .object(P0, "thrower", PosHex { q: 0, r: 0 }) - .object(P1, "heavy", PosHex { q: 1, r: 2 }); + .object(P1, "heavy", initial_heavy_position); let mut state = debug_state(prototypes, scenario); exec_and_check( &mut state, @@ -1442,4 +1444,5 @@ fn throw_bomb_push_heavy() { }, ], ); + assert_eq!(state.parts().pos.get(Id(1)).0, initial_heavy_position); }