예제 #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'])
예제 #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)
예제 #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)
예제 #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
예제 #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
예제 #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)
예제 #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)
예제 #8
0
game_stage = game.stage

while game_stage != core_doudizhu.CoreDoudizhu.STAGE_FINISHED:

    current_index_cards = game.playerHand[current_index]
    print(
        f'\n\ncurrent index:{current_index},cards:{card.bin_card_to_terminal_output(current_index_cards)},length:{len(current_index_cards)}'
    )
    if not game._previous_cd():
        print('now anything you want...')
    input_str = input('--->:')

    input_bin_cards = None
    if input_str:
        input_bin_cards = card.bin_card_from_terminal_string(input_str)
        print(
            f'had input cards:{card.bin_card_to_terminal_output(input_bin_cards)}'
        )
        if input_bin_cards is None:
            print("bad input")
            continue

    deal_result = game.play_card(current_index, input_bin_cards)
    if deal_result:
        print(deal_result)

        if len(game.playerHand[current_index]) == 0:
            print("game over, winner:", current_index)
            exit()
        else:
예제 #9
0
 def test_single_straight3(self):
     ret = doudizhu_match.check_valuable_play(
         card.bin_card_from_terminal_string('s3h4c5d6'))
     self.assertIsNone(ret)
예제 #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)
예제 #11
0
 def test_bombs3(self):
     ret = doudizhu_match.check_valuable_play(
         card.bin_card_from_terminal_string('sAsAsAsAs2s2s2s2'))
     self.assertIsNone(ret)
예제 #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)
예제 #13
0
 def test_four_two3(self):
     ret = doudizhu_match.check_valuable_play(
         card.bin_card_from_terminal_string('!Wc6c6c6c2c2'))
     self.assertIsNone(ret)
예제 #14
0
import card

bin_cards = card.bin_card_from_terminal_string('!Wd2c3h0bK')

print(bin_cards)

again = card.bin_card_to_terminal_output(bin_cards)

print(again)

assert '!W♦2♣3♥0♠K' == again

nocolors = card.bin_card_remove_color(bin_cards)
nocolor_str = card.bin_card_to_terminal_output(nocolors)
print(nocolor_str)

base64_show = card.bin_cards_to_base64(bin_cards)
print(f'base64 {base64_show}')
back_from_64 = card.bin_cards_from_base64(base64_show)
print(f'back from base64 {card.bin_card_to_terminal_output(back_from_64)}')

print(card.bin_card_to_terminal_output(card.ONE_DECK))

print(f'base16 one deck:{card.ONE_DECK.hex()}')
print(f'base64 one deck:{card.bin_cards_to_base64(card.ONE_DECK)}')

orgin_cards = list(card.ONE_DECK)
card.fisher_yates_shuffle(orgin_cards)
print(card.bin_card_to_terminal_output(orgin_cards))

## some