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:
AttilaNet
2026-11-08 13:08:12 +08:00
parent db17fc1288
commit 3b5da7ebcb
8 changed files with 331 additions and 21 deletions
+12 -2
View File
@@ -43,7 +43,7 @@ class GiftTests(unittest.TestCase):
def test_liked_item_respects_reserve_cap_and_cooldown(self):
action = self.planner.plan(self.snapshot, self.policy)[0]
self.assertEqual(action.payload, {"monsterId": 900, "itemId": int(self.liked)})
self.assertEqual(action.payload, {"monsterId": 900, "itemId": 2000})
self.snapshot.raw["items"][-2]["num"] = 2
self.assertEqual(self.planner.plan(self.snapshot, self.policy), [])
self.snapshot.raw["items"][-2]["num"] = 3
@@ -59,11 +59,21 @@ class GiftTests(unittest.TestCase):
self.policy.gift_items[self.liked]["enabled"] = False
self.assertEqual(self.planner.plan(self.snapshot, self.policy), [])
self.policy.gift_liked_only = False
self.assertEqual(self.planner.plan(self.snapshot, self.policy)[0].payload["itemId"], int(self.disliked))
self.assertEqual(self.planner.plan(self.snapshot, self.policy)[0].payload["itemId"], 2001)
def test_quest_reserves_take_precedence(self):
self.assertEqual(self.planner.plan(self.snapshot, self.policy, QuestPolicy(item_reserves={self.liked: 3})), [])
def test_cooling_manual_target_does_not_block_other_selected_targets(self):
other = copy.deepcopy(self.target)
other["id"] = 901
self.snapshot.raw["monsters"].append(other)
self.policy.gift_targets["901"] = 2
self.target["giftTime"] = self.snapshot.now * 1000
plans = self.planner.plan(self.snapshot, self.policy)
self.assertTrue(plans, "A cooling first target blocked another ready target")
self.assertEqual(plans[0].payload["monsterId"], 901)
def test_demo_consumes_one_item_and_clamps_feel(self):
engine = Engine(self.catalog)
engine.snapshot = self.snapshot