feat: add daily commission history for Web 2.0.8
This commit is contained in:
@@ -45,7 +45,7 @@ import uuid
|
||||
|
||||
from .game_data import ProgressionData, load_progression_data
|
||||
from .model import Planner, seconds
|
||||
from .quests import commission_priority, indexed, stage_has_level
|
||||
from .quests import commission_priority, commission_selection, indexed, stage_has_level
|
||||
|
||||
|
||||
CATEGORIES = {1: ("mainline", "主线"), 2: ("sidequest", "支线"),
|
||||
@@ -184,6 +184,8 @@ class ProgressionPlanner:
|
||||
self._anonymous = uuid.uuid4().hex
|
||||
self._accounts = {}
|
||||
self._issued = {}
|
||||
self.commission_selection = {}
|
||||
self.commission_offer_rows = []
|
||||
|
||||
def _scope(self, snapshot):
|
||||
raw, master = snapshot.raw, snapshot.raw.get("master") or {}
|
||||
@@ -896,11 +898,16 @@ class ProgressionPlanner:
|
||||
taskLoopReceive:{taskTypeId,city}; quotas decrement only on acceptance
|
||||
acknowledgement. Current battle/passStage never become sweep intents.
|
||||
"""
|
||||
self.commission_selection = {}
|
||||
self.commission_offer_rows = []
|
||||
if not quest_policy.enabled:
|
||||
return []
|
||||
policy = self._commission_policy(quest_policy, battle_policy)
|
||||
scope, account = self._account(snapshot)
|
||||
self.reconcile(snapshot)
|
||||
candidates = self.commission_offers(snapshot, quest_policy, ranch_policy,
|
||||
battle_policy=battle_policy, accept_supported=accept_supported)
|
||||
self.commission_offer_rows = candidates
|
||||
if account["pending"]:
|
||||
reason = "存在未确认请求,委托等待核对,禁止重发"
|
||||
return [self._intent(scope, {}, 0, {}, "progression_blocked", reason, policy, block_reason=reason)]
|
||||
@@ -925,30 +932,67 @@ class ProgressionPlanner:
|
||||
blocked.append(action)
|
||||
if blocked or not quest_policy.accept or remaining <= 0:
|
||||
return blocked
|
||||
ranked_offers = sorted(((city, key) for city, values in offers.items() for key in _values(values)),
|
||||
key=lambda pair: commission_priority(self.data.task(str(pair[1])) or {}))
|
||||
for city, offered_key in ranked_offers:
|
||||
city = _integer(city)
|
||||
if city <= 0 or quest_policy.city and city != quest_policy.city or not snapshot.city_unlocked(city):
|
||||
continue
|
||||
key, info = str(offered_key), self.data.task(offered_key)
|
||||
if key in active or key in finished or not info or info.get("type") != 4:
|
||||
continue
|
||||
if not self._commission_offer_ready(snapshot, quest_policy, policy, ranch_policy, info)[0]:
|
||||
continue
|
||||
if accept_supported is not None and not accept_supported(key):
|
||||
blocked.append(self._intent(scope, {"id": 0, "typeId": key}, 0, info.get("startStep") or {},
|
||||
"progression_loop_accept", "暂不接取:" + info.get("name", key), policy,
|
||||
path="taskService/taskLoopReceive", payload={"taskTypeId": key, "city": city}, phase=str(today),
|
||||
block_reason="委托后续战斗或条件当前无法自动完成"))
|
||||
rejected = []
|
||||
for candidate in candidates:
|
||||
city, key = candidate["city"], candidate["task_type_id"]
|
||||
info = self.data.task(key)
|
||||
if not candidate["eligible"]:
|
||||
rejected.append(candidate)
|
||||
if candidate["blocked_by_support"]:
|
||||
blocked.append(self._intent(scope, {"id": 0, "typeId": key}, 0, info.get("startStep") or {},
|
||||
"progression_loop_accept", "暂不接取:" + info.get("name", key), policy,
|
||||
path="taskService/taskLoopReceive", payload={"taskTypeId": key, "city": city}, phase=str(today),
|
||||
block_reason=candidate["reason"]))
|
||||
continue
|
||||
self.commission_selection = {"task_type_id": key, "city": city,
|
||||
**commission_selection(info, candidates, rejected)}
|
||||
action = self._intent(scope, {"id": 0, "typeId": key}, 0, info.get("startStep") or {},
|
||||
"progression_loop_accept", "接取城市委托:" + info.get("name", key), policy,
|
||||
"progression_loop_accept", f"接取城市委托:{info.get('name', key)}(预计{candidate['expected_ke']}氪金);" + self.commission_selection["selection_reason"], policy,
|
||||
path="taskService/taskLoopReceive", payload={"taskTypeId": key, "city": city}, phase=str(today))
|
||||
self._issued[action.token] = action.to_dict()
|
||||
return [action]
|
||||
return blocked
|
||||
|
||||
def commission_offers(self, snapshot, quest_policy, ranch_policy, *, battle_policy=None, accept_supported=None):
|
||||
"""Offline eligibility for every offer; raw presence never means receivable."""
|
||||
policy = self._commission_policy(quest_policy, battle_policy)
|
||||
_, account = self._account(snapshot)
|
||||
today, recorded, remaining, offers = self._loop_view(snapshot, account)
|
||||
active, _, finished = self._tasks(snapshot, account)
|
||||
has_active = any((self.data.task(key) or {}).get("type") == 4 and key not in finished for key in active)
|
||||
rows = []
|
||||
ranked = sorted(((city, key) for city, values in offers.items() for key in _values(values)),
|
||||
key=lambda pair: commission_priority(self.data.task(str(pair[1])) or {}))
|
||||
for offered_city, offered_key in ranked:
|
||||
city, key = _integer(offered_city), str(offered_key)
|
||||
info = self.data.task(key) or {}
|
||||
if info.get("type") != 4:
|
||||
continue
|
||||
support_blocked = False
|
||||
reason = ("城市编号无效" if city <= 0 else
|
||||
f"策略限定城市 {quest_policy.city}" if quest_policy.city and city != quest_policy.city else
|
||||
"城市尚未解锁" if not snapshot.city_unlocked(city) else
|
||||
"委托列表已跨日,等待刷新确认" if recorded is not None and recorded != today and account["commissions"]["day"] != today else
|
||||
"当日接取次数已用完" if remaining <= 0 else
|
||||
"自动委托未启用" if not quest_policy.enabled else "自动接取未启用" if not quest_policy.accept else
|
||||
"存在未确认请求,等待核对" if account["pending"] else
|
||||
"该委托已接取或已完成" if key in active or key in finished else
|
||||
"已有委托优先完成" if has_active else "")
|
||||
if not reason:
|
||||
ready, reason = self._commission_offer_ready(snapshot, quest_policy, policy, ranch_policy, info)
|
||||
if ready:
|
||||
reason = ""
|
||||
if accept_supported is not None:
|
||||
result = accept_supported(key)
|
||||
supported, detail = result if isinstance(result, tuple) else (result, "")
|
||||
if not supported:
|
||||
reason = detail or "委托后续战斗或条件当前无法自动完成"
|
||||
support_blocked = True
|
||||
rows.append({"task_type_id": key, "name": info.get("name", key), "city": city,
|
||||
"expected_ke": -commission_priority(info), "eligible": not reason, "reason": reason or "可接取",
|
||||
"blocked_by_support": support_blocked})
|
||||
return rows
|
||||
|
||||
def commission_rows(self, snapshot, quest_policy, ranch_policy, *, battle_policy=None):
|
||||
policy = self._commission_policy(quest_policy, battle_policy)
|
||||
return [row for row in self.rows(snapshot, policy, ranch_policy, quest_policy=quest_policy)
|
||||
|
||||
Reference in New Issue
Block a user