def resolve_day_round(g, alert=None): """ Like resolve_night_round, but for the day! """ alive_v = alive_for_village(g) alive_w = alive_for_werewolf(g) # we want to show vote results. vote_list_str = list_votes(g)[0] + '\n' if len(alive_w) >= len(alive_v): new_g = update_game_state(g, 'status', status='INACTIVE') new_g = update_game_state(new_g, 'reset_game_state') return vote_list_str + make_end_round_str(new_g, alert, 'w') # returns and sends message elif len(alive_w) == 0: new_g = update_game_state(g, 'status', status='INACTIVE') new_g = update_game_state(new_g, 'reset_game_state') return vote_list_str + make_end_round_str(new_g, alert, 'v') # returns and sends message else: # turn it into night and start night round round_end_str = vote_list_str + make_end_round_str(g) + start_night_round(g) return round_end_str
def resolve_night_round(game_state, alert=None): """Reconcile all night actions and update the game_state. The game can either continue into day mode or it will end with the night actions. """ alive_v = status.alive_for_village(game_state) alive_w = status.alive_for_werewolf(game_state) if len(alive_w) >= len(alive_v): new_game = update_game_state(game_state, 'status', status='INACTIVE') new_game = update_game_state(new_game, 'reset_game_state') return make_end_round_str(new_game, alert, 'w') elif len(alive_w) == 0: new_game = update_game_state(game_state, 'status', status='INACTIVE') new_game = update_game_state(new_game, 'reset_game_state') return make_end_round_str(new_game, alert, 'v') else: #TODO: aggregate of all night action game messages with channel id(dm) in game_state # and then send all messages at once round_end_str = make_end_round_str(game_state) + start_day_round(game_state) return round_end_str
def resolve_night_round(g, alert=None): """ Makes sure everyone has done all their roles. - if yes see if game is over. if yes set game to over. display results. if no change round to day. """ # TODO: for each player in the game, # check if completed their action for the night. alive_v = alive_for_village(g) alive_w = alive_for_werewolf(g) if len(alive_w) >= len(alive_v): new_g = update_game_state(g, 'status', status='INACTIVE') # reset game state. new_g = update_game_state(new_g, 'reset_game_state') return make_end_round_str(new_g, alert, 'w') # returns and sends message elif len(alive_w) == 0: new_g = update_game_state(g, 'status', status='INACTIVE') # reset game state. new_g = update_game_state(new_g, 'reset_game_state') return make_end_round_str(new_g, alert, 'v') # returns and sends message else: # turn it into morning and start day round. # idea: # game state has 'GAME_MESSAGES' : {'channel': <channel_id>, 'message': thing to say} # every night action adds game_message. # If all night actions have finished. Go through and send all those messages. # reset GAME_MESSAGES. round_end_str = make_end_round_str(g) + start_day_round(g) return round_end_str
def resolve_day_round(game_state, alert=None): """Reconcile all votes for the day and enter night mode.""" alive_v = status.alive_for_village(game_state) alive_w = status.alive_for_werewolf(game_state) vote_list_str = list_votes(game_state)[0] + '\n' if len(alive_w) >= len(alive_v): new_game = update_game_state(game_state, 'status', status='INACTIVE') new_game = update_game_state(new_game, 'reset_game_state') return vote_list_str + make_end_round_str(new_game, alert, 'w') elif len(alive_w) == 0: new_game = update_game_state(game_state, 'status', status='INACTIVE') new_game = update_game_state(new_game, 'reset_game_state') return vote_list_str + make_end_round_str(new_game, alert, 'v') else: return vote_list_str + make_end_round_str(game_state) + start_night_round(game_state)
def start_game(game_state, user_id, *kwargs): """Start the game and set game status to `RUNNING`.""" result, message = mod_valid_action(user_id, 'start', game_state) if not result: return message, None send_message("@channel: Game is starting...") players = status.players_in_game(game_state) num_werewolves = status.alive_for_werewolf(game_state) p1_str = "_There are *%d* players in the game._\n" % len(players) p2_str = "_There are *%d* werewolves in the game._\n" % len(num_werewolves) p3_str = "https://media.giphy.com/media/3o72FkgwrI7P4G1amI/giphy.gif" send_message(p1_str + p2_str + p3_str) game_state = update_game_state(game_state, 'status', status='RUNNING') new_game = assign_roles(game_state) message_everyone_roles(new_game) return start_day_round(new_game), None