Add region stage selection, eligible sweeps and daily rewards

This commit is contained in:
AttilaNet
2026-11-07 22:41:55 +08:00
parent 657f5f33b5
commit 42edc111d1
13 changed files with 1071 additions and 94 deletions
+13 -1
View File
@@ -15,6 +15,18 @@ def indexed(value, key, default=None):
return default
def stage_has_level(history, field, stage_id, level):
"""Wire histories contain difficulty ID lists; AS3 expands them to flags."""
value = indexed(history.get(field), stage_id)
if isinstance(value, dict):
return indexed(value, level, False) is True
if isinstance(value, list):
if value and all(isinstance(v, bool) or v is None for v in value):
return indexed(value, level, False) is True
return str(level) in {str(v) for v in value}
return False
def condition_ok(condition, snapshot):
if not condition:
return True
@@ -38,7 +50,7 @@ def condition_ok(condition, snapshot):
return False
for field, source in (("passStage", "passStage"), ("unlockStage", "unlockStage")):
for key in condition.get(field) or []:
if not indexed(indexed(history.get(source), key), 1, False):
if not stage_has_level(history, source, key, 1):
return False
now = datetime.fromtimestamp(snapshot.now, CN)
if condition.get("week") is not None and (now.weekday() + 1) % 7 not in condition["week"]: