Example #1
0
    def incorrect_answer(self):
        """
        Incorrect answer given by player.
        """
        if self.state != self.AWAIT_ANSWER:
            logging.error("Cannot answer, not in AWAIT_ANSWER")
            return

        if self.selected_clue.is_daily_double():
            self.players[self.buzzed_player].adjust_score(-self.wager)
            if self.players[self.buzzed_player].score < 0:
                self.players[self.buzzed_player].set_score(0)
        else:
            self.players[self.buzzed_player].adjust_score(-self.selected_clue.value)
        self.dump_scores()

        # Disable all lit players.
        game_buttons.reset_player_lights()
        # Disable all game buttons
        game_buttons.reset_buttons()

        logging.debug("Incorrect answer, Going to AWAIT_BUZZ state")
        self.state = self.AWAIT_BUZZ
        # Resetting timeout to number of seconds players get to buzz in.
        self.timeout_start = time.time()
        self.buzzer_lockouts = {}
        self.flash_player_score = True
Example #2
0
    def on_tick(self):
        """
        Call back associated with each tick.
        """
        game.on_tick()
        self.admin.on_tick()

        # Send update to player scores.
        self.player_score_box.update()

        # Read incoming game button presses if they exist.
        player1, player2, player3 = game_buttons.read()
        if player1:
            game.buzz(0)
        elif player2:
            game.buzz(1)
        elif player3:
            game.buzz(2)
        game_buttons.reset_buttons()
        self.update()
        return True
Example #3
0
    def on_tick(self):
        """
        Call back associated with each tick.
        """
        game.on_tick()
        self.admin.on_tick()

        # Send update to player scores.
        self.player_score_box.update()

        # Read incoming game button presses if they exist.
        player1, player2, player3 = game_buttons.read()
        if player1:
            game.buzz(0)
        elif player2:
            game.buzz(1)
        elif player3:
            game.buzz(2)
        game_buttons.reset_buttons()
        self.update()
        return True
Example #4
0
    def correct_answer(self):
        """
        Correct answer given by player.
        """
        if self.state != self.AWAIT_ANSWER:
            logging.error("Cannot answer, not in AWAIT_ANSWER")
            return

        if self.selected_clue.is_daily_double():
            self.players[self.buzzed_player].adjust_score(self.wager)
        else:
            self.players[self.buzzed_player].adjust_score(self.selected_clue.value)
        self.dump_scores()

        # Disable all lit players.
        game_buttons.reset_player_lights()
        # Disable all game buttons
        game_buttons.reset_buttons()

        logging.debug("Correct answer, Going to DISPLAY_QUESTION state")
        self.state = self.DISPLAY_QUESTION
        self.flash_player_score = True
