移除行动点系统,倒计时本地走秒,字体优化

为什么:游戏的时间(40 分钟一天、只能自然流动)本身就是唯一的行动节奏
阀门,再叠一层"每天 10 点行动点"纯属重复惩罚——浇水还要体力既不拟真
也不好玩。删掉之后,稀缺的只剩时间本身,放置玩法的定位反而更纯粹。

改动范围(引擎到界面连根拔):
- config 删 START_AP/AP_COST;models 删 ap 字段与 max_ap,存档 payload
  里的旧 ap 键被 from_dict 自然忽略;
- engine 删 _spend_ap 与全部 8 个调用点、每日恢复逻辑与日志;
  available_actions 不再按行动点筛,cost 只剩金币;
- storage 建表去掉 ap 列,老库在 connect() 里 ALTER TABLE DROP COLUMN
  无痛迁移(实测 saves/farm.db 已自动迁完);
- bot 删 AP 分支(无 AP 后 available_actions 恒可用);client/TUI/CLI/
  README/帮助文本同步清理。

网页端顺带两件事:
- "下一天"倒计时改为客户端本地走秒——SSE 只在有变化时推送,以前倒计时
  只在推送瞬间跳变,现在每秒都在动(记基点 + 1s 定时器补齐);
- 字体优化:页面字体栈补齐 MiSans/HarmonyOS Sans/PingFang,正文字号
  14→15,统计数字 tabular-nums;canvas 小字统一字体栈并加粗提对比度。

测试适配:删 2 个 AP 专属用例(无 AP 可测)、改名/收敛 5 个,
532 项全绿(skip 39),ruff/pyright 干净。真机验证:老库迁移、
统计条无行动点、倒计时逐秒递减(39:04→39:02)、动作不再报 no_ap。
This commit is contained in:
snowy-yang committed 2026-09-25 22:44:08 +08:00
1 parent 92b1a628b1
commit 15d290a60a
18 files changed
+82 -179

No files matched your search

+5 -24
View File
@@ -160,7 +160,6 @@ class GameStateTestCase(unittest.TestCase):
state = GameState()
self.assertEqual(state.day, 1)
self.assertEqual(state.gold, config.START_GOLD)
self.assertEqual(state.ap, config.START_AP)
self.assertEqual(len(state.plots), config.BASE_PLOTS)
self.assertEqual(len(state.animals), 0)
@@ -209,10 +208,9 @@ class GameStateTestCase(unittest.TestCase):
self.assertIsNone(state.next_goal)
def test_from_dict_clamps_hostile_values(self):
"""存档是外部输入:负数金币、越界行动点都要被夹回来。"""
state = GameState.from_dict({"gold": -500, "ap": 9999, "level": 0, "day": -3})
"""存档是外部输入:负数金币、越界等级都要被夹回来。"""
state = GameState.from_dict({"gold": -500, "level": 0, "day": -3})
self.assertEqual(state.gold, 0)
self.assertEqual(state.ap, state.max_ap)
self.assertEqual(state.level, 1)
self.assertEqual(state.day, 1)
@@ -472,12 +470,11 @@ class ActionTestCase(unittest.TestCase):
self.assertEqual(ctx.exception.status, 400)
# ------------------------------------------------------------------ 播种
def test_plant_costs_gold_and_action_point(self):
gold, ap = self.engine.state.gold, self.engine.state.ap
def test_plant_costs_gold(self):
gold = self.engine.state.gold
result = self.engine.plant(1, "wheat")
self.assertTrue(result["ok"])
self.assertEqual(self.engine.state.gold, gold - config.CROPS["wheat"]["seed_cost"])
self.assertEqual(self.engine.state.ap, ap - config.AP_COST["plant"])
def test_plant_sets_initial_moisture_and_planted_day(self):
self.engine.state.day = 4
@@ -511,11 +508,6 @@ class ActionTestCase(unittest.TestCase):
self.engine.water(1)
self.assertEqual(self.engine.state.plots[0].moisture, config.WATER_CAPACITY)
def test_water_needs_ap(self):
self.engine.plant(1, "wheat")
self.engine.state.ap = 0
self.assert_code("no_ap", self.engine.water, 1)
def test_water_rejects_full_and_empty_plots(self):
self.assert_code("plot_empty", self.engine.water, 1)
self.engine.plant(2, "wheat")
@@ -650,7 +642,6 @@ class ActionTestCase(unittest.TestCase):
self.engine.state.level = 99
self.engine.state.gold = 10**9
while self.engine.state.next_plot_price > 0:
self.engine.state.ap = 10
self.engine.buy_plot()
self.assertEqual(len(self.engine.state.plots), config.MAX_PLOTS)
self.assert_code("plot_limit", self.engine.buy_plot)
@@ -861,11 +852,9 @@ class AdvanceDayTestCase(unittest.TestCase):
def setUp(self):
self.engine = make_engine()
def test_day_increments_and_action_points_refill(self):
self.engine.state.ap = 0
def test_day_increments(self):
self.engine.advance_day()
self.assertEqual(self.engine.state.day, 2)
self.assertEqual(self.engine.state.ap, config.START_AP)
def test_fed_animals_make_progress_and_get_hungry_again(self):
self.engine.buy_animal("chicken") # cycle 1
@@ -1038,19 +1027,11 @@ class AvailableActionsTestCase(unittest.TestCase):
self.assertIn("collect", actions)
self.assertNotIn("feed", actions)
def test_action_point_shortage_hides_action_point_actions(self):
self.engine.state.ap = 0
names = self.names()
self.assertNotIn("plant", names)
self.assertNotIn("water", names)
self.assertNotIn("feed", names)
def test_actions_explain_themselves(self):
for item in self.engine.available_actions():
with self.subTest(action=item["action"]):
self.assertTrue(item["reason"])
self.assertIn("gold", item["cost"])
self.assertIn("ap", item["cost"])
class LogTestCase(unittest.TestCase):