Пример #1
0
    def _run_multi_tribe_council(self, winning_tribe: Tribe,
                                 losing_tribe: Tribe, gamedb: Database,
                                 engine: Engine):
        self._wait_for_tribal_council_start_time()

        # fraction of teams in losing tribe must vote
        non_immune_teams = list()
        for team in gamedb.stream_teams(from_tribe=losing_tribe):
            log_message(message="Found losing team {}.".format(team),
                        game_id=self._game_id)
            immunity_granted = random.random(
            ) < self._options.multi_tribe_team_immunity_likelihood
            if not immunity_granted:
                non_immune_teams.append(team)
            else:
                engine.add_event(
                    events.NotifyImmunityAwardedEvent(
                        game_id=self._game_id,
                        game_options=self._options,
                        team=team))

        # announce winner and tribal council for losing tribe
        gamedb.clear_votes()
        engine.add_event(
            events.NotifyMultiTribeCouncilEvent(game_id=self._game_id,
                                                game_options=self._options,
                                                winning_tribe=winning_tribe,
                                                losing_tribe=losing_tribe))
        self._wait_for_tribal_council_end_time()

        # count votes
        for team in non_immune_teams:
            log_message(
                message="Counting votes for non-immune team {}.".format(team),
                game_id=self._game_id)
            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))
Пример #2
0
    def _run_multi_tribe_council(self, winning_tribe: Tribe, losing_tribe: Tribe, gamedb: Database, engine: Engine):
        non_immune_teams = list()

        for team in gamedb.stream_teams(from_tribe=losing_tribe):
            log_message("Found losing team {}.".format(team))
            immunity_granted = random.random() < self._options.multi_tribe_team_immunity_likelihood
            if not immunity_granted:
                non_immune_teams.append(team)
            else:
                engine.add_event(events.NotifyImmunityAwardedEvent(
                    game_id=self._game_id, game_options=self._options, team=team))

        # announce winner and tribal council for losing tribe
        tribal_council_start_timestamp = _unixtime()
        gamedb.clear_votes()
        engine.add_event(events.NotifyMultiTribeCouncilEvent(game_id=self._game_id, game_options=self._options,
                                                             winning_tribe=winning_tribe, losing_tribe=losing_tribe))

        # wait for votes
        while (((_unixtime() - tribal_council_start_timestamp)
                < self._options.multi_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 non_immune_teams:
            log_message("Counting votes for non-immune team {}.".format(team))
            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))
Пример #3
0
                               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,
 ),
 events.NotifyWinnerAnnouncementEvent(game_id=_TEST_GAME_ID,
                                      game_options=_TEST_GAME_OPTIONS,
                                      winner=_TEST_PLAYER2),
Пример #4
0
    def test_notify_multi_tribe_council_event_msg(self):
        event = events.NotifyMultiTribeCouncilEvent(
            game_id=_TEST_GAME_ID,
            game_options=self.game_options,
            winning_tribe=_gamedb.tribe_from_id(
                id="59939070-34e1-4bfd-9a92-5415e2fb4277"),
            losing_tribe=_gamedb.tribe_from_id(
                id="c4630003-d361-4ff7-a03f-ab6f92afbb81")
        )

        self.assertEqual(
            _event_messages_as_json(event.messages(gamedb=_gamedb)),
            json.dumps(
                [
                    {
                        "class": "SMSEventMessage",
                        "content": ("\nVIR-US: Your team's tribe tribe/ASHER 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/@charles\n\nB: www.tiktok.com/@juanita\n\nC: "
                                    "www.tiktok.com/@donna\n\nD: www.tiktok.com/@henry\n\nE: www.tiktok.com/@corina\n\n\n\n"),
                        "recipient_phone_numbers": [
                            "331-046-5651",
                            "835-161-1468",
                            "191-221-0517",
                            "114-458-3014",
                            "245-228-6657"
                        ]
                    },
                    {
                        "class": "SMSEventMessage",
                        "content": ("\nVIR-US: Your team's tribe tribe/ASHER 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 tribe tribe/MANESSEH has won today's "
                                    "challenge and everyone is safe. tribe/ASHER will be voting players out of the "
                                    "game TONIGHT at 9PM EDT.\n\nNext challenge begins tomorrow at 12PM EDT!\"\n"),
                        "recipient_phone_numbers": [
                            "962-582-3407",
                            "142-175-7280",
                            "312-441-3246",
                            "917-511-9963",
                            "381-505-3014",
                            "388-685-3212",
                            "802-722-8425",
                            "704-425-0095",
                            "436-038-5365",
                            "514-721-1531"
                        ]
                    }
                ]
            )
        )