def test_get_battalions(self): horses, elephants, armoured_tanks, sling_guns = 100, 50, 10, 5 army = Army(horses=horses, elephants=elephants, armoured_tanks=armoured_tanks, sling_guns=sling_guns) assert set(army.get_battalions()) == set([BattalionType.HORSES, BattalionType.ELEPHANTS, BattalionType.SLINGGUNS, BattalionType.ARMOUREDTANKS])
def get_winning_army(self, enemy_army: Army): battle_result: bool = True for enemy_battalion in enemy_army.get_battalions(): enemy_strength = enemy_army.get_battalion_strength(enemy_battalion) battle_result &= self.resolve_battalion(enemy_battalion, enemy_strength) required_battalions = self.__result_army.get_all_battalion_with_strength( ) return battle_result, required_battalions
def get_winning_army(self, enemy_army: Army): """Returns the minimum required army and a bool indicating the result of the battle with the returned army True : Returned army will win False : Returned army will lose Arguments: enemy_army {Army} -- [The army to battle against] Returns: Army -- [Minimum required army to defeat enemy_army] battle_result {bool} -- [boolean indicating the result of the battle] """ battle_result: bool = True for enemy_battalion in enemy_army.get_battalions(): enemy_strength = enemy_army.get_battalion_strength(enemy_battalion) battle_result &= self.resolve_battalion(enemy_battalion, enemy_strength) required_battalions = self.__result_army.get_all_battalion_with_strength( ) return battle_result, required_battalions