Example #5
0
    def update(self):
        """
        Update the GUI based on the current state of the game.
        """
        if game.check_update_game_board():
            self.board_box.remove(self.game_board)
            self.game_board = GameBoard()
            self.board_box.add(self.game_board)
            if config.display_player_scores:
                self.game_board.set_size(0.9 * self.get_width(),
                                         self.get_height())
            else:
                self.game_board.set_size(self.get_width, self.get_height())
            self.game_board.lower_bottom()
        if game.check_timeout_beep():
            logging.debug("****************** BZZZZZT! ******************")
            tex = cluttergst.VideoTexture()
            tex.set_filename(config.sound_timeout)
            tex.set_playing(True)
        if game.check_flash_player_name():
            player_name = game.players[game.buzzed_player].name
            self.player_buzz_overlay.set_opacity(255)
            self.player_buzz_overlay.set_text(player_name)
            self.player_buzz_overlay.animate(clutter.EASE_IN_CUBIC, 2000,
                                             'opacity', 0)
        if game.check_flash_player_score():
            player = game.players[game.buzzed_player]
            self.player_score_overlay.set_opacity(255)
            self.player_score_overlay.set_content(player.name,
                                                  player.last_score_change)
            self.player_score_overlay.animate(clutter.EASE_IN_CUBIC, 1000,
                                              'opacity', 0)
        if game.check_flash_daily_double():
            self.daily_double_overlay.set_opacity(255)
            tex = cluttergst.VideoTexture()
            tex.set_filename(config.sound_daily_double)
            tex.set_playing(True)
        if game.check_clear_daily_double():
            self.daily_double_overlay.animate(clutter.EASE_IN_CUBIC, 1000,
                                              'opacity', 0)

        new_gui_state = self.gui_state
        if game.state == game.IDLE:
            new_gui_state = self.SHOW_GAME_BOARD
        elif game.state == game.FINAL_ROUND:
            new_gui_state = self.SHOW_FINAL_ROUND
        elif game.state == game.FINAL_ROUND_WAGER:
            new_gui_state = self.SHOW_FINAL_ROUND_CATEGORY
        elif game.state == game.FINAL_ROUND_CLUE:
            new_gui_state = self.SHOW_FINAL_ROUND_CLUE
        elif game.state == game.FINAL_ROUND_QUESTION:
            new_gui_state = self.SHOW_FINAL_ROUND_QUESTION
        elif game.state in (game.DISPLAY_CLUE, game.AWAIT_BUZZ,
                            game.AWAIT_ANSWER, game.DAILY_DOUBLE_AWAIT_WAGER,
                            game.DAILY_DOUBLE_SHOW_CLUE):
            new_gui_state = self.SHOW_CLUE
        elif game.state == game.DISPLAY_QUESTION:
            new_gui_state = self.SHOW_QUESTION
        else:
            logging.error('Invalid game state')

        if self.gui_state != new_gui_state:
            logging.debug("State %s to %s" % (self.gui_state, new_gui_state))
            if new_gui_state == self.SHOW_CLUE:
                # Reset the buttons.
                game_buttons.reset_buttons()

                # We're not displaying clue. Setup the users that are locked out.
                if game.selected_clue.get_type() == 'audio':
                    self.clue_overlay.set_audio(
                        game.selected_clue.answer['audio'])
                elif game.selected_clue.get_type() == 'image':
                    self.clue_overlay.set_image(
                        game.selected_clue.answer['image'])
                elif game.selected_clue.get_type() == 'text':
                    self.clue_overlay.set_text(game.selected_clue.answer)
                elif game.selected_clue.get_type() == 'video':
                    self.clue_overlay.set_video(
                        game.selected_clue.answer['video'])
                self.clue_overlay.set_opacity(255)
                self.clue_overlay.set_scale(0.1, 0.1)
                self.clue_overlay.animate(clutter.LINEAR, 500, 'scale-x', 1,
                                          'scale-y', 1)
            elif new_gui_state == self.SHOW_QUESTION:
                self.clue_overlay.set_text(game.selected_clue.question)
                self.clue_overlay.set_opacity(255)
                self.clue_overlay.animate(clutter.LINEAR, 500, 'scale-x', 1,
                                          'scale-y', 1)
            elif new_gui_state == self.SHOW_GAME_BOARD:
                logging.debug("Hiding clue overlay")
                self.clue_overlay.set_opacity(0)
            elif new_gui_state == self.SHOW_FINAL_ROUND:
                self.final_round_overlay.set_opacity(255)
            elif new_gui_state == self.SHOW_FINAL_ROUND_CATEGORY:
                self.final_round_overlay.set_opacity(255)
                self.final_round_overlay.set_text("Category:\n%s" %
                                                  game.final_round.category)
            elif new_gui_state == self.SHOW_FINAL_ROUND_CLUE:
                self.final_round_overlay.set_opacity(255)
                self.final_round_overlay.set_text(game.final_round.answer)
                self.final_round_overlay.play_music()
            elif new_gui_state == self.SHOW_FINAL_ROUND_QUESTION:
                self.final_round_overlay.set_opacity(255)
                self.final_round_overlay.set_text(game.final_round.question)

            self.gui_state = new_gui_state
