Add ranch retention, breakthroughs and exploration

This commit is contained in:
AttilaNet
2026-11-09 08:40:53 +08:00
parent f9631c3363
commit 9abc0a3de0
28 changed files with 4324 additions and 67 deletions
+33 -1
View File
@@ -18,6 +18,8 @@ from .master_sync import MasterSync
from .stage_cache import StageCache
from .drop_statistics import reward_text
from .cultivation import CultivationSelector
from .breakthrough import BreakthroughPlanner
from .exploration import ExplorePlanner, ExplorePolicy
from .battles import BattleJournal, BattleOrchestrator, CancelledBeforeDispatch, digest, gameplay_response, public_data, value
from .progression import ProgressionIntent, ProgressionPlanner, ProgressionPolicy
from .battle_messages import battle_message
@@ -58,6 +60,9 @@ class Engine:
self.hatch_planner = Planner(catalog, self.cultivation)
self.pending_hatches = []
self.gift_planner = GiftPlanner(catalog, self.cultivation)
self.breakthrough_planner = BreakthroughPlanner(catalog)
self.explore_planner = ExplorePlanner(catalog)
self.explore_policy = ExplorePolicy()
self.policy = Policy()
self.quest_policy = QuestPolicy()
self.tasks = TaskPlanner(catalog)
@@ -839,7 +844,11 @@ class Engine:
if self.demo:
self.apply_demo(action)
else:
if action.kind.startswith("explore_"):
self.explore_planner.mark_started(self.snapshot, action)
response = self._execute_legacy_task(action) if action.kind.startswith("quest_") else self.client.call(action.path, action.payload)
if action.kind.startswith("explore_"):
self.explore_planner.acknowledge(self.snapshot, action, response)
if action.kind == "buy":
self.record_draw(response.get("eggs") or [])
if action.kind == "gift":
@@ -858,6 +867,15 @@ class Engine:
if action.kind == "feed" and any(mid in self.snapshot.monsters for mid in action.payload["foods"]):
self.auto = False
raise ValueError("喂养已返回,但素材状态尚未同步;已停止,请刷新核对后再继续")
if action.kind == "breakthrough" and self.snapshot.monsters.get(action.payload["monId"], {}).get("potentialLevel") is not None:
# A successful write is followed by a fresh snapshot. Do
# not repeat it merely because a legacy response is sparse.
self.planner.notes.append("突破请求已返回,已刷新突破等级和材料")
if action.kind == "breakthrough":
expected = int(action.description.split("→")[-1].split("级")[0].strip()) if "→" in action.description else 0
actual = int(self.snapshot.monsters.get(action.payload["monId"], {}).get("potentialLevel") or 0)
if expected and actual != expected:
raise ValueError("突破请求已返回,但突破等级尚未同步;不会自动重复提交")
message = ("[演示] " if self.demo else "") + action.description
if action.kind == "buy" and self.last_draw:
message += ";" + self.last_draw
@@ -998,6 +1016,13 @@ class Engine:
sweep_actions = [map_action] if map_action else []
gifts = self.gift_planner.plan(self.snapshot, policy, self.quest_policy)
ranch = self.planner.plan(self.snapshot, policy, left)
breakthrough = self.breakthrough_planner.plan(self.snapshot, self.policy,
targets=self.policy.breakthrough_targets)
if breakthrough:
ranch = [breakthrough] + ranch
exploration = self.explore_planner.plan(self.snapshot, self.explore_policy, self.policy)
exploration = [] if exploration and exploration[0].kind == "explore_blocked" else exploration
self.planner.notes.extend(self.breakthrough_planner.notes)
self.planner.notes.extend(self.gift_planner.notes)
progression = [Action("progression", value(intent, "description", "推进任务"), "", {"intent": intent})
for intent in self._progression_intents if not value(intent, "block_reason") and self._intent_policy(intent).enabled]
@@ -1005,7 +1030,7 @@ class Engine:
progression = [action for action in progression if not self._is_commission(action.payload["intent"])]
if quests and quests[0].kind == "quest_reset":
return quests + commission[:1] + daily + progression[:1] + gifts + ranch + sweep_actions
return commission[:1] + quests + daily + progression[:1] + gifts + ranch + sweep_actions
return commission[:1] + quests + daily + progression[:1] + gifts + ranch + exploration + sweep_actions
@account_serial
def claim_daily_entry(self, entry):
@@ -1133,6 +1158,13 @@ class Engine:
if action.kind.startswith("quest_"):
self.apply_demo_quest(action)
return
if action.kind == "breakthrough":
mon = self.snapshot.monsters.get(action.payload["monId"])
if mon is not None:
mon["potentialLevel"] = int(mon.get("potentialLevel") or 1) + 1
return
if action.kind.startswith("explore_"):
return
if action.kind == "buy":
market = self.catalog.data["markets"][action.payload["id"]]
count = action.payload["num"]