This commit is contained in:
@@ -92,6 +92,7 @@ class LocalExtensionInventoryTests(unittest.TestCase):
|
||||
"coin": JWEBOT_AUTHOR,
|
||||
"coin-transfer": JWEBOT_AUTHOR,
|
||||
"coin-ranking": JWEBOT_AUTHOR,
|
||||
"coin-taffy": JWEBOT_AUTHOR,
|
||||
"coin-loan": JWEBOT_AUTHOR,
|
||||
"random-number": JWEBOT_AUTHOR,
|
||||
"draw-lot": JWEBOT_AUTHOR,
|
||||
|
||||
@@ -176,6 +176,56 @@ class Release063GameTests(unittest.TestCase):
|
||||
self.assertIn("下注 500,返还 500", history)
|
||||
self.assertIn("1~500", self.command("/21点开始501"))
|
||||
|
||||
def test_multiplayer_blackjack_table_guides_turns_and_settles(self):
|
||||
self.assertIn("黑杰克Blackjack 21点牌桌", self.command("/21点 多人 启动"))
|
||||
self.assertIn("目前玩家:alice", self.command("/21点 状态"))
|
||||
self.assertIn("bob 已加入", self.command("/21点 加入", sender="Bob"))
|
||||
self.assertIn("请alice 放自己的筹码", self.command("/21点 多人 开始"))
|
||||
|
||||
alice_bet = self.command("/21点 放200", event_id="alice-table-bet")
|
||||
replay = self.command(
|
||||
"/21点 放200",
|
||||
sender="a1",
|
||||
event_id="alice-table-bet",
|
||||
)
|
||||
self.assertEqual(replay, alice_bet)
|
||||
self.assertIn("请bob 放自己的筹码", alice_bet)
|
||||
self.assertEqual(self.state()["balance"], 800)
|
||||
|
||||
def table_deck(cards):
|
||||
first = [12, 8, 9, 24, 19, 32, 25]
|
||||
cards[:] = first + [card for card in cards if card not in first]
|
||||
|
||||
with mock.patch.object(
|
||||
self.engine.local.players.rng,
|
||||
"shuffle",
|
||||
side_effect=table_deck,
|
||||
):
|
||||
dealt = self.command("/21点 放100", sender="Bob")
|
||||
self.assertIn("全部筹码已确认", dealt)
|
||||
self.assertIn("alice #1:K Q(20点);下注 200", dealt)
|
||||
self.assertIn("bob #1:9 7(16点);下注 100", dealt)
|
||||
self.assertIn("请alice 操作", dealt)
|
||||
self.assertEqual(self.state("Bob")["balance"], 900)
|
||||
|
||||
alice_stand = self.command("/21点 停牌")
|
||||
self.assertIn("alice 停牌", alice_stand)
|
||||
self.assertIn("请bob 操作", alice_stand)
|
||||
|
||||
settled = self.command("/21点 要牌", sender="Bob")
|
||||
self.assertIn("这一桌每个人的变化", settled)
|
||||
self.assertIn("alice #1:你赢了", settled)
|
||||
self.assertIn("下注 200,返还 400,净变化 +200;金币 1200", settled)
|
||||
self.assertIn("bob #1:你输了", settled)
|
||||
self.assertIn("下注 100,返还 0,净变化 -100;金币 900", settled)
|
||||
self.assertEqual(self.state()["balance"], 1200)
|
||||
self.assertEqual(self.state("Bob")["balance"], 900)
|
||||
self.assertIn("alice #1:21点 你赢了", self.command("/游戏记录"))
|
||||
self.assertIn(
|
||||
"bob #1:21点 你输了",
|
||||
self.command("/游戏记录", sender="Bob"),
|
||||
)
|
||||
|
||||
def test_prize_draw_has_indexed_history(self):
|
||||
with mock.patch.object(
|
||||
self.engine.local.players.rng,
|
||||
@@ -262,6 +312,29 @@ class Release063GameTests(unittest.TestCase):
|
||||
self.assertNotIn("Dave", ranking)
|
||||
self.assertIn("金币排行人数必须为 1~20", self.command("/金币排行 0"))
|
||||
|
||||
def test_taffy_coin_stats_sums_all_game_history(self):
|
||||
with mock.patch.object(
|
||||
self.engine.local.players.rng,
|
||||
"randrange",
|
||||
return_value=99,
|
||||
):
|
||||
self.command("/抽奖10")
|
||||
with mock.patch.object(
|
||||
self.engine.local.players.rng,
|
||||
"randrange",
|
||||
return_value=0,
|
||||
):
|
||||
self.command("/抽奖10", sender="Bob")
|
||||
|
||||
stats = self.command("/Taffy金币")
|
||||
|
||||
self.assertIn("玩家总下注 20,总返还 50", stats)
|
||||
self.assertIn("Taffy累计倒贴 30 金币", stats)
|
||||
self.assertIn("最大上贡者排行(含负数):", stats)
|
||||
self.assertIn("alice:上贡 10", stats)
|
||||
self.assertIn("bob:从Taffy赢走 40", stats)
|
||||
self.assertIn("Taffy金币人数必须为 1~20", self.command("/Taffy金币 0"))
|
||||
|
||||
def test_open_round_and_history_survive_restart(self):
|
||||
root = Path(self.temp.name)
|
||||
self.command("/彩票开始")
|
||||
|
||||
Reference in New Issue
Block a user