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
+7 -4
View File
@@ -659,17 +659,20 @@ class ServiceTests(unittest.TestCase):
worker.schedule.clock = lambda: clock[0]
worker.engine.last_heartbeat = clock[0]
monsters = list(worker.engine.snapshot.monsters)
# Use the primary so the request reaches the uncertainty barrier.
species = str(worker.engine.snapshot.monsters[monsters[0]]["typeId"])
recipient = int(worker.engine.cultivation.select(worker.engine.snapshot)[species]["id"])
if kind == "gift":
# Engine overlays confirmed gift timestamps in seconds,
# while an unchanged raw server snapshot uses milliseconds.
mon = next(row for row in worker.engine.client.raw["monsters"] if row["id"] == monsters[0])
mon = next(row for row in worker.engine.client.raw["monsters"] if row["id"] == recipient)
mon["giftTime"] = 1_700_000_000_000
worker.engine.gift_planner.confirmed[monsters[0]] = {
worker.engine.gift_planner.confirmed[recipient] = {
"owner": str(worker.engine.snapshot.raw["master"]["id"]),
"type": str(mon["typeId"]), "feel": int(mon.get("feel") or 0),
"giftTime": 1_700_000_060}
action = Action(kind, "Unconfirmed gift", "monsterService/monsterSendGift",
{"monsterId": monsters[0], "itemId": 1})
{"monsterId": recipient, "itemId": 1})
elif kind == "hatch":
slot = worker.engine.client.raw["stacks"][0]
slot["monsterId"] = -1
@@ -678,7 +681,7 @@ class ServiceTests(unittest.TestCase):
worker.engine.pending_hatches = [action]
else:
action = Action(kind, "Unconfirmed feed", "monsterService/monsterIntensify",
{"targetId": monsters[0], "foods": [monsters[1]]})
{"targetId": recipient, "foods": [monsters[1]]})
before = len(FakeClient.calls)
with patch.object(worker.engine, "plans", return_value=[action]):
if kind == "hatch":