Example #1
0
    def _run_single_tribe_council(self, winning_teams: List[Team], losing_teams: List[Team],
                                  gamedb: Database, engine: Engine):

        # announce winner and tribal council for losing teams
        gamedb.clear_votes()
        engine.add_event(events.NotifySingleTribeCouncilEvent(
            game_id=self._game_id, game_options=self._options,
            winning_teams=winning_teams, losing_teams=losing_teams))
        tribal_council_start_timestamp = _unixtime()

        # wait for votes
        while (((_unixtime() - tribal_council_start_timestamp)
                < self._options.single_tribe_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
        for team in losing_teams:
            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))
            else:
                log_message("For some reason no one got voted out...")
                log_message("Players = {}.".format(
                    pprint.pformat(gamedb.list_players(from_team=team))))

        # notify all players of what happened at tribal council
        engine.add_event(
            events.NotifyTribalCouncilCompletionEvent(game_id=self._game_id, game_options=self._options))
Example #2
0
    def test_notify_single_tribe_council_event_msg(self):
        event = events.NotifySingleTribeCouncilEvent(
            game_id=_TEST_GAME_ID,
            game_options=self.game_options,
            winning_teams=[
                _gamedb.team_from_id(
                    id="42a73a78-170e-45ed-a3eb-402fa844afa1")
            ],
            losing_teams=[
                _gamedb.team_from_id(
                    id="bbea5ef1-8688-4831-9929-07e3cd7a3f1b")
            ]
        )

        self.assertEqual(
            _event_messages_as_json(event.messages(gamedb=_gamedb)),
            json.dumps(
                [
                    {
                        "class": "SMSEventMessage",
                        "content": ("\nVIR-US: Your team has lost today's challenge and you must vote "
                                    "a player off of your team!\nReply by 9PM 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/@gary\n\nB: www.tiktok.com/@donna\n\nC: "
                                    "www.tiktok.com/@kirk\n\nD: www.tiktok.com/@neil\n\nE: www.tiktok.com/@frank\n\n\n\n"),
                        "recipient_phone_numbers": [
                            "751-005-3935",
                            "555-259-3255",
                            "877-102-2965",
                            "994-138-5472",
                            "461-328-0686"
                        ]
                    },
                    {
                        "class": "SMSEventMessage",
                        "content": ("\nVIR-US: Congratulations! Your team is a winner of today's "
                                    "challenge and none of your team members will be eliminated. Other teams "
                                    "will be voting players out of the game tonight at 9PM EDT.\n\nNext challenge "
                                    "begins tomorrow at 12PM EDT!\"\n"),
                        "recipient_phone_numbers": [
                            "331-046-5651",
                            "835-161-1468",
                            "191-221-0517",
                            "114-458-3014",
                            "245-228-6657"
                        ]
                    }
                ]
            )
        )
Example #3
0
    def _run_single_tribe_council(self, winning_teams: List[Team],
                                  losing_teams: List[Team], gamedb: Database,
                                  engine: Engine):
        self._wait_for_tribal_council_start_time()
        # keep top K teams

        # announce winner and tribal council for losing teams
        gamedb.clear_votes()
        engine.add_event(
            events.NotifySingleTribeCouncilEvent(game_id=self._game_id,
                                                 game_options=self._options,
                                                 winning_teams=winning_teams,
                                                 losing_teams=losing_teams))
        self._wait_for_tribal_council_end_time()

        # count votes
        for team in losing_teams:
            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))
            else:
                log_message(message="For some reason no one got voted out...",
                            game_id=self._game_id)
                log_message(message="Players = {}.".format(
                    pprint.pformat(gamedb.list_players(from_team=team))),
                            game_id=self._game_id)

        # notify all players of what happened at tribal council
        engine.add_event(
            events.NotifyTribalCouncilCompletionEvent(
                game_id=self._game_id, game_options=self._options))
Example #4
0
                               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,
                                  game_options=_TEST_GAME_OPTIONS,
                                  player=_TEST_PLAYER1),
 events.NotifyTribalCouncilCompletionEvent(
     game_id=_TEST_GAME_ID,
     game_options=_TEST_GAME_OPTIONS,