Esempio n. 1
0
    def _run_single_team_council(self, team: Team, losing_players: List[Player], gamedb: Database, engine: Engine):
        # announce winner and tribal council for losing teams
        gamedb.clear_votes()

        winning_player = [player for player in gamedb.list_players(
            from_team=team) if player not in losing_players][0]
        engine.add_event(events.NotifySingleTeamCouncilEvent(game_id=self._game_id, game_options=self._options,
                                                             winning_player=winning_player, losing_players=losing_players))
        tribal_council_start_timestamp = _unixtime()

        # wait for votes
        while (((_unixtime() - tribal_council_start_timestamp)
                < self._options.single_team_council_time_sec) and not self._stop.is_set()):
            log_message("Waiting for tribal council to end.")
            time.sleep(self._options.game_wait_sleep_interval_sec)

        # count votes
        voted_out_player = self._get_voted_out_player(team=team, gamedb=gamedb)
        if voted_out_player:
            gamedb.deactivate_player(player=voted_out_player)
            log_message("Deactivated player {}.".format(voted_out_player))
            engine.add_event(events.NotifyPlayerVotedOutEvent(game_id=self._game_id, game_options=self._options,
                                                              player=voted_out_player))

        # notify all players of what happened at tribal council
        engine.add_event(
            events.NotifyTribalCouncilCompletionEvent(game_id=self._game_id, game_options=self._options))
Esempio n. 2
0
    def _run_single_team_council(self, team: Team,
                                 losing_players: List[Player],
                                 gamedb: Database, engine: Engine):
        self._wait_for_tribal_council_start_time()

        # announce winner and tribal council for losing teams
        gamedb.clear_votes()

        winning_players = [
            player for player in gamedb.list_players(from_team=team)
            if player not in losing_players
        ]
        if len(winning_players) > 0:
            winning_player = winning_players[0]
        else:
            engine.stop()
            raise GameError(
                "Unable to determine a winning player for the challenge. Have any entries been submitted?"
            )

        engine.add_event(
            events.NotifySingleTeamCouncilEvent(game_id=self._game_id,
                                                game_options=self._options,
                                                winning_player=winning_player,
                                                losing_players=losing_players))
        self._wait_for_tribal_council_end_time()

        # count votes
        voted_out_player = self._get_voted_out_player(team=team, gamedb=gamedb)
        if voted_out_player:
            gamedb.deactivate_player(player=voted_out_player)
            log_message(
                message="Deactivated player {}.".format(voted_out_player),
                game_id=self._game_id)
            engine.add_event(
                events.NotifyPlayerVotedOutEvent(game_id=self._game_id,
                                                 game_options=self._options,
                                                 player=voted_out_player))

        # notify all players of what happened at tribal council
        engine.add_event(
            events.NotifyTribalCouncilCompletionEvent(
                game_id=self._game_id, game_options=self._options))
