Release beta 2.0.4.1023

This commit is contained in:
JWeBot Contributors
2026-10-23 17:18:29 +08:00
parent 22f5240fa7
commit 6375ab5c79
32 changed files with 2286 additions and 233 deletions
+64 -17
View File
@@ -154,7 +154,20 @@ class Release063GameTests(unittest.TestCase):
self.assertEqual(self.state()["balance"], 500)
self.assertIn("已报名 1 人", self.command("/彩票状态"))
def test_blackjack_uses_1_to_500_and_indexed_history(self):
def test_blackjack_uses_1_to_2000_and_indexed_history(self):
self.command("/摩拉")
account = self.state()
account["balance"] = 2500
person_key = self.engine.ledger.resolve_person(
"group-a",
"Alice",
)["person_key"]
self.engine.ledger._save_player_account(
"group-a",
person_key,
account,
MODULE.utc_now(),
)
def tied_deck(cards):
first = [9, 6, 8, 7]
cards[:] = first + [card for card in cards if card not in first]
@@ -164,17 +177,23 @@ class Release063GameTests(unittest.TestCase):
"shuffle",
side_effect=tied_deck,
):
started = self.command("/21点开始500")
started = self.command("/21点开始2000")
self.assertTrue(started.startswith("alice #1:"))
self.assertEqual(self.state()["balance"], 500)
settled = self.command("/21点停牌")
self.assertTrue(settled.startswith("alice #1:"))
self.assertIn("平局", settled)
self.assertEqual(self.state()["balance"], 1000)
self.assertEqual(self.state()["balance"], 2500)
history = self.command("/游戏记录")
self.assertIn("alice #1:21点 平局", history)
self.assertIn("下注 500,返还 500", history)
self.assertIn("1~500", self.command("/21点开始501"))
self.assertIn("下注 2000,返还 2000", history)
rates = self.command("/21点胜率")
self.assertIn("Taffy:胜 0 / 负 0 / 平 1,胜率 0.00%", rates)
self.assertIn(
"alice:胜 0 / 负 0 / 平 1,胜率 0.00%;净赚净亏 0 摩拉",
rates,
)
self.assertIn("1~2000", self.command("/21点开始2001"))
def test_multiplayer_blackjack_table_guides_turns_and_settles(self):
self.assertIn("黑杰克Blackjack 21点牌桌", self.command("/21点 多人 启动"))
@@ -225,26 +244,54 @@ class Release063GameTests(unittest.TestCase):
"bob #1:21点 你输了",
self.command("/游戏记录", sender="Bob"),
)
rates = self.command("/21点 胜率")
self.assertIn("本群已结算 2 手", rates)
self.assertIn(
"Taffy:胜 1 / 负 1 / 平 0,胜率 50.00%;净亏 100 摩拉",
rates,
)
self.assertIn(
"alice:胜 1 / 负 0 / 平 0,胜率 100.00%;净赚 200 摩拉",
rates,
)
self.assertIn(
"bob:胜 0 / 负 1 / 平 0,胜率 0.00%;净亏 100 摩拉",
rates,
)
self.assertIn("+200:21点 获胜", self.command("/金币"))
self.assertIn(
"-100:21点 失败",
self.command("/金币", sender="Bob"),
)
def test_prize_draw_has_indexed_history(self):
def test_wish_pool_has_indexed_history(self):
self.command("/摩拉")
account = self.state()
account["balance"] = 2000
person_key = self.engine.ledger.resolve_person(
"group-a",
"Alice",
)["person_key"]
self.engine.ledger._save_player_account(
"group-a",
person_key,
account,
MODULE.utc_now(),
)
self.engine.ledger.connection.commit()
with mock.patch.object(
self.engine.local.players.rng,
"randrange",
return_value=99,
):
first = self.command("/抽奖10")
second = self.command("/抽奖10")
first = self.command("/许愿1000")
second = self.command("/抽奖1000")
self.assertTrue(first.startswith("alice #1:"))
self.assertTrue(second.startswith("alice #2:"))
history = self.command("/gamehistory")
self.assertIn("alice #2:抽奖 未中奖", history)
self.assertIn("alice #1:抽奖 未中奖", history)
self.assertIn("alice #2:许愿池 沉底", history)
self.assertIn("alice #1:许愿池 沉底", history)
def test_transfer_requires_initialized_target_and_replays_once(self):
self.assertIn("摩拉 1000", self.command("/摩拉"))
@@ -345,21 +392,21 @@ class Release063GameTests(unittest.TestCase):
"randrange",
return_value=99,
):
self.command("/抽奖10")
self.command("/抽奖1000")
with mock.patch.object(
self.engine.local.players.rng,
"randrange",
return_value=0,
side_effect=[950, 3000],
):
self.command("/抽奖10", sender="Bob")
self.command("/抽奖1000", sender="Bob")
stats = self.command("/Taffy摩拉")
self.assertIn("玩家总下注 20,总返还 50", stats)
self.assertIn("Taffy累计倒贴 30 摩拉", stats)
self.assertIn("玩家总下注 2000,总返还 3000", stats)
self.assertIn("Taffy累计倒贴 1000 摩拉", stats)
self.assertIn("最大上贡者排行(含负数):", stats)
self.assertIn("alice:上贡 10", stats)
self.assertIn("bob:从Taffy赢走 40", stats)
self.assertIn("alice:上贡 1000", stats)
self.assertIn("bob:从Taffy赢走 2000", stats)
self.assertIn("Taffy摩拉人数必须为 1~20", self.command("/Taffy摩拉 0"))
def test_open_round_and_history_survive_restart(self):