Пример #1
0
    def test_win_by_tsumo_and_scores_calculation(self):
        clients = [Client() for _ in range(0, 4)]
        manager = GameManager(clients)
        manager.init_game()
        manager.init_round()
        manager.riichi_sticks = 1

        winner = clients[0]
        manager.process_the_end_of_the_round(list(range(0, 14)), 0, winner,
                                             None, True)

        self.assertEqual(winner.player.scores, 26900)
        self.assertEqual(clients[1].player.scores, 24700)
        self.assertEqual(clients[2].player.scores, 24700)
        self.assertEqual(clients[3].player.scores, 24700)
Пример #2
0
    def test_win_by_ron_and_scores_calculation(self):
        clients = [Client() for _ in range(0, 4)]
        manager = GameManager(clients)
        manager.init_game()
        manager.init_round()

        winner = clients[0]
        loser = clients[1]

        # only 1000 hand
        manager.process_the_end_of_the_round(list(range(0, 14)), 0, winner,
                                             loser, False)
        self.assertEqual(winner.player.scores, 26000)
        self.assertEqual(loser.player.scores, 24000)

        winner.player.scores = 25000
        winner.player.dealer_seat = 1
        loser.player.scores = 25000
        manager.riichi_sticks = 2
        manager.honba_sticks = 2

        manager.process_the_end_of_the_round(list(range(0, 14)), 0, winner,
                                             loser, False)
        self.assertEqual(winner.player.scores, 28600)
        self.assertEqual(loser.player.scores, 23400)
        self.assertEqual(manager.riichi_sticks, 0)
        self.assertEqual(manager.honba_sticks, 0)

        winner.player.scores = 25000
        winner.player.dealer_seat = 0
        loser.player.scores = 25000
        manager.honba_sticks = 2

        # if dealer won we need to increment honba sticks
        manager.process_the_end_of_the_round(list(range(0, 14)), 0, winner,
                                             loser, False)
        self.assertEqual(winner.player.scores, 26600)
        self.assertEqual(loser.player.scores, 23400)
        self.assertEqual(manager.honba_sticks, 3)