Esempio n. 3
0
 events.NotifyTribalChallengeEvent(game_id=_TEST_GAME_ID,
                                   game_options=_TEST_GAME_OPTIONS,
                                   challenge=_TEST_CHALLENGE),
 events.NotifyPlayerScoreEvent(game_id=_TEST_GAME_ID,
                               game_options=_TEST_GAME_OPTIONS,
                               player=_TEST_PLAYER1,
                               challenge=_TEST_CHALLENGE,
                               entry=_TEST_ENTRY,
                               points=100),
 events.NotifyTeamReassignmentEvent(game_id=_TEST_GAME_ID,
                                    game_options=_TEST_GAME_OPTIONS,
                                    player=_TEST_PLAYER1,
                                    team=_TEST_TEAM1),
 events.NotifySingleTeamCouncilEvent(
     game_id=_TEST_GAME_ID,
     game_options=_TEST_GAME_OPTIONS,
     winning_player=_TEST_PLAYER1,
     losing_players=[_TEST_PLAYER1, _TEST_PLAYER2]),
 events.NotifySingleTribeCouncilEvent(game_id=_TEST_GAME_ID,
                                      game_options=_TEST_GAME_OPTIONS,
                                      winning_teams=[_TEST_TEAM1],
                                      losing_teams=[_TEST_TEAM2]),
 events.NotifyMultiTribeCouncilEvent(game_id=_TEST_GAME_ID,
                                     game_options=_TEST_GAME_OPTIONS,
                                     winning_tribe=_TEST_TRIBE1,
                                     losing_tribe=_TEST_TRIBE2),
 events.NotifyFinalTribalCouncilEvent(
     game_id=_TEST_GAME_ID,
     game_options=_TEST_GAME_OPTIONS,
     finalists=[_TEST_PLAYER1, _TEST_PLAYER2]),
 events.NotifyPlayerVotedOutEvent(game_id=_TEST_GAME_ID,
Esempio n. 4
0
    def test_notify_single_team_council_event_msg(self):
        losing_players = [p for p in _gamedb.list_players(
            from_team=_gamedb.team_from_id(id="bab66d57-74ad-4c08-b823-65946b160435")) if
            p.id != "5d3deb3a-eced-4cfb-b1b4-cb3aeb718119"]
        event = events.NotifySingleTeamCouncilEvent(
            game_id=_TEST_GAME_ID,
            game_options=self.game_options,
            winning_player=_gamedb.player_from_id(
                id="5d3deb3a-eced-4cfb-b1b4-cb3aeb718119"),
            losing_players=losing_players
        )

        self.assertEqual(
            _event_messages_as_json(event.messages(gamedb=_gamedb)),
            json.dumps(
                [
                    {
                        "class": "SMSEventMessage",
                        "content": ("\nVIR-US: bruce (www.tiktok.com/@bruce) has won today's challenge"
                                    " and cannot be voted out! There are now 10 players remaining and you must vote"
                                    " a player out of the game!\nReply by 6PM EDT with the letter of the player you're"
                                    " voting OUT. If you do not reply, your vote will count against you.\n\nA: "
                                    "www.tiktok.com/@donald\n\nB: www.tiktok.com/@denise\n\nC: www.tiktok.com/@stacy\n\n\n\n"),
                        "recipient_phone_numbers": "388-685-3212"
                    },
                    {
                        "class": "SMSEventMessage",
                        "content": ("\nVIR-US: bruce (www.tiktok.com/@bruce) has won today's challenge "
                                    "and cannot be voted out! There are now 10 players remaining and you must vote "
                                    "a player out of the game!\nReply by 6PM EDT with the letter of the player you're "
                                    "voting OUT. If you do not reply, your vote will count against you.\n\nA: "
                                    "www.tiktok.com/@elizabeth\n\nB: www.tiktok.com/@denise\n\nC: www.tiktok.com/@stacy\n\n\n\n"),
                        "recipient_phone_numbers": "802-722-8425"
                    },
                    {
                        "class": "SMSEventMessage",
                        "content": ("\nVIR-US: bruce (www.tiktok.com/@bruce) has won today's challenge"
                                    " and cannot be voted out! There are now 10 players remaining and you must vote "
                                    "a player out of the game!\nReply by 6PM EDT with the letter of the player you're "
                                    "voting OUT. If you do not reply, your vote will count against you.\n\nA: "
                                    "www.tiktok.com/@elizabeth\n\nB: www.tiktok.com/@donald\n\nC: www.tiktok.com/@stacy\n\n\n\n"),
                        "recipient_phone_numbers": "704-425-0095"
                    },
                    {
                        "class": "SMSEventMessage",
                        "content": ("\nVIR-US: bruce (www.tiktok.com/@bruce) has won today's challenge "
                                    "and cannot be voted out! There are now 10 players remaining and you must vote a "
                                    "player out of the game!\nReply by 6PM EDT with the letter of the player you're voting "
                                    "OUT. If you do not reply, your vote will count against you.\n\nA: "
                                    "www.tiktok.com/@elizabeth\n\nB: www.tiktok.com/@donald\n\nC: www.tiktok.com/@denise\n\n\n\n"),
                        "recipient_phone_numbers": "514-721-1531"
                    },
                    {
                        "class": "SMSEventMessage",
                        "content": ("\nVIR-US: Congratulations you have won today's challenge and can not be voted "
                                    "out!\nThere are now 10 players remaining and you must vote a player out of the game.\n"
                                    "Reply by 6PM EDT with the letter of the player you're voting OUT.\n\nA: "
                                    "www.tiktok.com/@elizabeth\n\nB: www.tiktok.com/@donald\n\nC: "
                                    "www.tiktok.com/@denise\n\nD: www.tiktok.com/@stacy\n\n\n\n"),
                        "recipient_phone_numbers": "436-038-5365"
                    }
                ]
            )
        )