def test_2ndary_status(): """Status effects as secondary effect.""" spinda = Pokemon(name="spinda", moves=["nuzzle", "inferno"]) charizard_target = Pokemon(name="charizard", moves=["synthesis", "recover"]) nuzzle = SecondaryEffectMove(**MOVE_DATA["nuzzle"]) inferno = SecondaryEffectMove(**MOVE_DATA["inferno"]) # Assert that Muk gets paralyzed nuzzle.apply_secondary_effect(spinda, charizard_target) assert charizard_target.status == PAR_STATUS # Assert that if there's another status effect, it # cannot be overwritten charizard_target.status = PSN_STATUS nuzzle.apply_secondary_effect(spinda, charizard_target) assert charizard_target.status == PSN_STATUS # Assert that the type immunities are respected charizard_target.status = None inferno.apply_secondary_effect(spinda, charizard_target) assert charizard_target.status is None # Assert that if no damage, no status effect trapinch_target = Pokemon(name="trapinch", moves=["synthesis"]) nuzzle.apply_secondary_effect(spinda, trapinch_target) assert trapinch_target.status is None
def status_dmg_test(): """Test Status Damage applied correctly.""" pkmn = Pokemon(name="spinda", moves=["tackle", "watergun"], level=50) pkmn.status = BRN_STATUS pkmn.apply_status_damage() assert pkmn.max_hp > pkmn.current_hp
def test_engine_2ndary_status(): """Status effects as secondary effect.""" spinda = Pokemon(name="spinda", moves=["nuzzle", "inferno"]) charizard_target = Pokemon(name="charizard", moves=["synthesis", "recover"]) player1 = PokemonAgent([spinda]) player2 = PokemonAgent([charizard_target]) player_first_move = ("ATTACK", 0) p_eng = PokemonEngine() p_eng.initialize_battle(player1, player2) # Assert that Muk gets paralyzed p_eng.run_single_turn(player_first_move, player_first_move, player1, player2) assert p_eng.game_state["player2"]["active"].status == PAR_STATUS # Assert that if there's another status effect, it # cannot be overwritten charizard_target.status = PSN_STATUS p_eng.initialize_battle(player1, player2) p_eng.run_single_turn(player_first_move, player_first_move, player1, player2) assert p_eng.game_state["player2"]["active"].status == PSN_STATUS # Assert that the type immunities are respected charizard_target.status = None player_second_move = ("ATTACK", 1) p_eng.initialize_battle(player1, player2) p_eng.run_single_turn(player_second_move, player_second_move, player1, player2) assert p_eng.game_state["player2"]["active"].status is None # Assert that if no damage, no status effect trapinch_target = Pokemon(name="trapinch", moves=["synthesis"]) player3 = PokemonAgent([trapinch_target]) p_eng.initialize_battle(player1, player3) p_eng.run_single_turn(player_first_move, player_first_move, player1, player3) assert p_eng.game_state["player2"]["active"].status is None
def test_attack_burn(): """ Test that the attack drop happens on burn. Burned attack = 1/2 * normal attack """ exploud = Pokemon(name="exploud", moves=["tackle"]) exploud_brn = Pokemon(name="exploud", moves=["tackle"]) exploud_brn.status = BRN_STATUS assert exploud.attack == exploud_brn.attack assert floor(exploud.effective_stat("atk") / 2) ==\ exploud_brn.effective_stat("atk")
def test_speed_paralyze(): """ Test paralysis speed drop. Paralyzed speed = 1/2 * normal speed """ exploud = Pokemon(name="exploud", moves=["tackle"]) exploud_par = Pokemon(name="exploud", moves=["tackle"]) exploud_par.status = PAR_STATUS assert exploud.speed == exploud_par.speed assert floor(exploud.effective_stat("spe") / 2) ==\ exploud_par.effective_stat("spe")
def test_poison_dmg(): """Test that poison damage is applied.""" exploud = Pokemon(name="exploud", moves=["synthesis"]) exploud_psn = Pokemon(name="exploud", moves=["synthesis"]) exploud_psn.status = PSN_STATUS player1 = PokemonAgent([exploud]) player2 = PokemonAgent([exploud_psn]) player_move = ("ATTACK", 0) p_eng = PokemonEngine() p_eng.initialize_battle(player1, player2) p_eng.run_single_turn(player_move, player_move, player1, player2) assert p_eng.game_state["player2"]["active"].current_hp == \ int(1+7*p_eng.game_state["player2"]["active"].max_hp/8)
def range_status(): """Test damage range with burn status.""" dsc = DamageStatCalc() params = {} params["atk"] = {} params["def"] = {} params["hp"] = {} move = generate_move(MOVE_DATA["tackle"]) attacker = Pokemon(name="spinda", moves=["tackle"]) defender = Pokemon(name="spinda", moves=["tackle"]) attacker.status = BRN_STATUS dmg_range = dsc.calculate_range(move, attacker, defender, params) assert dmg_range[0] == 8 assert dmg_range[1] == 10
def test_toxic_dmg(): """Toxic damage applied correctly.""" exploud = Pokemon(name="exploud", moves=["synthesis"]) exploud_tox = Pokemon(name="exploud", moves=["shadowball"]) exploud_tox.status = TOX_STATUS player1 = PokemonAgent([exploud]) player2 = PokemonAgent([exploud_tox]) player_move = ("ATTACK", 0) p_eng = PokemonEngine() p_eng.initialize_battle(player1, player2) # First turn is 15/16 p_eng.run_single_turn(player_move, player_move, player1, player2) assert p_eng.game_state["player2"]["active"].current_hp == \ int(1+15*p_eng.game_state["player2"]["active"].max_hp/16) prev_hp = p_eng.game_state["player2"]["active"].current_hp # Second turn is ~13/16 p_eng.run_single_turn(player_move, player_move, player1, player2) assert p_eng.game_state["player2"]["active"].current_hp == \ int(1 + prev_hp - 2*p_eng.game_state["player2"]["active"].max_hp/16)
def test_determine_faster(): """ Test ability to determine if player faster. A -> Abomasnow, S -> Spinda Under normal conditions, A is faster. When A is paralyzed, S is faster. When S is boosted, S is faster. When A and S are both boosted, A is faster. When A and S are both boosted, and A is paralyzed, S is faster. """ player_spinda = Pokemon(name="spinda", moves=["tackle"]) opp_abomasnow = Pokemon(name="abomasnow", moves=["tackle"]) player_move = ("ATTACK", 0) opp_move = ("ATTACK", "tackle") player_gs = {"team": [], "active": player_spinda} player = BasicPlanningPokemonAgent(tier="pu", team=[player_spinda]) # Slower than regular abomasnow opp_gs = { "data": anonymize_gamestate_helper({ "team": [], "active": opp_abomasnow }) } player.update_gamestate(player_gs, opp_gs) player.init_opp_gamestate(opp_gs["data"]["team"], opp_gs["data"]["active"]) assert not player.determine_faster(player.game_state.gamestate, opp_gs, player_move, opp_move) # Faster than paralyzed abonasnow opp_abomasnow.status = PAR_STATUS opp_gs = { "data": anonymize_gamestate_helper({ "team": [], "active": opp_abomasnow }) } player.update_gamestate(player_gs, opp_gs) assert player.determine_faster(player.game_state.gamestate, opp_gs, player_move, opp_move) # Faster than regular abomasnow at +6 player_gs["active"]["boosts"]["spe"] = 6 opp_abomasnow.status = None opp_gs = { "data": anonymize_gamestate_helper({ "team": [], "active": opp_abomasnow }) } player.update_gamestate(player_gs, opp_gs) assert player.determine_faster(player.game_state.gamestate, opp_gs, player_move, opp_move) # Slower than regular abomasnow when both at +6 opp_abomasnow.boosts["spe"] = 6 opp_gs = { "data": anonymize_gamestate_helper({ "team": [], "active": opp_abomasnow }) } player.update_gamestate(player_gs, opp_gs) assert not player.determine_faster(player.game_state.gamestate, opp_gs, player_move, opp_move) # Faster than paralyzed abomasnow when both at +6 opp_abomasnow.status = PAR_STATUS opp_gs = { "data": anonymize_gamestate_helper({ "team": [], "active": opp_abomasnow }) } player.update_gamestate(player_gs, opp_gs) assert player.determine_faster(player.game_state.gamestate, opp_gs, player_move, opp_move)