def test_end_illusion(): logger = MagicMock() battle = Battle("tag", "username", logger) empty_boosts = { "accuracy": 0, "atk": 0, "def": 0, "evasion": 0, "spa": 0, "spd": 0, "spe": 0, } non_empty_boosts = { "accuracy": 1, "atk": 0, "def": -2, "evasion": 3, "spa": 5, "spd": -6, "spe": 2, } battle._player_role = "p2" battle._switch("p2: Celebi", "Celebi", "100/100") battle._switch("p1: Kingdra", "Kingdra, F", "100/100") battle.active_pokemon._boosts = non_empty_boosts assert battle.active_pokemon.species == "celebi" battle._parse_message(["", "replace", "p2: Zoroark", "Zoroark, M"]) assert battle.active_pokemon.species == "zoroark" assert battle.opponent_active_pokemon.species == "kingdra" assert battle.get_pokemon("p2: Zoroark").boosts == non_empty_boosts assert battle.get_pokemon("p2: Celebi").boosts == empty_boosts
def test_battle_side_start_end(): logger = MagicMock() battle = Battle("tag", "username", logger) battle._player_role = "p1" assert not battle.side_conditions condition = "safeguard" battle._parse_message(["", "-sidestart", "p1", condition]) battle._parse_message(["", "-sidestart", "p2", condition]) assert battle.side_conditions == {SideCondition.SAFEGUARD: 1} assert battle.opponent_side_conditions == {SideCondition.SAFEGUARD: 1} battle._parse_message(["", "-sidestart", "p1", condition]) assert battle.side_conditions == {SideCondition.SAFEGUARD: 2} battle._parse_message(["", "-sideend", "p1", condition]) battle._parse_message(["", "-sideend", "p2", condition]) assert not battle.side_conditions assert not battle.opponent_side_conditions with pytest.raises(Exception): battle._side_end("p1", condition) with pytest.raises(Exception): battle._side_end("p2", condition)
def test_battle_side_start_end(): logger = MagicMock() battle = Battle("tag", "username", logger) battle._player_role = "p1" assert not battle.side_conditions condition = "safeguard" battle._side_start("p1", condition) assert battle.side_conditions == {SideCondition.SAFEGUARD} battle._side_end("p1", condition) assert not battle.side_conditions
def test_dynamax(): logger = MagicMock() battle = Battle("tag", "username", logger) battle._player_role = "p1" hydreigon = Pokemon(species="hydreigon") hydreigon._active = True battle._team = {"p1: Hydreigon": hydreigon} assert battle.active_pokemon.is_dynamaxed is not True battle._parse_message(["", "-start", "p1: Hydreigon", "dynamax"]) assert battle.active_pokemon.is_dynamaxed assert battle.dynamax_turns_left == 3 battle._parse_message(["", "-end", "p1: Hydreigon", "dynamax"]) assert not battle.active_pokemon.is_dynamaxed assert battle.dynamax_turns_left is None assert not battle.can_dynamax
def test_battle_get_pokemon(): logger = MagicMock() battle = Battle("tag", "username", logger) # identifier: str, force_self_team: bool = False, details: str = "" battle.get_pokemon("p2: azumarill", force_self_team=True) assert "p2: azumarill" in battle.team battle._player_role = "p2" battle._parse_message(["", "teamsize", "p1", 6]) battle._parse_message(["", "teamsize", "p2", 6]) battle.get_pokemon("p2a: tapukoko") assert "p2: tapukoko" in battle.team battle.get_pokemon("p1: hydreigon", details="Hydreigon, F") assert "p1: hydreigon" in battle.opponent_team assert battle.get_pokemon("p2: tapufini").species == "tapufini" assert battle.get_pokemon("p2: tapubulu").types == ( PokemonType.GRASS, PokemonType.FAIRY, ) assert battle.get_pokemon("p2: tapulele").base_stats == { "atk": 85, "def": 75, "hp": 70, "spa": 130, "spd": 115, "spe": 95, } battle.get_pokemon("p2: yveltal") assert len(battle.team) == 6 with pytest.raises(ValueError): battle.get_pokemon("p2: pikachu") assert "p2: pikachu" not in battle.team