Refine ranch tree, growth sync and monitoring policies
This commit is contained in:
+14
-11
@@ -99,8 +99,13 @@ class Engine:
|
||||
self.read_snapshot()
|
||||
return True
|
||||
|
||||
def growth_sync_due(self):
|
||||
if self.snapshot is None:
|
||||
return False
|
||||
now = time.monotonic()
|
||||
return any(now - self.growth_attempts.get(key, -1e12) >= 60 for key in self.snapshot.growth_pending(self.catalog))
|
||||
|
||||
def sync_growth(self):
|
||||
self.auto = False
|
||||
if self.demo:
|
||||
if self.snapshot is None:
|
||||
self.snapshot = demo_snapshot(self.catalog)
|
||||
@@ -109,9 +114,9 @@ class Engine:
|
||||
mon["mode"] = self.snapshot.expected_growth_mode(mon, self.catalog)
|
||||
else:
|
||||
self.read_snapshot()
|
||||
self.settle_pending_growth(force=True)
|
||||
self.settle_pending_growth()
|
||||
pending = self.snapshot.growth_pending(self.catalog)
|
||||
message = "已同步孵化 / 成长状态;本次不执行派遣或喂养"
|
||||
message = "已自动同步孵化 / 成长状态"
|
||||
if pending:
|
||||
message += f";仍有 {len(pending)} 只等待服务器确认阶段或资质"
|
||||
return self.snapshot, self.plans(), message
|
||||
@@ -129,17 +134,15 @@ class Engine:
|
||||
if self.demo:
|
||||
if self.snapshot is None:
|
||||
self.snapshot = demo_snapshot(self.catalog)
|
||||
if self.auto and self.policy.enabled:
|
||||
for mon in self.snapshot.raw["monsters"]:
|
||||
if mon.get("process") == 2:
|
||||
mon["mode"] = self.snapshot.expected_growth_mode(mon, self.catalog)
|
||||
for mon in self.snapshot.raw["monsters"]:
|
||||
if mon.get("process") == 2:
|
||||
mon["mode"] = self.snapshot.expected_growth_mode(mon, self.catalog)
|
||||
else:
|
||||
self.read_snapshot()
|
||||
if self.auto and self.policy.enabled:
|
||||
settled = self.settle_pending_growth()
|
||||
settled = self.settle_pending_growth()
|
||||
message = "状态已刷新" + (";已请求孵化 / 成长结算" if settled else "")
|
||||
if not self.auto and self.snapshot.growth_pending(self.catalog):
|
||||
message += ";仅监控:有待结算的孵化 / 成长;请开始执行,或点击“同步孵化 / 成长”"
|
||||
if self.snapshot.growth_pending(self.catalog):
|
||||
message += ";成长状态等待服务器确认,将自动检查"
|
||||
try:
|
||||
plans = self.plans()
|
||||
except (ValueError, TypeError, KeyError, AttributeError) as error:
|
||||
|
||||
Reference in New Issue
Block a user