Exemple #1
0
 def call_meld(self, type, who, from_who, opened, tiles, called_tile):
     meld = Meld()
     meld.type = type
     meld.who = who
     meld.from_who = from_who
     meld.opened = opened
     meld.tiles = tiles
     meld.called_tile = called_tile
     return meld
Exemple #2
0
    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.should_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)
Exemple #3
0
    def test_call_meld_kan_from_player(self):
        client = Client()

        client.table.init_round(0, 0, 0, 0, 0, [0, 0, 0, 0])
        self.assertEqual(client.table.count_of_remaining_tiles, 70)

        meld = Meld()
        client.table.add_called_meld(0, meld)

        self.assertEqual(len(client.player.melds), 1)
        self.assertEqual(client.table.count_of_remaining_tiles, 71)

        client.player.tiles = [0]
        meld = Meld()
        meld.type = Meld.KAN
        # closed kan
        meld.tiles = [0, 1, 2, 3]
        meld.called_tile = 0
        meld.opened = True
        client.table.add_called_meld(0, meld)

        self.assertEqual(len(client.player.melds), 2)
        # kan was called from another player, total number of remaining tiles stays the same
        self.assertEqual(client.table.count_of_remaining_tiles, 71)
Exemple #4
0
    def test_call_meld_closed_kan(self):
        client = Client()

        client.table.init_round(0, 0, 0, 0, 0, [0, 0, 0, 0])
        self.assertEqual(client.table.count_of_remaining_tiles, 70)

        meld = Meld()
        client.table.add_called_meld(0, meld)

        self.assertEqual(len(client.player.melds), 1)
        self.assertEqual(client.table.count_of_remaining_tiles, 71)

        client.player.tiles = [0]
        meld = Meld()
        meld.type = Meld.KAN
        # closed kan
        meld.tiles = [0, 1, 2, 3]
        meld.called_tile = None
        meld.opened = False
        client.table.add_called_meld(0, meld)

        self.assertEqual(len(client.player.melds), 2)
        # kan was closed, so -1
        self.assertEqual(client.table.count_of_remaining_tiles, 70)