Prioritize commission rewards and fix built-in battle simulation flow
This commit is contained in:
@@ -7,6 +7,14 @@ from .model import Action, Planner, seconds
|
||||
CN = timezone(timedelta(hours=8))
|
||||
|
||||
|
||||
def commission_priority(info):
|
||||
try:
|
||||
reward = int((info.get("reward") or {}).get("ke") or 0)
|
||||
except (TypeError, ValueError):
|
||||
reward = 0
|
||||
return -reward
|
||||
|
||||
|
||||
def indexed(value, key, default=None):
|
||||
if isinstance(value, dict):
|
||||
return value.get(str(key), value.get(key, default))
|
||||
@@ -161,7 +169,9 @@ class TaskPlanner:
|
||||
current_day = int((snapshot.now - 10 + 8 * 3600) // 86400)
|
||||
if old_day < current_day:
|
||||
return [Action("quest_reset", "刷新跨日委托", "taskService/taskLoopFlush", {})]
|
||||
for task in self.current(snapshot) if include_active else []:
|
||||
current_tasks = sorted(self.current(snapshot), key=lambda task: commission_priority(
|
||||
self.catalog.data["task_info"][str(task["typeId"])])) if include_active else []
|
||||
for task in current_tasks:
|
||||
info = self.catalog.data["task_info"][str(task["typeId"])]
|
||||
index, steps = int(task.get("curStep", 1)) - 1, info.get("steps", [])
|
||||
payload = {"taskId": int(task["id"]), "taskTypeId": str(task["typeId"])}
|
||||
@@ -171,10 +181,12 @@ class TaskPlanner:
|
||||
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})]
|
||||
if not policy.accept or int(history.get("loopTaskNum", 0)) <= 0:
|
||||
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)}
|
||||
for type_id, name, state, _, meta in self.rows(snapshot, policy, ranch):
|
||||
offers = sorted(self.rows(snapshot, policy, ranch), key=lambda row: commission_priority(
|
||||
self.catalog.data["task_info"][row[0]]))
|
||||
for type_id, name, state, _, meta in offers:
|
||||
if "city" not in meta or type_id in current:
|
||||
continue
|
||||
city = meta["city"]
|
||||
|
||||
Reference in New Issue
Block a user