1
1
This commit is contained in:
@@ -41,6 +41,7 @@ def test_can_win_with_pure_sequences():
|
||||
hand.add_tile(MahjongTile("万", 5))
|
||||
|
||||
state = ChengduMahjongState()
|
||||
state.melds[0] = []
|
||||
state.hands[0] = hand
|
||||
|
||||
# 设置缺门为 "条",因为手牌中没有 "条"
|
||||
@@ -48,7 +49,7 @@ def test_can_win_with_pure_sequences():
|
||||
print(f"\n,state.hand[0]: {state.hands[0]}")
|
||||
|
||||
# 调用 can_win 方法并断言胡牌
|
||||
assert state.can_win(state.hands[0], missing_suit) == True, "测试失败:纯顺子应该可以胡牌"
|
||||
assert state.can_win(state.hands[0], state.melds[0],missing_suit) == True, "测试失败:纯顺子应该可以胡牌"
|
||||
|
||||
|
||||
def test_can_win_with_sequence_and_triplet():
|
||||
@@ -72,13 +73,14 @@ def test_can_win_with_sequence_and_triplet():
|
||||
|
||||
state = ChengduMahjongState()
|
||||
state.hands[0] = hand
|
||||
state.melds[0] = []
|
||||
|
||||
# 设置缺门为 "条",因为手牌中没有 "条"
|
||||
missing_suit = "条"
|
||||
print(f"\n,state.hand[0]: {state.hands[0]}")
|
||||
|
||||
# 调用 can_win 方法并断言胡牌
|
||||
assert state.can_win(state.hands[0], missing_suit) == True, "测试失败:顺子 + 刻子应该可以胡牌"
|
||||
assert state.can_win(state.hands[0], state.melds[0],missing_suit) == True, "测试失败:顺子 + 刻子应该可以胡牌"
|
||||
|
||||
def test_can_win_with_triplets_and_pair():
|
||||
"""测试刻子和对子胡牌"""
|
||||
@@ -100,13 +102,13 @@ def test_can_win_with_triplets_and_pair():
|
||||
|
||||
state = ChengduMahjongState()
|
||||
state.hands[0] = hand
|
||||
|
||||
state.melds[0] = []
|
||||
# 设置缺门为 "万",因为手牌中没有 "万"
|
||||
missing_suit = "万"
|
||||
print(f"\n,state.hand[0]: {state.hands[0]}")
|
||||
|
||||
# 调用 can_win 方法并断言胡牌
|
||||
assert state.can_win(state.hands[0], missing_suit) == True, "测试失败:刻子和对子应该可以胡牌"
|
||||
assert state.can_win(state.hands[0], state.melds[0],missing_suit) == True, "测试失败:刻子和对子应该可以胡牌"
|
||||
|
||||
|
||||
def test_can_win_with_pure_one_suit():
|
||||
@@ -130,12 +132,47 @@ def test_can_win_with_pure_one_suit():
|
||||
|
||||
state = ChengduMahjongState()
|
||||
state.hands[0] = hand
|
||||
state.melds[0] = []
|
||||
|
||||
# 设置缺门为 "万",因为手牌中只有 "筒"
|
||||
missing_suit = "万"
|
||||
print(f"\n,state.hand[0]: {state.hands[0]}")
|
||||
|
||||
# 调用 can_win 方法并断言胡牌
|
||||
assert state.can_win(state.hands[0], missing_suit) == True, "测试失败:清一色不带杠应该可以胡牌"
|
||||
assert state.can_win(state.hands[0], state.melds[0],missing_suit) == True, "测试失败:清一色不带杠应该可以胡牌"
|
||||
|
||||
|
||||
def test_can_win_with_pure_one_suit_and_gang():
|
||||
"""测试带杠的清一色胡牌"""
|
||||
hand = Hand()
|
||||
|
||||
# 添加暗牌
|
||||
hand.add_tile(MahjongTile("筒", 6))
|
||||
hand.add_tile(MahjongTile("筒", 6))
|
||||
hand.add_tile(MahjongTile("筒", 6))
|
||||
hand.add_tile(MahjongTile("筒", 7))
|
||||
hand.add_tile(MahjongTile("筒", 7))
|
||||
hand.add_tile(MahjongTile("筒", 7))
|
||||
hand.add_tile(MahjongTile("筒", 8))
|
||||
hand.add_tile(MahjongTile("筒", 8))
|
||||
hand.add_tile(MahjongTile("筒", 8))
|
||||
# 添加对子
|
||||
hand.add_tile(MahjongTile("筒", 2))
|
||||
hand.add_tile(MahjongTile("筒", 2))
|
||||
|
||||
# 初始化游戏状态
|
||||
state = ChengduMahjongState()
|
||||
state.hands[0] = hand
|
||||
|
||||
# 设置明牌(杠)
|
||||
melds_list = [
|
||||
("杠", MahjongTile("筒", 9))
|
||||
]
|
||||
state.melds[0] = melds_list
|
||||
|
||||
# 设置缺门为 "万"
|
||||
missing_suit = "万"
|
||||
print(f"\n当前手牌: {state.hands[0]}, 明牌: {state.melds[0]}")
|
||||
|
||||
# 调用 can_win 方法并断言胡牌
|
||||
assert state.can_win(state.hands[0], state.melds[0], missing_suit) == True, "测试失败:带杠的清一色应该可以胡牌"
|
||||
Reference in New Issue
Block a user