fix: keep automatic cultivation on one stable primary per species

This commit is contained in:
AttilaNet
2026-11-13 08:51:03 +08:00
parent 01ad2e3ab9
commit 4fbe895999
35 changed files with 2069 additions and 322 deletions
+9 -1
View File
@@ -63,19 +63,27 @@ class GiftTimingTests(unittest.TestCase):
def test_success_response_updates_each_monster_despite_stale_queries(self):
with patch("ranch_assistant.model.time.time", return_value=NOW):
client = GiftClient(self.catalog)
client.raw["monsters"][1].update(typeId=1002010,
**{"g" + stat.capitalize(): self.catalog.monster(1002010)[stat + "_grow_min"]
for stat in ("atk", "def", "hp", "dex")})
engine = Engine(self.catalog, client)
engine.policy = gift_policy()
engine.auto = True
first, _, _ = engine.poll()
self.assertEqual(first.monsters[1]["feel"], 10)
self.assertEqual(first.monsters[1]["giftTime"], NOW)
engine.poll()
second, _, _ = engine.poll()
self.assertEqual(second.monsters[2]["feel"], 10)
self.assertEqual(second.monsters[2]["giftTime"], NOW)
engine.poll()
self.assertEqual([payload["monsterId"] for _, payload in client.calls], [1, 2])
def test_next_due_uses_earliest_eligible_cooldown_and_ignores_full_targets(self):
with patch("ranch_assistant.model.time.time", return_value=NOW):
snapshot = gift_snapshot(self.catalog)
snapshot.monsters[2].update(typeId=1002010,
**{"g" + stat.capitalize(): self.catalog.monster(1002010)[stat + "_grow_min"]
for stat in ("atk", "def", "hp", "dex")})
snapshot.monsters[1]["giftTime"] = (NOW - 7200 + 120) * 1000
snapshot.monsters[2]["giftTime"] = (NOW - 7200 + 15) * 1000
planner = GiftPlanner(self.catalog)