def _process_round_character(game: game_runtime.Game, guild: guild_runtime.Guild, character: character_runtime.Character): ''' Process a round of game for one character. If the character has no more actions, set the finished flag. ''' guild_turn = game.turns[guild.slug] turn_character = guild_turn.characters.get(character.slug, None) turn_actions = turn_character.actions if turn_character else [] if not turn_actions or character.turn_next_action >= len(turn_actions): character.finish_turn() else: if character.turn_round <= game.turn_round: turn_action = turn_actions[character.turn_next_action] place = game.places[turn_action.place_slug] action = action_services.find_action(turn_action.action_slug, game, place) if turn_action.target: target_guild = game.guilds[turn_action.target.guild_slug] target_character = target_guild.members[turn_action.target.character_slug] else: target_guild = None target_character = None context = action_runtime.ActionContext( guild = guild, character = character, place = place, action = action, target_guild = target_guild, target_character = target_character, ) action_services.process_action(game, context)
def init_character_rounds(character: character_runtime.Character): ''' Reset any round info to start processing rounds in a new turn. ''' character.reset_turn_finished() character.last_turn.reset()