Пример #1
0
def major_actions(battle: Battle, split_line, side_dict):
    status = ["brn", "frz", "par", "psn", "tox", "slp"]
    pos_dict = {"a": 1, "b": 2}
    # move, used to decide that a pokemon can't Fake Out anymore
    if split_line[0] == "move":
        side = side_dict[split_line[1][0:2]]
        position = pos_dict[split_line[1][2]]
        move = formatting.format_move(split_line[2])  # unused
        pokemon = battle.get_pokemon(side, position)
        pokemon.can_fake_out = False
    # switch
    elif split_line[0] == "switch":
        side = side_dict[split_line[1][0:2]]
        pokemon_id = split_line[2].split(',')[0]
        position = pos_dict[split_line[1][2]]
        battle.update_switch(side, pokemon_id, position)
    # swap positions i.e. Ally Switch
    elif split_line[0] == "swap":
        side = side_dict[split_line[1][0:2]]
        pokemon1, pokemon2 = battle.active_pokemon(side)
        pokemon1.active, pokemon2.active = pokemon2.active, pokemon1.active
    # details change i.e. Mega Evolution
    elif split_line[0] == "detailschange":
        new_id = split_line[2].split(',')[0]
        position = pos_dict[split_line[1][2]]
        if (split_line[1][0:2] == battle.my_side):
            battle.form_change("bot", position, new_id)
        else:
            battle.form_change("foe", position, new_id)
    # includes flinches - use for Stomping Tantrum boost?
    elif split_line[0] == "cant":
        side = side_dict[split_line[1][0:2]]
        position = pos_dict[split_line[1][2]]
        pokemon = battle.get_pokemon(side, position)
        pokemon.can_fake_out = False
    # Pokemon fainting, currently do for bot team with team_data anyways
    elif split_line[0] == "faint":
        position = pos_dict[split_line[1][2]]
        side = side_dict[split_line[1][0:2]]
        pokemon = battle.get_pokemon(side, position)
        pokemon.fainted = True
    # Pokemon on team at preview, currently handled otherwise with battle.initialise_teams() called from main
    elif split_line[0] == "poke":
        pass
        '''
        if battle.player_id not in split_line[1]:
            pkm = split_line[2].split(', ')
            battle.update_enemy(pkm[0], pkm[1][1:] if len(pkm) > 1 and 'L' in pkm[1] else '100', 100)
        '''
    # indicates updating counter for things like TR/TW/Weather/Terrain
    elif split_line[0] == "upkeep":
        battle.upkeep_counters()
    # new turn, if turn 1 then start switching out old Pokemon on new switches
    elif split_line[0] == "turn":
        if (split_line[1] == "1"):
            battle.at_team_preview = False
        print("\nTurn {}".format(split_line[1]))  # print turn number
    else:
        pass