def peek(user_id, action, game_state, target_name): user_map = UserMap() role_map = { 's': "the Seer", 'w': "a wolf", 'v': "a vanilla villa", 'a': "the Angel" } target_id = user_map.get(name=target_name) user_name = user_map.get(user_id) if not status.player_in_game(game_state, user_id): return False, RESPONSE['noop'] if not status.is_player_alive(game_state, user_id): return False, RESPONSE['dead_villa'] #if status.get_current_round(game_state) != 'night': # return False, RESPONSE['noop'] if status.player_role(game_state, user_id) != 's': return False, RESPONSE['not_seer'] target_role = status.player_role(game_state, target_id) target_str = RESPONSE['peek'] return True, target_name + "'s role is " + role_map[target_role]
def make_end_round_str(g, alert=None, game_over=None): """ g - game state alert - string of any alerts game_over - string of role that won, if game is over. """ round_end_str = '' if alert: round_end_str += alert if game_over: if game_over == 'w': # werewolves won round_end_str += "\n Game Over. Werewolves wins.\n" elif game_over == 'v': # village wins round_end_str += "\n Game Over. Village wins.\n" # Display list of players and their roles round_end_str += '\n'.join( [u.get(user_id=p_id) + "%s | *%s*." % (u.get(user_id=p_id), player_role(g, p_id)) for p_id in players_in_game(g)]) return round_end_str
def message_everyone_roles(g): """ for every player in game. DM them their roles. """ u = UserMap() # player_role(g, player_id) all_alive = [(u.get(user_id=p_id, DM=True), player_role(g, p_id)) for p_id in players_in_game(g) if is_player_alive(g, p_id)] print(all_alive) for im, role in all_alive: if role=='v': nice=" Plain Villager" elif role=='w': nice=" Werewolf. *Awoooo!*" elif role=='s': nice=" Seer." elif role=='b': nice=" Bodyguard." send_message(nice, channel=im)
def kill(): # 1) Make sure player who made the command # is in the game if not player_in_game(g,user_id): return False, 'Not allowed.' # 1a) is a werewolf # Only werewolf can use kill. (for now) if player_role(g, user_id) != 'w': return False, 'Not allowed.' # 1c) is alive if not is_player_alive(g, user_id): return False, 'Dead wolves can not kill.' # 2) Kill command only valid at night. if get_current_round(g) != 'night': return False, 'Not allowed.' # 3) Target must be in game. if not player_in_game(g, target_id): return False, 'Not allowed.' # 4) Target must be alive. if not is_player_alive(g, target_id): return False, 'Not allowed.' return True, '' # no message
def player_role_string(player_id, game_state): return user_map.get(user_id=player_id) + "%s | %s" % (user_map.get(user_id=player_id), status.player_role(game_state, player_id))
def _player_tuple(player_id, game_state): return (user_map.get(user_id=player_id, DM=True), status.player_role(game_state, player_id))