Exemplo n.º 1
0
    def test_single(self):
        ret = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('cJ'))
        self.assertTrue(ret)
        self.assertEqual(ret.pattern, 101)
        self.assertEqual(ret.weight, 11)

        ret2 = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('s2'), ret)
        self.assertTrue(ret2)
        self.assertEqual(ret2.pattern, 101)
        self.assertEqual(ret2.weight, doudizhu_match.MIN3_2)

        ret3 = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('c6'), ret)
        self.assertIsNone(ret3)

        ret4 = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('h8c8'), ret)
        self.assertIsNone(ret4)

        ret5 = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('hJsJcJdJdQhQsQcQ'), ret)
        self.assertTrue(ret5)
        self.assertEqual(ret5.pattern, 8)
        self.assertEqual(ret5.weight, card._color_char_to_bin_map['J'])
Exemplo n.º 2
0
    def test_grand_bomb(self):
        ret = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('!V!W'))
        self.assertTrue(ret)
        self.assertEqual(ret.pattern, 2)

        ret2 = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('s2s2s2s2'), ret)
        self.assertIsNone(ret2)
Exemplo n.º 3
0
    def test_four_two2(self):
        ret = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('s5s5s5s5s6s6s6s6sQsQsQc7'))
        self.assertTrue(ret)
        self.assertEqual(ret.pattern, 612)
        self.assertEqual(ret.weight, 5)

        ret2 = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('!W'), ret)
        self.assertIsNone(ret2)
Exemplo n.º 4
0
def test1():
    deal_str = "d0c0h0s2"
    deal_bins = card.bin_card_from_terminal_string(deal_str)
    ret = doudizhu_match.check_valuable_play(deal_bins)
    print(ret)
    assert ret

    deal_str2 = "dAhAsA!W"
    deal_bins2 = card.bin_card_from_terminal_string(deal_str2)
    ret2 = doudizhu_match.check_valuable_play(deal_bins2, ret)
    print(ret2.pattern)
    assert ret2
Exemplo n.º 5
0
def test2():
    deal_str = "d3h4h5h6c7c8"
    deal_bins = card.bin_card_from_terminal_string(deal_str)
    ret = doudizhu_match.check_valuable_play(deal_bins)
    print(ret)
    assert ret

    deal_str2 = "!V!W"
    deal_bins2 = card.bin_card_from_terminal_string(deal_str2)
    ret2 = doudizhu_match.check_valuable_play(deal_bins2, ret)
    print(ret2.pattern)
    assert ret2
Exemplo n.º 6
0
    def test_bombs(self):
        ret = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('dAdAdAdA'))
        self.assertTrue(ret)
        self.assertEqual(ret.pattern, 4)
        self.assertEqual(ret.weight, 14)

        ret2 = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('d3d3d3d3d4d4d4d4d5d5d5d5'),
            ret)
        self.assertTrue(ret2)
        self.assertEqual(ret2.pattern, 12)
        self.assertEqual(ret2.weight, 3)
Exemplo n.º 7
0
    def test_single_straight(self):
        ret = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('c6c7c8c9c0cJcQdK'))
        self.assertTrue(ret)
        self.assertEqual(ret.pattern, 108)
        self.assertEqual(ret.weight, 6)

        ret1 = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('c7c8c9c0cJcQcKcA'), ret)
        self.assertTrue(ret1)
        self.assertEqual(ret1.pattern, 108)
        self.assertEqual(ret1.weight, 7)

        ret2 = doudizhu_match.check_valuable_play(
            card.bin_card_from_terminal_string('d8d9d0dJsQdKdA'), ret)
        self.assertIsNone(ret2)
Exemplo n.º 8
0
 def play_card(self, p_index, cards):
     """
     cards 为空表示"不要"
     返回 None 表示无效出牌
     返回 {...} 表示此次出牌的eventContent
     """
     if p_index == self._get_current_turn():
         if cards:
             if card.contain_subcard(self.playerHand[p_index], cards):
                 ret = doudizhu_match.check_valuable_play(
                     cards, self._previous_cd())
                 if ret:
                     card.remove_subcard(self.playerHand[p_index], cards)
                     self._deadwood += cards
                     self.__add_playing_track(p_index, cards, ret)
                     return self.playingTrack[-1].copy()
         else:
             if self._previous_cd():  # 起始出牌时不出是不允许的!即只有在之前有效时才能"不出"
                 self.__add_playing_track(p_index, cards,
                                          doudizhu_match.CardDescription())
                 return self.playingTrack[-1].copy()
Exemplo n.º 9
0
 def test_single_straight3(self):
     ret = doudizhu_match.check_valuable_play(
         card.bin_card_from_terminal_string('s3h4c5d6'))
     self.assertIsNone(ret)
Exemplo n.º 10
0
 def test_single_straight2(self):
     ret = doudizhu_match.check_valuable_play(
         card.bin_card_from_terminal_string('s3s4s5s6s7s8s9s0sJsQsKsA'))
     self.assertTrue(ret)
     self.assertEqual(ret.pattern, 112)
     self.assertEqual(ret.weight, 3)
Exemplo n.º 11
0
 def test_bombs3(self):
     ret = doudizhu_match.check_valuable_play(
         card.bin_card_from_terminal_string('sAsAsAsAs2s2s2s2'))
     self.assertIsNone(ret)
Exemplo n.º 12
0
 def test_bombs2(self):
     ret = doudizhu_match.check_valuable_play(
         card.bin_card_from_terminal_string('s7h7c7c7c8c8c8c8'))
     self.assertTrue(ret)
     self.assertEqual(ret.pattern, 8)
     self.assertEqual(ret.weight, 7)
Exemplo n.º 13
0
 def test_four_two3(self):
     ret = doudizhu_match.check_valuable_play(
         card.bin_card_from_terminal_string('!Wc6c6c6c2c2'))
     self.assertIsNone(ret)