def battle(self, clearing: Clearing, defender: Player) -> None: if self.has_trait(TRAIT_MARKSMAN): # Fortified MM is currently the only way for a piece to require two hits to be removed in battle # Marksman Vagabot is currently the only way for a player to deal hits in battle to a bot before the roll # To prevent messy logic in handling taking hits, we just deal two hits of damage in this case, which will # still functionally remove one building if defender.halves_damage(clearing): marksman_damage_result = defender.suffer_damage(clearing, 2, self, is_attacker=False) else: marksman_damage_result = defender.suffer_damage(clearing, 1, self, is_attacker=False) self.add_victory_points(marksman_damage_result.points_awarded + self.supplementary_score_for_removed_pieces_in_battle( defender, marksman_damage_result.removed_pieces, is_attacker=True)) random_rolls = (random.randint(0, 3), random.randint(0, 3)) # Defender allocates the rolls - high roll to attacker, low roll to defender, except in the case of Veterans roll_result = defender.allocate_rolls_as_defender(random_rolls) # Each battler caps their hits and adds their relevant bonus hits attacker_hits = (self.cap_rolled_hits(clearing, roll_result.attacker_roll) + self.get_bonus_hits(clearing, defender, is_attacker=True)) defender_hits = (defender.cap_rolled_hits(clearing, roll_result.defender_roll) + defender.get_bonus_hits(clearing, defender, is_attacker=False)) # Each battler removes their pieces and calculates how much VP the opponent should earn from the battle defender_damage_result = defender.suffer_damage(clearing, attacker_hits, self, is_attacker=False) attacker_damage_result = self.suffer_damage(clearing, defender_hits, defender, is_attacker=True) # Each battler scores their awarded VP, plus any bonus VP they deserve (such as Vagabot from removing warriors) self.add_victory_points(defender_damage_result.points_awarded + self.supplementary_score_for_removed_pieces_in_battle( defender, defender_damage_result.removed_pieces, is_attacker=True)) defender.add_victory_points(attacker_damage_result.points_awarded + defender.supplementary_score_for_removed_pieces_in_battle( self, attacker_damage_result.removed_pieces, is_attacker=False))
def battle(self, clearing: Clearing, defender: Player) -> None: random_rolls = (random.randint(0, 3), random.randint(0, 3)) # Defender allocates the rolls - high roll to attacker, low roll to defender, except in the case of Veterans roll_result = defender.allocate_rolls_as_defender(random_rolls) # Each battler caps their hits and adds their relevant bonus hits attacker_hits = ( self.cap_rolled_hits(clearing, roll_result.attacker_roll) + self.get_bonus_hits(clearing, defender, is_attacker=True)) defender_hits = ( defender.cap_rolled_hits(clearing, roll_result.defender_roll) + defender.get_bonus_hits(clearing, defender, is_attacker=False)) # Each battler removes their pieces and calculates how much VP the opponent should earn from the battle defender_damage_result = defender.suffer_damage(clearing, attacker_hits, self, is_attacker=False) attacker_damage_result = self.suffer_damage(clearing, defender_hits, defender, is_attacker=True) # Each battler scores their awarded VP, plus any bonus VP they deserve (such as Vagabot from removing warriors) self.add_victory_points( defender_damage_result.points_awarded + self.supplementary_score_for_removed_pieces_in_battle( defender, defender_damage_result.removed_pieces, is_attacker=True)) if self.has_trait(TRAIT_WAR_TAX): removed_buildings_and_tokens = [ piece for piece in defender_damage_result.removed_pieces if isinstance(piece, Building) or isinstance(piece, Token) ] defender.add_victory_points(len(removed_buildings_and_tokens) * -1) defender.add_victory_points( attacker_damage_result.points_awarded + defender.supplementary_score_for_removed_pieces_in_battle( self, attacker_damage_result.removed_pieces, is_attacker=False) )