feat: add daily commission history for Web 2.0.8
This commit is contained in:
@@ -15,6 +15,24 @@ def commission_priority(info):
|
||||
return -reward
|
||||
|
||||
|
||||
def commission_selection(info, offers, rejected):
|
||||
"""Explain this selection using the offers actually examined, across cities."""
|
||||
reward = -commission_priority(info)
|
||||
higher = [row for row in rejected if row["expected_ke"] > reward]
|
||||
has_twenty = any(row["expected_ke"] == 20 for row in offers)
|
||||
if reward >= 20:
|
||||
code, reason = "highest_reward", f"按氪金奖励优先,选择当前可处理的 {reward} 氪金委托"
|
||||
elif not has_twenty:
|
||||
code, reason = "no_20_offered", f"本次候选未提供20氪金委托,按奖励优先选择 {reward} 氪金委托"
|
||||
if higher:
|
||||
reason += ";" + ";".join(f"{row['name']}({row['expected_ke']}氪金):{row['reason']}" for row in higher)
|
||||
else:
|
||||
code = "20_ineligible"
|
||||
details = ";".join(f"{row['name']}({row['expected_ke']}氪金):{row['reason']}" for row in higher)
|
||||
reason = f"较高奖励委托当前不可接取,选择 {reward} 氪金委托" + (";" + details if details else "")
|
||||
return {"selection_code": code, "selection_reason": reason, "higher_reward_blockers": higher}
|
||||
|
||||
|
||||
def indexed(value, key, default=None):
|
||||
if isinstance(value, dict):
|
||||
return value.get(str(key), value.get(key, default))
|
||||
@@ -84,6 +102,7 @@ class TaskPlanner:
|
||||
def __init__(self, catalog):
|
||||
self.catalog = catalog
|
||||
self.guard = Planner(catalog)
|
||||
self.commission_selection = {}
|
||||
|
||||
def current(self, snapshot):
|
||||
infos = self.catalog.data.get("task_info", {})
|
||||
@@ -161,6 +180,7 @@ class TaskPlanner:
|
||||
return rows
|
||||
|
||||
def plan(self, snapshot, policy, ranch, *, include_active=True, accept_supported=None):
|
||||
self.commission_selection = {}
|
||||
if not policy.enabled:
|
||||
return []
|
||||
history = snapshot.raw.get("history", {})
|
||||
@@ -176,31 +196,42 @@ class TaskPlanner:
|
||||
index, steps = int(task.get("curStep", 1)) - 1, info.get("steps", [])
|
||||
payload = {"taskId": int(task["id"]), "taskTypeId": str(task["typeId"])}
|
||||
if steps and index >= len(steps):
|
||||
return [Action("quest_complete", f"领取委托奖励:{info['name']}", "taskService/taskComplete", payload)]
|
||||
return [Action("quest_complete", f"领取委托奖励:{info['name']}(预计{-commission_priority(info)}氪金)", "taskService/taskComplete", payload)]
|
||||
if 0 <= index < len(steps):
|
||||
ready, ids, _ = self.requirement(snapshot, steps[index], task, policy, ranch)
|
||||
if ready:
|
||||
return [Action("quest_step", f"推进委托:{info['name']}", "taskService/taskCompleteStep", payload | {"removeIds": ids or None})]
|
||||
return [Action("quest_step", f"推进委托:{info['name']}(预计{-commission_priority(info)}氪金)", "taskService/taskCompleteStep", payload | {"removeIds": ids or None})]
|
||||
if current_tasks or not policy.accept or int(history.get("loopTaskNum", 0)) <= 0:
|
||||
return []
|
||||
current = {str(t["typeId"]) for t in self.current(snapshot)}
|
||||
offers = sorted(self.rows(snapshot, policy, ranch), key=lambda row: commission_priority(
|
||||
self.catalog.data["task_info"][row[0]]))
|
||||
candidates, rejected = [], []
|
||||
for type_id, name, state, _, meta in offers:
|
||||
if "city" not in meta or type_id in current:
|
||||
continue
|
||||
city = meta["city"]
|
||||
if policy.city and city != policy.city or not snapshot.city_unlocked(city):
|
||||
continue
|
||||
info = self.catalog.data["task_info"][type_id]
|
||||
if info.get("closed") or not condition_ok((info.get("startStep") or {}).get("condition"), snapshot):
|
||||
candidate = {"task_type_id": type_id, "name": name, "city": city, "expected_ke": -commission_priority(info)}
|
||||
candidates.append(candidate)
|
||||
reason = (f"策略限定城市 {policy.city}" if policy.city and city != policy.city else
|
||||
"城市尚未解锁" if not snapshot.city_unlocked(city) else "委托已关闭" if info.get("closed") else
|
||||
"接取前置条件未满足" if not condition_ok((info.get("startStep") or {}).get("condition"), snapshot) else "")
|
||||
if reason:
|
||||
rejected.append(candidate | {"reason": reason})
|
||||
continue
|
||||
steps = info.get("steps", [])
|
||||
supported = accept_supported(type_id) if accept_supported else all(
|
||||
(s.get("statusType") in ("passStage", "battle") and policy.battle_tasks)
|
||||
or self.requirement(snapshot, s, {}, policy, ranch)[0] for s in steps)
|
||||
if supported:
|
||||
return [Action("quest_accept", f"接取委托:{name}", "taskService/taskLoopReceive", {"taskTypeId": type_id, "city": city})]
|
||||
self.commission_selection = {"task_type_id": type_id, "city": city,
|
||||
**commission_selection(info, candidates, rejected)}
|
||||
return [Action("quest_accept", f"接取委托:{name}(预计{-commission_priority(info)}氪金);" + self.commission_selection["selection_reason"],
|
||||
"taskService/taskLoopReceive", {"taskTypeId": type_id, "city": city})]
|
||||
reason = next((self.requirement(snapshot, step, {}, policy, ranch)[2] for step in steps
|
||||
if not self.requirement(snapshot, step, {}, policy, ranch)[0]), "委托后续步骤当前无法自动完成")
|
||||
rejected.append(candidate | {"reason": reason})
|
||||
return []
|
||||
|
||||
def reservations(self, snapshot):
|
||||
|
||||
Reference in New Issue
Block a user