Fix gift item instance IDs and per-monster cooldown scheduling
Use bag instance IDs required by the client protocol. Apply confirmed feel and giftDate values across stale queries, skip cooling targets, and schedule ready gifts independently of random polling. Replan cultivation locally and retain local strategy errors in diagnostics.
This commit is contained in:
@@ -77,6 +77,7 @@ class Engine:
|
||||
mon.update({field: entry[field] for field in fields if field in entry})
|
||||
rows.append(mon)
|
||||
self.snapshot.raw["monsters"] = rows
|
||||
self.gift_planner.apply_confirmed(self.snapshot)
|
||||
self.sweeper.recover_reward_event(self.snapshot, getattr(getattr(self.client, "trace", None), "path", None))
|
||||
return self.snapshot
|
||||
|
||||
@@ -211,6 +212,12 @@ class Engine:
|
||||
response = self.client.call(action.path, action.payload)
|
||||
if action.kind == "buy":
|
||||
self.record_draw(response.get("eggs") or [])
|
||||
if action.kind == "gift":
|
||||
try:
|
||||
self.gift_planner.remember_success(self.snapshot, action, response)
|
||||
except ValueError:
|
||||
self.auto = False
|
||||
raise
|
||||
self.read_snapshot(sync_master=not hatch_only)
|
||||
if action.kind == "hatch":
|
||||
stack_id = action.payload["eggs"][0]["stackId"]
|
||||
@@ -400,7 +407,7 @@ class Engine:
|
||||
raw["monsters"] = [m for m in raw["monsters"] if m["id"] != mid]
|
||||
elif action.kind == "gift":
|
||||
target = self.snapshot.monsters[action.payload["monsterId"]]
|
||||
item = next(i for i in raw["items"] if int(i["typeId"]) == action.payload["itemId"])
|
||||
item = next(i for i in raw["items"] if int(i["id"]) == action.payload["itemId"])
|
||||
gain = int(self.catalog.monster(target.get("typeId")).get("like", {}).get(str(item["typeId"]), 0))
|
||||
target["feel"] = max(0, min(self.catalog.max_feel(target), int(target.get("feel") or 0) + gain))
|
||||
target["giftTime"] = int(time.time())
|
||||
|
||||
Reference in New Issue
Block a user