fix(web): finalize quick battle and commission procurement for 2.0.9
This commit is contained in:
+45
-10
@@ -13,7 +13,7 @@ from ranch_assistant.drop_statistics import analyze
|
||||
from ranch_assistant.presentation import monster_rows
|
||||
from ranch_assistant.battle_messages import battle_message
|
||||
from ranch_assistant.resource_stages import available_item_count, item_requirements, with_resource_data
|
||||
from ranch_assistant.quests import commission_priority, commission_selection
|
||||
from ranch_assistant.quests import commission_priority, commission_selection, commission_reason_kind
|
||||
from .policies import default_config, validate_config
|
||||
|
||||
|
||||
@@ -478,6 +478,26 @@ def _category(value):
|
||||
return value if value in CATEGORIES else "unknown"
|
||||
|
||||
|
||||
def _task_diagnostic_reason(reason):
|
||||
# Keep concrete mechanism names visible while presenting Chinese reasons.
|
||||
text = str(reason or "")
|
||||
import re
|
||||
labels = {"monMaker": "生成魔物", "monSteps": "脚本行动", "skill": "脚本技能", "monDead": "魔物死亡事件"}
|
||||
for source, label in (("Unsupported monster controller", "当前模型尚未支持的魔物行为"),
|
||||
("Unsupported battle controller", "当前模型尚未支持的战斗机制"),
|
||||
("Unsupported battle triggers", "当前模型尚未支持的战斗触发事件")):
|
||||
text = re.sub(re.escape(source) + r":\s*([^;;\n]+)",
|
||||
lambda match: label + ":" + "、".join(labels.get(k.strip(), k.strip()) for k in match[1].split(",")), text)
|
||||
text = text.replace("+15overpoten", "潜能字段(+15overpoten)尚未兼容")
|
||||
return battle_message(text)
|
||||
|
||||
|
||||
REASON_KINDS = {"ready": "条件齐备", "city_locked": "城市未解锁", "prerequisite": "前置条件", "quota": "次数用尽",
|
||||
"offline": "账号离线", "busy": "当前占用", "cooldown": "等待时间", "temp_resource": "资源暂缺",
|
||||
"protection": "保护限制", "model_unsupported": "模型尚未支持", "policy": "策略限制",
|
||||
"uncertain_write": "请求待核对", "priority": "奖励排序"}
|
||||
|
||||
|
||||
def _mainline(dto, engine, config, query):
|
||||
selected, state = str(query.get("category", "mainline")), str(query.get("state", "current"))
|
||||
dto["filters"] = [_filter("category", "任务类别", selected, [("", "全部类别"), *CATEGORIES.items()]),
|
||||
@@ -492,7 +512,8 @@ def _mainline(dto, engine, config, query):
|
||||
lifecycle = STATE_ALIASES.get(raw_state, raw_state)
|
||||
if selected and category != selected or state == "current" and lifecycle not in ("received", "unlocked", "ready_to_reward") or state not in ("", "current") and lifecycle != state:
|
||||
continue
|
||||
reason = battle_message(source.get("blocked_reason") or source.get("block_reason") or source.get("reason") or "")
|
||||
raw_reason = source.get("blocked_reason") or source.get("block_reason") or source.get("reason") or ""
|
||||
reason = _task_diagnostic_reason(raw_reason)
|
||||
support = "受阻:" + reason if reason else "已支持" if source.get("supported") is True else "暂不支持" if source.get("supported") is False else "支持状态未确认"
|
||||
battle = _text(source.get("battle_kind"), "未确认")
|
||||
battle = BATTLE_ALIASES.get(battle, battle)
|
||||
@@ -500,11 +521,15 @@ def _mainline(dto, engine, config, query):
|
||||
"category_label": CATEGORIES[category], "name": _text(source.get("name")), "state": raw_state, "lifecycle_state": lifecycle,
|
||||
"state_label": STATES.get(raw_state, raw_state), "step": _text(source.get("step_number")) + " / " + _text(source.get("total_steps")),
|
||||
"location": _text(source.get("location_text") or source.get("location") or source.get("position")), "requirement": _text(source.get("requirement")),
|
||||
"next_action": _text(source.get("next_action")), "battle": BATTLE_KINDS.get(battle, battle), "support": support}
|
||||
"next_action": _task_diagnostic_reason(_text(source.get("next_action"))), "battle": BATTLE_KINDS.get(battle, battle), "support": support,
|
||||
"reason_kind": source.get("reason_kind") or commission_reason_kind(raw_reason),
|
||||
"resources": source.get("resources") or [], "progress_plan": source.get("progress_plan") or []}
|
||||
detail = {"任务": row["name"], "类别": row["category_label"], "状态": row["state_label"], "步骤": row["step"],
|
||||
"目标 / 位置": row["location"], "NPC": _text(source.get("npc_name")), "需求": row["requirement"],
|
||||
"对话": _text(source.get("dialogue") or source.get("dialogue_text") or source.get("dialogue_status"), "当前未提供对话内容"),
|
||||
"下一步": row["next_action"], "战斗": row["battle"], "运行状态": _text(source.get("status"), row["state_label"]), "支持状态 / 阻塞原因": support}
|
||||
"下一步": row["next_action"], "战斗": row["battle"], "运行状态": _text(source.get("status"), row["state_label"]), "支持状态 / 阻塞原因": support,
|
||||
"原因类型": REASON_KINDS.get(row["reason_kind"], "条件待核对"), "资源需求与可用量": row["resources"],
|
||||
"补齐计划": ";".join(row["progress_plan"])}
|
||||
if search and search not in " ".join(map(str, [*row.values(), *detail.values()])).casefold():
|
||||
continue
|
||||
dto["rows"].append(row)
|
||||
@@ -645,11 +670,11 @@ def _commissions(dto, engine, config, query):
|
||||
snapshot, catalog = engine.snapshot, engine.catalog
|
||||
search = _search(dto, query)
|
||||
dto["columns"] = [_column(key, label) for key, label in (("task_type_id", "编号"), ("name", "委托"), ("city", "城市"), ("status", "状态"),
|
||||
("reward_money", "标注金币"), ("reward_ke", "标注氪金"), ("selection_reason", "选择 / 回退原因"), ("reason", "需求 / 下一步 / 阻塞原因"))]
|
||||
("reward_money", "标注金币"), ("reward_ke", "标注氪金"), ("reason_type", "原因类型"), ("selection_reason", "选择 / 回退原因"), ("reason", "需求 / 下一步 / 阻塞原因"))]
|
||||
diagnostics = {str(row.get("task_type_id")): row for row in engine.progression_rows() if _category(row.get("category")) == "commission"}
|
||||
offer_rows = engine.commission_offer_diagnostics()
|
||||
offers = {(str(row.get("task_type_id")), str(row.get("city"))): row for row in offer_rows}
|
||||
selected = next((row for row in offer_rows if row.get("eligible") is True), {})
|
||||
selected = next((row for row in offer_rows if row.get("eligible") is True or row.get("preparable")), {})
|
||||
selection = commission_selection({"reward": {"ke": selected.get("expected_ke", 0)}}, offer_rows,
|
||||
[row for row in offer_rows if row.get("eligible") is False]) if selected else {}
|
||||
source = sorted(engine.tasks.rows(snapshot, engine.quest_policy, engine.policy), key=lambda row: (
|
||||
@@ -661,15 +686,23 @@ def _commissions(dto, engine, config, query):
|
||||
status = "可接取" if offer.get("eligible") is True else "候选 / 条件待核对"
|
||||
reason = (offer.get("reason") if offer.get("eligible") is False else None) if offer else diagnostic.get("block_reason") or diagnostic.get("blocked_reason")
|
||||
if reason:
|
||||
status = "暂不接取" if "city" in meta else "等待条件"
|
||||
status = "补齐后接取" if offer.get("preparable") else "暂不接取" if "city" in meta else "等待条件"
|
||||
text = reason
|
||||
elif not offer and diagnostic.get("next_action"):
|
||||
text = diagnostic["next_action"]
|
||||
info = catalog.data.get("task_info", {}).get(str(key), {})
|
||||
reward = info.get("reward") or {}
|
||||
reason_kind = offer.get("reason_kind") or diagnostic.get("reason_kind") or commission_reason_kind(reason)
|
||||
if offer and offer != selected and offer.get("eligible"):
|
||||
reason_kind = "priority"
|
||||
text = f"当前优先处理《{selected.get('name')}》({selected.get('expected_ke')}氪金);本委托条件齐备,排队等待"
|
||||
row = {"id": f"{key}:{index}", "task_type_id": str(key), "name": name, "status": status,
|
||||
"reward_money": reward.get("money", 0), "reward_ke": reward.get("ke", 0), "reason": battle_message(text),
|
||||
"city": meta.get("city"), "active": "city" not in meta,
|
||||
"reward_money": reward.get("money", 0), "reward_ke": reward.get("ke", 0), "reason": _task_diagnostic_reason(text),
|
||||
"city": offer.get("city_name") or meta.get("city"), "city_id": meta.get("city"), "active": "city" not in meta,
|
||||
"reason_kind": reason_kind, "reason_type": REASON_KINDS.get(reason_kind, "条件待核对"),
|
||||
"resources": offer.get("resources") or diagnostic.get("resources") or [],
|
||||
"progress_plan": offer.get("progress_plan") or diagnostic.get("progress_plan") or [],
|
||||
"next_step": _task_diagnostic_reason(offer.get("next_step") or diagnostic.get("next_action") or text),
|
||||
"selection_reason": _text(offer.get("selection_reason") or (selection.get("selection_reason") if offer and offer == selected else None)
|
||||
or diagnostic.get("selection_reason") or meta.get("selection_reason") or (reason if "city" in meta else None),
|
||||
"较高氪金的可执行委托优先" if offer.get("eligible") is True else "接取条件待核对" if "city" in meta else "已接取,优先推进当前委托")}
|
||||
@@ -677,7 +710,9 @@ def _commissions(dto, engine, config, query):
|
||||
continue
|
||||
dto["rows"].append(row)
|
||||
dto["details"][row["id"]] = {"描述": info.get("des", ""), "标注奖励": reward_summary(catalog, reward),
|
||||
"城市": _text(meta.get("city")), "选择 / 回退原因": row["selection_reason"], "需求 / 下一步": row["reason"],
|
||||
"城市": _text(row["city"]), "城市解锁条件": offer.get("unlock_condition", ""),
|
||||
"原因类型": row["reason_type"], "资源需求与可用量": row["resources"], "补齐计划": ";".join(row["progress_plan"]),
|
||||
"下一步": row["next_step"], "选择 / 回退原因": row["selection_reason"], "需求 / 下一步": row["reason"],
|
||||
"交付限制": {"允许物品": engine.quest_policy.allow_items, "允许魔物": engine.quest_policy.allow_monsters,
|
||||
"单次金币上限": engine.quest_policy.max_money, "允许已支持战斗": engine.quest_policy.battle_tasks},
|
||||
"接取优先级": "跨城市按标注氪金 20 → 15 → 10 优先;20 氪金均不可用时回退到可执行的 15 / 10 氪金委托"}
|
||||
|
||||
Reference in New Issue
Block a user