Exemple #1
0
 def mark_word_as_guessed(self):
     self.team_scores[self.current_team_turn] = self.team_scores[
         self.current_team_turn] + 1
     self.played_words.append(self.unplayed_words.pop(0))
     socketio.emit('update_leaderboard', {
         'teams': self.teams,
         'scores': self.team_scores
     },
                   room='GameRoom_{code}'.format(code=self.code))
Exemple #2
0
 def add_words(self, player, words):
     if self.game_state == 'LOBBY':
         self.unplayed_words += words
     idx = self.players.index(player)
     self.players_ready[idx] = True
     socketio.emit('words_submitted', {
         'players': self.players,
         'ready': self.players_ready
     },
                   room='GameRoom_{code}'.format(code=self.code))
Exemple #3
0
 def start_game(self):
     print(self.game_state, self.players)
     if self.game_state == 'LOBBY' and len(
             self.players) >= Game.min_players and len(
                 self.players) % 2 == 0:
         number_of_teams = len(self.players) // 2
         self._assign_teams(number_of_teams)
         self.current_player_index = 0
         self.current_team_turn = self.team_split_players[0][1]
         self.teams = self._set_team_names()
         self.game_state = 'PLAYING'
         socketio.emit('game_started', {'code': self.code},
                       room='GameRoom_{code}'.format(code=self.code))
         return True
     return False
Exemple #4
0
    def prepare_next_player_turn(self):
        print('Preparing next player turn')
        random.shuffle(self.unplayed_words)
        self.current_player_index = (self.current_player_index + 1) % len(
            self.players)
        player, self.current_team_turn = self.team_split_players[
            self.current_player_index]
        self.players_finished = 0
        game_data = {
            'players': self.players,
            'teams': self.teams,
            'scores': self.team_scores,
            'current_player': self.current_player_index,
            'current_team': self.current_team_turn,
            'round': self.round_number
        }
        socketio.emit('turn_loaded',
                      game_data,
                      room='GameRoom_{code}'.format(code=self.code))

        return player
Exemple #5
0
 def notify_play_initiated(self):
     socketio.emit('play', {},
                   room='GameRoom_{code}'.format(code=self.code))