def test_dont_call_riichi_with_tanki_wait(self): table = Table() table.count_of_remaining_tiles = 60 player = table.player player.scores = 25000 tiles = self._string_to_136_array(sou='123456', pin='123456', man='3') player.init_hand(tiles) player.draw_tile(self._string_to_136_tile(man='4')) player.discard_tile() self.assertEqual(player.can_call_riichi(), False) table = Table() table.count_of_remaining_tiles = 60 player = table.player player.scores = 25000 tiles = self._string_to_136_array(sou='1133557799', pin='113') tile = self._string_to_136_tile(pin='6') player.init_hand(tiles) player.draw_tile(tile) player.discard_tile() # for chitoitsu it is ok to have a pair wait self.assertEqual(player.can_call_riichi(), True)
def test_call_riichi_and_penchan_wait(self): table = Table() table.count_of_remaining_tiles = 60 player = table.player player.scores = 25000 tiles = self._string_to_136_array(sou='11223', pin='234567', man='66') tile = self._string_to_136_tile(man='9') player.init_hand(tiles) player.draw_tile(tile) player.discard_tile() self.assertEqual(player.can_call_riichi(), True)
def test_call_riichi_with_bad_wait_against_other_player_riichi(self): table = Table() table.count_of_remaining_tiles = 60 table.player.scores = 25000 tiles = self._string_to_136_array(sou='11223', pin='234678', man='55') table.player.init_hand(tiles) table.player.draw_tile(self._string_to_136_tile(man='9')) table.add_called_riichi(3) discard = table.player.discard_tile() self.assertEqual(self._to_string([discard]), '9m') self.assertEqual(table.player.ai.in_defence, True) self.assertEqual(table.player.can_call_riichi(), False)
def test_discard_not_effective_tiles_first(self): table = Table() player = table.player player.scores = 25000 table.count_of_remaining_tiles = 100 tiles = self._string_to_136_array(man='33', pin='12788999', sou='5', honors='23') player.init_hand(tiles) player.draw_tile(self._string_to_136_tile(honors='6')) tile_to_discard = player.discard_tile() self.assertEqual(self._to_string([tile_to_discard]), '5s')
def test_riichi_and_tiles_from_another_suit_in_the_hand(self): table = Table() player = table.player player.scores = 25000 table.count_of_remaining_tiles = 100 tiles = self._string_to_136_array(man='33345678', pin='22', honors='155') player.init_hand(tiles) player.draw_tile(self._string_to_136_tile(man='9')) tile_to_discard = player.discard_tile() # we don't need to go for honitsu here # we already in tempai self.assertEqual(self._to_string([tile_to_discard]), '1z')
def test_dont_discard_safe_tiles_when_call_riichi(self): table = Table() table.count_of_remaining_tiles = 70 table.player.scores = 2000 tiles = self._string_to_136_array(sou='12356789', pin='22678') table.player.init_hand(tiles) table.player.draw_tile(self._string_to_136_tile(honors='1')) table.player.discard_tile() table.player.draw_tile(self._string_to_136_tile(honors='1')) table.add_discarded_tile(1, self._string_to_136_tile(sou='1'), False) table.add_called_riichi(1) result = table.player.discard_tile() self.assertEqual(table.player.can_call_riichi(), True) self.assertEqual(self._to_string([result]), '1z')
def test_closed_kan_and_riichi(self): table = Table() table.count_of_remaining_tiles = 60 player = table.player player.scores = 25000 kan_tiles = self._string_to_136_array(pin='7777') tiles = self._string_to_136_array(pin='568', sou='1235788') + kan_tiles[:3] player.init_hand(tiles) # +3 to avoid tile duplication of 7 pin tile = kan_tiles[3] player.draw_tile(tile) kan_type = player.can_call_kan(tile, False) self.assertEqual(kan_type, Meld.KAN) meld = Meld() meld.type = Meld.KAN meld.tiles = kan_tiles meld.called_tile = tile meld.who = 0 meld.from_who = 0 meld.opened = False # replacement from the dead wall player.draw_tile(self._string_to_136_tile(pin='4')) table.add_called_meld(meld.who, meld) discard = player.discard_tile() self.assertEqual(self._to_string([discard]), '8p') self.assertEqual(player.can_call_riichi(), True) # with closed kan we can't call riichi player.melds[0].opened = True self.assertEqual(player.can_call_riichi(), False)
def test_discard_not_needed_winds(self): table = Table() player = table.player player.scores = 25000 table.count_of_remaining_tiles = 100 tiles = self._string_to_136_array(man='24', pin='4', sou='12344668', honors='36') player.init_hand(tiles) player.draw_tile(self._string_to_136_tile(sou='5')) table.add_discarded_tile(1, self._string_to_136_tile(honors='3'), False) table.add_discarded_tile(1, self._string_to_136_tile(honors='3'), False) table.add_discarded_tile(1, self._string_to_136_tile(honors='3'), False) tile_to_discard = player.discard_tile() # west was discarded three times, we don't need it self.assertEqual(self._to_string([tile_to_discard]), '3z')