Skip to content

Commit

Permalink
fix feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Jan 14, 2020
1 parent a4b486a commit c7b8aac
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/core/battle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 6 additions & 8 deletions src/core/battle/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 0 additions & 1 deletion src/core/battle/state/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions src/core/battle/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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,
Expand Down Expand Up @@ -1442,4 +1444,5 @@ fn throw_bomb_push_heavy() {
},
],
);
assert_eq!(state.parts().pos.get(Id(1)).0, initial_heavy_position);
}

0 comments on commit c7b8aac

Please sign in to comment.