예제 #1
0
 def notify_disable_votes(self, *player_ids):
     logger.debug(f"Disabling votes for users ids {player_ids}")
     for player_id in player_ids:
         rs.game.disable_guesser(player_id)
         emit_in_room(
             "disable_vote",
             room=rs.game_state.socketio_id_from_user_id[player_id])
예제 #2
0
 def notify_team_change(self):
     logger.debug(f"Sending teams={room_session.teams}")
     # Send event in room about new teams (or changes only ?)
     emit_in_room(
         "teams_changed",
         {i: t.to_json()
          for i, t in enumerate(room_session.teams)},
         broadcast=True)
     emit_in_room("toggle_start", self._are_teams_ready(), broadcast=True)
예제 #3
0
    def game_over(self, winners):
        logger.info("GAME OVER")
        self.notify_change_title(
            f"L'équipe {rs.game.team_names[winners]} a gagné !")

        emit_in_room(
            'change_controls',
            render_template("_gameover_controls.html", room_id=get_room_id()))
        del rs.teams  # Remove teams so they appear empty when redirected to room
        # Get remaining cells values
        left_cells = self._get_remaining_cells()
        for cell in left_cells:
            value = rs.game.answers[parse_cell_code(cell)]
            self.notify_cell_voted(cell, value)
            time.sleep(1)
예제 #4
0
 def on_start_game(self):
     # Check that teams are ok
     if self._are_teams_ready():
         # Emit URL redirection
         logger.info("Starting game !")
         room_session.started = True
         url = request.environ["HTTP_REFERER"]  # Access to request context
         grid_url = url.replace("room", "grid")
         # Create Game instance
         game = Game([team.get_ids_list() for team in room_session.teams])
         room_session.game = game  # Could remove ?
         game_state = GameState(game, room_session.teams)
         room_session.game_state = game_state
         emit_in_room("url_redirection", {"url": grid_url}, broadcast=True)
     else:
         logger.warning("Teams not ready yet")
예제 #5
0
 def on_chat_message(self, msg):
     logger.debug("Chat : " + msg)
     response = session.get("pseudo") + " : " + parse_for_emojis(msg)
     rs.game_state.chat_history.append(response)
     emit_in_room("chat_msg", response)
예제 #6
0
 def notify_new_event(self, event_msg):
     logger.debug(f"Sending new event {event_msg}")
     rs.game_state.events_history.append(event_msg)
     emit_in_room("add_event", event_msg)
예제 #7
0
 def notify_update_current_players(self):
     logger.debug(f"Updating current players: {rs.game.current_players}")
     emit_in_room("change_current_player", rs.game.current_players)
예제 #8
0
 def notify_enable_controls(self):
     emit_in_room(
         "enable_controls",
         room=rs.game_state.socketio_id_from_user_id[rs.game.current_spy])
예제 #9
0
 def notify_change_title(self, new_title, color="white"):
     rs.game_title = new_title
     rs.title_color = color
     emit_in_room('change_title', {"title": new_title, "color": color})
예제 #10
0
 def notify_cell_voted(self, cell, value):
     vote = {"cell": cell, "value": str(value)}
     emit_in_room("vote_done", vote)
예제 #11
0
 def notify_update_cell_votes(self):
     votes_counts = rs.game.get_votes_counts()
     logger.debug(f"Votes counts: {votes_counts}")
     if len(votes_counts
            ):  # Check that contains actual values and not just pass
         emit_in_room("update_votes", votes_counts)