fix: keep automatic cultivation on one stable primary per species
This commit is contained in:
@@ -9,7 +9,9 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from .cultivation import CultivationSelector
|
||||
from .model import Action
|
||||
from .team_availability import _exploring_ids
|
||||
|
||||
|
||||
PATH = "monsterService/monsterPotentialLevelUpgrade"
|
||||
@@ -43,6 +45,31 @@ def field(row, name, default=None):
|
||||
return getattr(row, name, default)
|
||||
|
||||
|
||||
def primary_target_reason(catalog, cultivation, snapshot, monster_id, *, primaries=None):
|
||||
"""Admission for automatic resources only; saved target maps are not authority."""
|
||||
mid = integer(monster_id)
|
||||
mon = snapshot.monsters.get(mid) if snapshot is not None else None
|
||||
if mon is None:
|
||||
return f"自动培养目标 #{monster_id} 已不在角色数据中"
|
||||
label = catalog.monster_label(mon)
|
||||
if mon.get("process") != 3:
|
||||
return f"{label} 不在牧场,暂停自动培养"
|
||||
primaries = cultivation.select(snapshot) if primaries is None else primaries
|
||||
primary = primaries.get(str(mon.get("typeId")))
|
||||
if primary is None:
|
||||
return f"{label} 尚未确认同种主培养,暂停自动培养"
|
||||
if int(primary["id"]) != mid:
|
||||
return (f"{label} 是同种非主培养(备选 / 重复魔物);"
|
||||
f"仅主培养 #{primary['id']} 可自动喂养、赠礼和突破")
|
||||
if mon.get("inExploreTeam") or mid in _exploring_ids(snapshot):
|
||||
return f"{label} 主培养正在探险,暂停自动培养,不改用备选"
|
||||
if mon.get("inBuild"):
|
||||
return f"{label} 主培养正在建筑,暂停自动培养,不改用备选"
|
||||
if mon.get("sysLock"):
|
||||
return f"{label} 主培养系统锁定,暂停自动培养,不改用备选"
|
||||
return ""
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Material:
|
||||
type_id: int
|
||||
@@ -66,8 +93,9 @@ class Candidate:
|
||||
class BreakthroughPlanner:
|
||||
"""Plan PotentialPanel writes; each call returns at most one operation."""
|
||||
|
||||
def __init__(self, catalog):
|
||||
def __init__(self, catalog, cultivation=None):
|
||||
self.catalog = catalog
|
||||
self.cultivation = cultivation or CultivationSelector(catalog)
|
||||
self.notes = []
|
||||
|
||||
@staticmethod
|
||||
@@ -228,18 +256,14 @@ class BreakthroughPlanner:
|
||||
if not ids:
|
||||
self.notes.append("未选择自动突破目标")
|
||||
return None
|
||||
primaries = self.cultivation.select(snapshot)
|
||||
for mid in ids:
|
||||
mon = snapshot.monsters.get(mid)
|
||||
if not mon:
|
||||
self.notes.append(f"#{mid} 已不在角色数据中")
|
||||
reason = primary_target_reason(self.catalog, self.cultivation, snapshot, mid, primaries=primaries)
|
||||
if reason:
|
||||
self.notes.append(reason)
|
||||
continue
|
||||
mon = snapshot.monsters[mid]
|
||||
label = self.catalog.monster_label(mon)
|
||||
if mon.get("process") != 3:
|
||||
self.notes.append(f"{label} 不在牧场")
|
||||
continue
|
||||
if mon.get("inExploreTeam") or mon.get("inBuild"):
|
||||
self.notes.append(f"{label} 正在探险或建筑,暂停自动突破")
|
||||
continue
|
||||
level, caps, reason = self.caps(mon)
|
||||
if level is None:
|
||||
self.notes.append(f"{label}:{reason}")
|
||||
|
||||
Reference in New Issue
Block a user