Implementation plan for fairness-critical cleanup and JS repair
Goals
- Restore browser boot by fixing syntax corruption in account.js and duel.js.
- Remove local pseudo-random/demo result generation from hunt and duel.
- Shift fairness-critical UI to honest pending/blocked states until chain-backed data exists.
- Keep existing app navigable and functional without pretending results are final.
- Align arena/duel entry flow with real challenge/accept/commit/reveal expectations as far as current client/state engine allow.
Implementation prompt for coding subagent
- Project: /root/ai-projects/viz-magic
- Constraints: plain JS ES5/IIFE, no build step, production-first, minimal but real fixes, no fake blockchain outcomes.
- Required changes:
- Repair corrupted syntax in app/js/blockchain/account.js and app/js/ui/screens/duel.js so the app can load in browser.
- In account.js login(), restore regular authority validation using account.regular_authority.key_auths safely, with fallback to empty array.
- In hunt.js remove Date.now/Math.random pseudoHash and any optimistic local XP/loot/result awarding before proof. Hunt should still validate mana from chain account, broadcast the hunt action, and then show an honest pending / submitted state that tells the user result and rewards require chain confirmation / block processing. Do not fabricate combat resolution.
- In broadcast.js make solo hunt mana linkage less misleading: require an auditable spend path. Minimal acceptable production fix is to reject solo hunts without npcAccount for award-backed spend, or make hunt screen block unsupported solo resolution instead of pretending mana spend/reward completion happened.
- In arena.js stop launching a duel as a fully local simulated fight. Starting a duel without a combatRef should now mean initiating or preparing a real chain challenge only.
- In duel.js remove demo/auto/random flow from fairness-critical logic: no Math.random choice selection, no _simulateOpponentReveal, no local pseudoHash round resolution, no local auto-reveal path. If chain events are unavailable, show honest waiting/blocked status.
- Keep commit/reveal path operational where possible: allow challenge creation, accept, commit, reveal broadcasts, and waiting for chain-driven duel events. Use duel state / challengeData / combatRef when available rather than simulation.
- Keep result rendering only for chain-backed roundResults already present in duel/world state. If unavailable, do not invent them.
- Add minimal i18n strings needed for honest pending/unsupported states in both ru.js and en.js.
- Update README-ru and/or plan if necessary to reduce mismatch with shipped behavior, but do not overpromise unfinished chain syncing.
- Validation:
- Run syntax checks with node --check on edited JS files.
- Search for remaining fairness-critical Math.random / pseudoHash / simulateOpponentReveal in hunt.js and duel.js; only non-gameplay randomness like sound synthesis may remain.
- Summarize changed files, checks run, and remaining risks.
Execution order
- Fix account.js syntax.
- Refactor hunt flow to submit-only honest state.
- Refactor duel screen to remove fake simulation and support real challenge/accept/reveal waiting states.
- Update arena entry points to respect honest duel flow.
- Add i18n strings.
- Run checks and note residual gaps.