def on_overkill(self, friendly_board: PlayerBoard, defending_minion: Minion, enemy_board: PlayerBoard): overkill_amount = defending_minion.health * -1 neighbors = [ x for x in enemy_board.get_minions_neighbors(defending_minion) if x ] num_neighbors = len(neighbors) if num_neighbors > 0: if self.golden: for i in range(num_neighbors): neighbors[i].receive_damage(overkill_amount, enemy_board) else: index = random.randint(0, num_neighbors - 1) neighbors[index].receive_damage(overkill_amount, enemy_board)
def attack(self, attacking_minion: Minion, defending_minion: Minion, attacking_board: PlayerBoard, defending_board: PlayerBoard): """Let one minion attack the other Arguments: attacking_minion {Minion} -- Minion that attacks defending_minion {Minion} -- Minion that is attacked """ # Pre-attack triggers attacking_board.call_triggers(TriggerType.ON_FRIENDLY_BEFORE_ATTACK, attacking_minion, attacking_board, defending_minion, defending_board) defending_board.call_triggers(TriggerType.ON_FRIENDLY_ATTACKED, defending_minion, defending_board, attacking_board) # If minion is killed by pyro spawn trigger, attack is cancelled if defending_minion.dead: attacking_minion.on_attack_after(attacking_board, defending_board) return # Deal attack damage if attacking_minion.cleave: # Minions hit with cleave should take damage all at once, but triggers resolve after neighbors = defending_board.get_minions_neighbors(defending_minion) defenders = [neighbors[0], defending_minion, neighbors[1]] for minion in [x for x in defenders if x]: self.deal_attack_damage(minion, defending_board, attacking_minion, attacking_board, True) self.deal_attack_damage(attacking_minion, attacking_board, defending_minion, defending_board) else: self.deal_attack_damage(defending_minion, defending_board, attacking_minion, attacking_board) self.deal_attack_damage(attacking_minion, attacking_board, defending_minion, defending_board) # Damage triggers from cleave and herald of flame should be resolved after attack and overkill trigger resolution for trigger in defending_board.deferred_damage_triggers: trigger(defending_board) defending_board.deferred_damage_triggers.clear() # Post attack triggers (macaw) attacking_minion.on_attack_after(attacking_board, defending_board)