Skip to content

Commit

Permalink
Fix panic in abs
Browse files Browse the repository at this point in the history
  • Loading branch information
HadrienRenaud committed Oct 5, 2021
1 parent f37b5d1 commit 0b6e13d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/abs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ fn apply_effect<T: Rng>(card_index: u8, opponent_card_index: u8, player_hb: &mut
}
Abilities::Multiplication => {}, // TODO: Not yet implemented
Abilities::Poisonous => {
player_hb.board[opponent_card_index as usize].hp = 0;
opponent_hb.board[opponent_card_index as usize].hp = 0;
}
Abilities::Glitch => {
if rng.gen() {
player_hb.board[opponent_card_index as usize].atk = relu(opponent_card.atk as i32 - 2);
opponent_hb.board[opponent_card_index as usize].atk = relu(opponent_card.atk as i32 - 2);
events.push(CombatEvents::StatsChange { player_id: opponent_id, card_id: opponent_card.id, hp: 0, at: -2 });
} else {
player_hb.board[opponent_card_index as usize].hp = relu(opponent_card.hp as i32 - 2);
opponent_hb.board[opponent_card_index as usize].hp = relu(opponent_card.hp as i32 - 2);
events.push(CombatEvents::StatsChange { player_id: opponent_id, at: 0, hp: -2, card_id: opponent_card.id });
}
}
Expand Down Expand Up @@ -134,8 +134,6 @@ fn simulate_attack<T: Rng>(att_card_index: usize, att_hb: &mut PlayerData, def_h
events.append(&mut apply_effect(def_card_index, att_card_index, def_hb, att_hb, rng));
}

let replay =

for &card in &att_hb.board {
if card.hp <= 0 {
events.push(CombatEvents::Death { player_id: att_hb.id, card_id: card.id });
Expand Down
2 changes: 1 addition & 1 deletion src/shop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ fn display_ability_animation(
let index = slot.id;
for (e, &s, mut card) in card_query.iter_mut() {
if s.row == ShopSlots::BOARD
&& (s.id == index + 1 || s.id + 1 == index) {
&& (s.id == index + 1 || s.id + 1 == index || s.id == index) {
card.hp += 1;
card.atk += 1;
ev_stats.send(StatsChanged(e));
Expand Down

0 comments on commit 0b6e13d

Please sign in to comment.