Example #6
0
    def update(self):
        """
        Update the GUI based on the current state of the game.
        """
        if game.check_update_game_board():
            self.board_box.remove(self.game_board)
            self.game_board = GameBoard()
            self.board_box.add(self.game_board)
            if config.display_player_scores:
                self.game_board.set_size(0.9 * self.get_width(),
                                         self.get_height())
            else:
                self.game_board.set_size(self.get_width,
                                         self.get_height())
            self.game_board.lower_bottom()
        if game.check_timeout_beep():
            logging.debug("****************** BZZZZZT! ******************")
            tex = cluttergst.VideoTexture()
            tex.set_filename(config.sound_timeout)
            tex.set_playing(True)
        if game.check_flash_player_name():
            player_name = game.players[game.buzzed_player].name
            self.player_buzz_overlay.set_opacity(255)
            self.player_buzz_overlay.set_text(player_name)
            self.player_buzz_overlay.animate(clutter.EASE_IN_CUBIC,
                                             2000,
                                             'opacity', 0)
        if game.check_flash_player_score():
            player = game.players[game.buzzed_player]
            self.player_score_overlay.set_opacity(255)
            self.player_score_overlay.set_content(player.name, player.last_score_change)
            self.player_score_overlay.animate(clutter.EASE_IN_CUBIC,
                                             1000,
                                             'opacity', 0)
        if game.check_flash_daily_double():
            self.daily_double_overlay.set_opacity(255)
            tex = cluttergst.VideoTexture()
            tex.set_filename(config.sound_daily_double)
            tex.set_playing(True)
        if game.check_clear_daily_double():
            self.daily_double_overlay.animate(clutter.EASE_IN_CUBIC,
                                             1000,
                                             'opacity', 0)

        new_gui_state = self.gui_state
        if game.state == game.IDLE:
            new_gui_state = self.SHOW_GAME_BOARD
        elif game.state == game.FINAL_ROUND:
            new_gui_state = self.SHOW_FINAL_ROUND
        elif game.state == game.FINAL_ROUND_WAGER:
            new_gui_state = self.SHOW_FINAL_ROUND_CATEGORY
        elif game.state == game.FINAL_ROUND_CLUE:
            new_gui_state = self.SHOW_FINAL_ROUND_CLUE
        elif game.state == game.FINAL_ROUND_QUESTION:
            new_gui_state = self.SHOW_FINAL_ROUND_QUESTION
        elif game.state in (game.DISPLAY_CLUE,
                            game.AWAIT_BUZZ,
                            game.AWAIT_ANSWER,
                            game.DAILY_DOUBLE_AWAIT_WAGER,
                            game.DAILY_DOUBLE_SHOW_CLUE):
            new_gui_state = self.SHOW_CLUE
        elif game.state == game.DISPLAY_QUESTION:
            new_gui_state = self.SHOW_QUESTION
        else:
            logging.error('Invalid game state')

        if self.gui_state != new_gui_state:
            logging.debug("State %s to %s" % (self.gui_state, new_gui_state))
            if new_gui_state == self.SHOW_CLUE:
                # Reset the buttons.
                game_buttons.reset_buttons()

                # We're not displaying clue. Setup the users that are locked out.
                if game.selected_clue.get_type() == 'audio':
                    self.clue_overlay.set_audio(game.selected_clue.answer['audio'])
                elif game.selected_clue.get_type() == 'image':
                    self.clue_overlay.set_image(game.selected_clue.answer['image'])
                elif game.selected_clue.get_type() == 'text':
                    self.clue_overlay.set_text(game.selected_clue.answer)
                elif game.selected_clue.get_type() == 'video':
                    self.clue_overlay.set_video(game.selected_clue.answer['video'])
                self.clue_overlay.set_opacity(255)
                self.clue_overlay.set_scale(0.1, 0.1)
                self.clue_overlay.animate(clutter.LINEAR,
                                          500,
                                          'scale-x', 1,
                                          'scale-y', 1)
            elif new_gui_state == self.SHOW_QUESTION:
                self.clue_overlay.set_text(game.selected_clue.question)
                self.clue_overlay.set_opacity(255)
                self.clue_overlay.animate(clutter.LINEAR,
                                          500,
                                          'scale-x', 1,
                                          'scale-y', 1)
            elif new_gui_state == self.SHOW_GAME_BOARD:
                logging.debug("Hiding clue overlay")
                self.clue_overlay.set_opacity(0)
            elif new_gui_state == self.SHOW_FINAL_ROUND:
                self.final_round_overlay.set_opacity(255)
            elif new_gui_state == self.SHOW_FINAL_ROUND_CATEGORY:
                self.final_round_overlay.set_opacity(255)
                self.final_round_overlay.set_text("Category:\n%s" % game.final_round.category)
            elif new_gui_state == self.SHOW_FINAL_ROUND_CLUE:
                self.final_round_overlay.set_opacity(255)
                self.final_round_overlay.set_text(game.final_round.answer)
                self.final_round_overlay.play_music()
            elif new_gui_state == self.SHOW_FINAL_ROUND_QUESTION:
                self.final_round_overlay.set_opacity(255)
                self.final_round_overlay.set_text(game.final_round.question)

            self.gui_state = new_gui_state