fix: rotate challenge each session

Stop hook clears active.challenge after reporting it.
Start hook assigns a random challenge from the buddy's pool if none is set.
Result: fresh challenge every session, no stale repeat.
This commit is contained in:
pyr0ball 2026-04-02 12:20:19 -07:00
parent 95ffc92e7d
commit 1930bd29bd
2 changed files with 16 additions and 1 deletions

View file

@ -101,6 +101,20 @@ if ch:
echo "${ctx}"
}
# Assign a fresh challenge if none is set
python3 << PYEOF
import json, random
catalog = json.load(open('${CATALOG}'))
active_file = '${ACTIVE_FILE}'
active = json.load(open(active_file))
buddy_id = active.get('buddymon_id')
if buddy_id and not active.get('challenge'):
pool = catalog.get('buddymon', {}).get(buddy_id, {}).get('challenges', [])
if pool:
active['challenge'] = random.choice(pool)
json.dump(active, open(active_file, 'w'), indent=2)
PYEOF
CONTEXT=$(build_context)
# Escape for JSON

View file

@ -87,12 +87,13 @@ print('\n'.join(lines))
PYEOF
)
# Reset session XP counter for next session (keep total in roster)
# Reset session XP + clear challenge so next session assigns a fresh one
python3 << PYEOF
import json
active_file = '${BUDDYMON_DIR}/active.json'
active = json.load(open(active_file))
active['session_xp'] = 0
active['challenge'] = None
json.dump(active, open(active_file, 'w'), indent=2)
PYEOF