Add ranch retention, breakthroughs and exploration
This commit is contained in:
@@ -7,6 +7,7 @@ from .daily import DailyPolicy
|
||||
from .quests import QuestPolicy
|
||||
from .sweeping import SweepPolicy
|
||||
from .progression import ProgressionPolicy
|
||||
from .exploration import ExplorePolicy
|
||||
|
||||
FORMAT = "ranch-helper-policies"
|
||||
VERSION = 1
|
||||
@@ -58,7 +59,7 @@ def portable_policy(policy, snapshot=None):
|
||||
value["feed_targets"] = {str(value["feed_target"]): 1}
|
||||
value["feed_target"] = value["room_id"] = 0
|
||||
targets = {}
|
||||
for kind, field in (("feed", "feed_targets"), ("gift", "gift_targets")):
|
||||
for kind, field in (("feed", "feed_targets"), ("gift", "gift_targets"), ("breakthrough", "breakthrough_targets")):
|
||||
targets[kind] = []
|
||||
for key, priority in sorted(value.pop(field).items(), key=lambda pair: pair[1]):
|
||||
mon = snapshot.monsters.get(int(key)) if snapshot else None
|
||||
@@ -73,8 +74,8 @@ def import_policy(value, snapshot=None):
|
||||
policy = checked_policy(Policy, value["policy"])
|
||||
policy.feed_target = policy.room_id = 0
|
||||
if snapshot:
|
||||
used = {"feed": set(), "gift": set()}
|
||||
for kind, field in (("feed", "feed_targets"), ("gift", "gift_targets")):
|
||||
used = {"feed": set(), "gift": set(), "breakthrough": set()}
|
||||
for kind, field in (("feed", "feed_targets"), ("gift", "gift_targets"), ("breakthrough", "breakthrough_targets")):
|
||||
result = {}
|
||||
targets = value.get("targetSpecies", {})
|
||||
if not isinstance(targets, dict) or not isinstance(targets.get(kind, []), list):
|
||||
@@ -90,7 +91,7 @@ def import_policy(value, snapshot=None):
|
||||
break
|
||||
setattr(policy, field, result)
|
||||
else:
|
||||
policy.feed_targets, policy.gift_targets = {}, {}
|
||||
policy.feed_targets, policy.gift_targets, policy.breakthrough_targets = {}, {}, {}
|
||||
return policy
|
||||
|
||||
|
||||
@@ -106,6 +107,7 @@ def portable_config(config, snapshot=None):
|
||||
for key, cls in (("quest_policy", QuestPolicy), ("daily_policy", DailyPolicy), ("sweep_policy", SweepPolicy)):
|
||||
value[key] = asdict(cls(**config.get(key, {})))
|
||||
value["progression_policy"] = asdict(checked_progression_policy(config.get("progression_policy", {})))
|
||||
value["explore_policy"] = ExplorePolicy.from_dict(config.get("explore_policy", {})).to_dict()
|
||||
value["interval"] = config.get("interval", 30)
|
||||
value["overrides"] = copy.deepcopy(config.get("overrides", {}))
|
||||
value["yield_stars"] = list(config.get("yield_stars", [1, 2, 3, 4, 5]))
|
||||
@@ -127,6 +129,8 @@ def import_config(value, snapshot=None):
|
||||
# An additive section preserves schema-2 compatibility with older bundles.
|
||||
if "progression_policy" in value:
|
||||
config["progression_policy"] = asdict(checked_progression_policy(value["progression_policy"]))
|
||||
if "explore_policy" in value:
|
||||
config["explore_policy"] = ExplorePolicy.from_dict(value["explore_policy"]).to_dict()
|
||||
interval = value.get("interval", 30)
|
||||
if interval not in (30, 60, 120, 300):
|
||||
raise ValueError("刷新间隔须为30、60、120或300秒")
|
||||
|
||||
Reference in New Issue
Block a user