Revert ranch retention, breakthroughs and exploration
This commit is contained in:
@@ -258,15 +258,12 @@ class EggRule:
|
||||
refill_below: int = 1
|
||||
refill_target: int = 10
|
||||
market_id: str = ""
|
||||
keep_count: int = 1
|
||||
|
||||
def __post_init__(self):
|
||||
if self.action not in ("sell", "feed", "keep") or not 1 <= self.priority <= 999:
|
||||
raise ValueError("魔物蛋规则的优先级或孵化后去向无效")
|
||||
if not 0 <= self.refill_below <= 1000 or not max(1, self.refill_below) <= self.refill_target <= 1000:
|
||||
raise ValueError("补货目标不能低于补货下限,0下限表示不自动补货")
|
||||
if not 0 <= self.keep_count <= 1000:
|
||||
raise ValueError("牧场保留数量须为0至1000")
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -306,13 +303,11 @@ class Policy:
|
||||
gift_liked_only: bool = True
|
||||
gift_auto_representative: bool = False
|
||||
keep_better_quality: bool = False
|
||||
breakthrough_targets: dict[str, int] = field(default_factory=dict)
|
||||
|
||||
def __post_init__(self):
|
||||
self.egg_rules = {str(int(key)): asdict(EggRule(**rule)) for key, rule in self.egg_rules.items()}
|
||||
self.feed_targets = {str(int(key)): int(priority) for key, priority in self.feed_targets.items() if int(key) > 0 and 1 <= int(priority) <= 999}
|
||||
self.gift_targets = {str(int(key)): int(priority) for key, priority in self.gift_targets.items() if int(key) > 0 and 1 <= int(priority) <= 999}
|
||||
self.breakthrough_targets = {str(int(key)): int(priority) for key, priority in self.breakthrough_targets.items() if int(key) > 0 and 1 <= int(priority) <= 999}
|
||||
self.gift_items = {str(int(key)): {"enabled": bool(rule.get("enabled")), "reserve": max(0, int(rule.get("reserve", 0)))}
|
||||
for key, rule in self.gift_items.items()}
|
||||
|
||||
@@ -353,7 +348,7 @@ class Planner:
|
||||
quality = math.ceil(sum(qualities) / 4)
|
||||
if policy.keep_better_quality or policy.gift_auto_representative:
|
||||
representative = self.cultivation.select(snapshot).get(str(mon.get("typeId")))
|
||||
if policy.gift_auto_representative and representative and int(representative["id"]) == int(mon["id"]):
|
||||
if representative and int(representative["id"]) == int(mon["id"]):
|
||||
return "同种魔物的唯一培养代表(等级、好感、资质优先)"
|
||||
if policy.keep_better_quality:
|
||||
if representative is None:
|
||||
@@ -363,15 +358,6 @@ class Planner:
|
||||
return "同种培养代表的资质尚未同步,暂时保留"
|
||||
if candidate is not None and candidate > baseline + 1e-8:
|
||||
return f"综合成长资质高于同种培养代表 #{representative['id']}({candidate:.1%} > {baseline:.1%})"
|
||||
if policy.manual_eggs:
|
||||
rule = policy.egg_rules.get(str(mon.get("typeId")), {})
|
||||
quota = int(rule.get("keep_count", 1))
|
||||
if quota > 0 and (rule.get("action") == "keep" or policy.keep_better_quality):
|
||||
ranch = [row for row in snapshot.raw["monsters"]
|
||||
if row.get("process") == 3 and str(row.get("typeId")) == str(mon.get("typeId"))
|
||||
and int(row["id"]) != int(mon["id"])]
|
||||
if len(ranch) < quota:
|
||||
return f"同种魔物保留数量 {len(ranch) + 1} / {quota}"
|
||||
if policy.protect_quality == 6:
|
||||
return "攻/防/生命/敏捷四项资质全S(4S)" if all(q == 4 for q in qualities) else ""
|
||||
if quality >= policy.protect_quality:
|
||||
@@ -417,22 +403,6 @@ class Planner:
|
||||
target, reason = self.feeding_target(snapshot, policy)
|
||||
return target is not None, reason
|
||||
|
||||
def same_species_feeding_target(self, mon, snapshot, policy):
|
||||
"""Use an inferior duplicate to raise its ranch species before others."""
|
||||
if mon.get("process") != 3 or policy.egg_rules.get(str(mon.get("typeId")), {}).get("action") != "feed":
|
||||
return None
|
||||
candidates = [row for row in snapshot.raw["monsters"] if row.get("process") == 3
|
||||
and str(row.get("typeId")) == str(mon.get("typeId")) and int(row["id"]) != int(mon["id"])]
|
||||
candidates.sort(key=lambda row: (int(policy.feed_targets.get(str(row["id"]), 9999)),
|
||||
-int(row.get("potentialLevel") or 0), -int(row.get("level") or 1), int(row["id"])))
|
||||
for target in candidates:
|
||||
cap = self.catalog.max_level(target)
|
||||
if int(target.get("potentialLevel") or 0) >= int(self.catalog.data.get("potential_info", {}).get("maxPotentialLevel") or 0):
|
||||
continue
|
||||
if cap is not None and int(target.get("level") or 1) < cap and self.catalog.feed_remaining(target, cap) != 0:
|
||||
return target
|
||||
return None
|
||||
|
||||
def available_eggs(self, snapshot, policy):
|
||||
reserves = dict(policy.reserved_eggs)
|
||||
result = []
|
||||
@@ -572,8 +542,7 @@ class Planner:
|
||||
else:
|
||||
self.notes.append(f"{name} 等待收取:牧场没有空位")
|
||||
elif disposition == "feed" and mon.get("process") == 3:
|
||||
target = self.same_species_feeding_target(mon, snapshot, policy)
|
||||
target, reason = (target, f"优先培养未满经验的同种魔物 #{target['id']}") if target else self.feeding_target(snapshot, policy)
|
||||
target, reason = self.feeding_target(snapshot, policy)
|
||||
if target:
|
||||
actions.append(Action("feed", f"{name} #{mid} → 喂养 #{target['id']}", "monsterService/monsterIntensify", {"targetId": int(target["id"]), "foods": [mid]}))
|
||||
else:
|
||||
@@ -616,11 +585,6 @@ class Planner:
|
||||
|
||||
def batch_actions(self, actions, snapshot, policy):
|
||||
monsters = snapshot.monsters
|
||||
feeds = [a for a in actions if a.kind == "feed"]
|
||||
if feeds:
|
||||
# Feeding changes its target's level; later targets need a fresh
|
||||
# server read rather than a stale batch computed in this pass.
|
||||
actions = [a for a in actions if a.kind != "feed"] + feeds
|
||||
collects = [a for a in actions if a.kind == "collect"]
|
||||
if collects:
|
||||
rooms = {}
|
||||
|
||||
Reference in New Issue
Block a user