From 0b6e13d2cf7019c206921fdf976b02c83f4fb87d Mon Sep 17 00:00:00 2001 From: Hadrien RENAUD Date: Tue, 5 Oct 2021 12:04:57 +0200 Subject: [PATCH] Fix panic in abs --- src/abs.rs | 8 +++----- src/shop.rs | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/abs.rs b/src/abs.rs index d10c9d1..2d44911 100644 --- a/src/abs.rs +++ b/src/abs.rs @@ -77,14 +77,14 @@ fn apply_effect(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 }); } } @@ -134,8 +134,6 @@ fn simulate_attack(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 }); diff --git a/src/shop.rs b/src/shop.rs index 3a39539..fc3298c 100644 --- a/src/shop.rs +++ b/src/shop.rs @@ -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));