def _init_game_rounds(game: game_runtime.Game): ''' Reset any round info to start processing rounds in a new turn. ''' game.reset_turn_round() for guild in game.guilds.values(): guild_services.init_guild_rounds(guild)
def _process_round(game: game_runtime.Game): ''' Process a round of game for all characters. ''' for guild in game.guilds.values(): for character in guild.members.values(): if not character.turn_finished: _process_round_character(game, guild, character) game.advance_turn_round()
def submit_turn(game: game_runtime.Game, turn: game_runtime.Turn): ''' Submit a turn from one player. If this was the last slacker, and now all players have sent their turns, process them and update the game. ''' if not turn.guild_slug in game.guilds: raise exceptions.InvalidValue('Not existing guild {slug}'.format(slug = turn.guild_slug)) if turn.guild_slug in game.turns: raise exceptions.InvalidValue('Duplicated turn for guild {slug}'.format(slug = turn.guild_slug)) game.add_turn(turn) if game.has_all_turns(): _init_game_rounds(game) _process_turns(game) game.clear_turns()