add # 新增开垦、升级土地功能

This commit is contained in:
2026-10-21 14:07:18 +08:00
parent e5bec1a2b6
commit 4a484bfde6
13 changed files with 709 additions and 33 deletions
+7 -4
View File
@@ -61,13 +61,16 @@ class TransactionTests(unittest.IsolatedAsyncioTestCase):
self.assertEqual(snapshot.account.point, 500)
self.assertEqual(snapshot.account.vip_point, 0)
self.assertEqual(snapshot.account.experience, 0)
self.assertEqual(len(snapshot.plots), 3)
self.assertEqual([p.slot for p in snapshot.plots], list(range(1, 7)))
self.assertTrue(all(p.plant is None for p in snapshot.plots))
repeated = await self.service.register(
self.identity, "另一个名称", "register-again",
)
self.assertFalse(repeated.data["created"])
self.assertEqual(repeated.data["account"]["point"], 500)
self.assertEqual(
(await self.service.snapshot(self.identity)).plots, snapshot.plots,
)
self.assertEqual(len(await self.store.ledger(self.identity)), 1)
async def test_scopes_are_independent(self):
@@ -158,13 +161,13 @@ class TransactionTests(unittest.IsolatedAsyncioTestCase):
self.assertEqual(result.data["account"]["vip_point"], 6)
async def test_sow_all_and_explicit_overflow(self):
await self.service.buy(self.identity, "萝卜", 5, "buy")
await self.service.buy(self.identity, "萝卜", 8, "buy")
before = await self.service.snapshot(self.identity)
with self.assertRaisesRegex(FarmError, "insufficient_empty_plots"):
await self.service.sow(self.identity, "萝卜", 4, "too-many")
await self.service.sow(self.identity, "萝卜", 7, "too-many")
self.assertEqual(await self.service.snapshot(self.identity), before)
result = await self.service.sow(self.identity, "萝卜", None, "all")
self.assertEqual(result.data["quantity"], 3)
self.assertEqual(result.data["quantity"], 6)
self.assertEqual(result.data["seeds"], 2)
async def test_maturity_boundary_and_multi_crop_lifecycle(self):