Exemplo n.º 1
0
 def run_game(player_id_map, red_team_ids, blue_team_ids, red_score,
              blue_score):
     minqlx_fake.start_game(PLAYER_ID_MAP, red_team_ids, blue_team_ids,
                            red_score, blue_score)
     TestTimba.fake_time += 1000
     minqlx_fake.frame()
     minqlx_fake.end_game()
Exemplo n.º 2
0
 def test_lagparatodos_reset(self, m):
     lpt = lagparatodos.lagparatodos()
     player = PLAYER_ID_MAP[10]
     minqlx_fake.start_game(PLAYER_ID_MAP, [10, 11], [12, 13], 7, 15)
     minqlx_fake.call_command('!lagparatodos remove', player)
     self.assertMessages('LagParaTodos: Rules removed. Back to normal.')
     self.assertSavedConfig(None, m)
Exemplo n.º 3
0
 def test_lagparatodos_no_command(self):
     lpt = lagparatodos.lagparatodos()
     player = PLAYER_ID_MAP[10]
     minqlx_fake.start_game(PLAYER_ID_MAP, [10, 11], [12, 13], 7, 15)
     minqlx_fake.call_command('!lagparatodos', player)
     self.assertEqual(['Format: !lagparatodos <set|remove>'],
                      player.messages)
Exemplo n.º 4
0
    def test_handles_game_start(self):
        tim = timba.timba()
        self.assertEqual({}, tim.get_current_bets())

        minqlx_fake.call_command('!timba blue 1000', PLAYER_ID_MAP[10])
        self.assertEqual({}, tim.get_current_bets())

        minqlx_fake.countdown_game()
        minqlx_fake.call_command('!timba blue 1000', PLAYER_ID_MAP[10])
        minqlx_fake.call_command('!timba red 123', PLAYER_ID_MAP[11])
        expected_bets = {10: make_bet('blue', 1000), 11: make_bet('red', 123)}
        self.assertEqual(expected_bets, tim.get_current_bets())
        minqlx_fake.start_game(PLAYER_ID_MAP, [10, 11], [12, 13], 7, 15)
        TestTimba.fake_time += 1000
        minqlx_fake.frame()
        self.assertInMessages(
            'Betting is now closed. The pot is 1123 credits.')

        # should not be allowed
        minqlx_fake.call_command('!timba red 200', PLAYER_ID_MAP[10])
        self.assertEqual(expected_bets, tim.get_current_bets())
        minqlx_fake.end_game()

        # should not be allowed
        minqlx_fake.call_command('!timba red 200', PLAYER_ID_MAP[10])
        self.assertEqual({}, tim.get_current_bets())
Exemplo n.º 5
0
 def test_no_bets(self):
     tim = timba.timba()
     minqlx_fake.countdown_game()
     # blue won
     minqlx_fake.Plugin.reset_log()
     self.assertEqual({}, tim.get_current_bets())
     minqlx_fake.start_game(PLAYER_ID_MAP, [10, 11], [12, 13], 7, 15)
     TestTimba.fake_time += 1000
     minqlx_fake.frame()
     self.assertMessages('Betting is now closed. There were no bets.')
     self.assertEqual({}, tim.get_current_bets())
Exemplo n.º 6
0
    def test_handles_game_start_new_player(self):
        fun = funes.funes()
        # id 90 isn't in data
        minqlx_fake.start_game(PLAYER_ID_MAP, [11, 13, 14], [12, 10, 90], 7,
                               15)

        msgs = minqlx_fake.Plugin.messages
        # session, historic
        self.assertInMessages(
            'fundi, p-lu-k, renga 0 v 0 cthulhu, mandiok, toro')
        self.assertInMessages(
            'fundi, p-lu-k, renga 0 v 0 cthulhu, mandiok, toro')
Exemplo n.º 7
0
 def test_lagparatodos_set(self, m):
     lpt = lagparatodos.lagparatodos()
     player = PLAYER_ID_MAP[10]
     minqlx_fake.start_game(PLAYER_ID_MAP, [10, 11], [12, 13], 7, 15)
     minqlx_fake.call_command('!lagparatodos set', player)
     # self.assertMessages(
     #     'LagParaTodos: Rules set. Max ping is 1000ms. Enjoy your lag.')
     self.assertSavedConfig(['1.2.3.7:1000', '1.2.3.5:990', '1.2.3.4:334'],
                            m)
     self.assertInMessages('          zoth-ommog: 1000ms added')
     self.assertInMessages('      shub niggurath:  990ms added')
     self.assertInMessages('             cthulhu:  334ms added')
     self.assertInMessages('Rules set. Enjoy your lag! >:[')
Exemplo n.º 8
0
    def test_handles_game_start(self):
        fun = funes.funes()
        minqlx_fake.start_game(PLAYER_ID_MAP, [11, 13, 14], [12, 10, 15], 7,
                               15)

        # session, historic
        self.assertInMessages('fundi, p-lu-k, renga 1 v 2 coco, mandiok, toro')
        self.assertInMessages('                     1 v 3 (since 2018w10)')

        # flip red and blue teams:
        minqlx_fake.Plugin.reset_log()
        minqlx_fake.start_game(PLAYER_ID_MAP, [12, 10, 15], [11, 13, 14], 15,
                               1)

        msgs = minqlx_fake.Plugin.messages
        # session, historic
        self.assertInMessages('coco, mandiok, toro 2 v 1 fundi, p-lu-k, renga')
        self.assertInMessages('                    3 v 1 (since 2018w10)')
Exemplo n.º 9
0
    def test_handles_game_end_player_left(self, m):
        fun = funes.funes()
        red_ids = [10, 11, 12]
        blue_ids = [15, 13, 14]
        teams = (red_ids, blue_ids)
        self.assertEqual([1, 0], fun.get_teams_history('ad', teams))
        self.assertEqual([5, 2],
                         fun.get_teams_history('ad', teams, aggregate=True))

        # start game with 2v2 players
        minqlx_fake.start_game(PLAYER_ID_MAP, red_ids, blue_ids, 7, 15)
        current_teams = fun.teams()
        self.assertEqual(3, len(fun.teams()['red']))
        self.assertEqual(3, len(fun.teams()['blue']))

        # one player leaves.
        current_teams['red'].pop()
        minqlx_fake.Plugin.set_players_by_team(current_teams)

        # blue won. should update according to starting teams.
        minqlx_fake.end_game()
        self.assertEqual([1, 1], fun.get_teams_history('ad', teams))
        self.assertEqual([5, 3],
                         fun.get_teams_history('ad', teams, aggregate=True))