Engine.replayedTo carries each player's final faction variant over so the
replayed faction selection loads the boards the game was played with. When
the replay stops before the selection ends, the variant was left on the
player and the end of the selection loaded it on whatever faction was
picked next: undoing back into the faction selection and picking another
faction gave it the previous faction's board.
Reset the variant of players whose board isn't loaded at that point.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Engine.replayedTo rebuilds the game from the move history and only
carried each player's name, dropped flag and variant over, so
wrapper.replay reset players' auto-charge/income/brainstone settings to
the defaults, and automove ran with those defaults. BGS saves the
result of replay when a player undoes a move against bots and for admin
replays, so the settings were silently lost for good.
Carry the settings over with the other per-player data. Saved analyses
still start every player with default settings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Now the "version" field is required for variants. When the engine is created, the factionVersion field is automatically set to the latest version for the variant.
When a player choose their faction, the faction customization is stored, with the version (not used, just metadata) and now even handlers from the variant are saved (but they can't use local scope for now, they need to be pure functions).
In the engine, apart from the faction variant name & version number, nothing is stored.
During a replay, the player will load its own faction first, if not possible then the matching faction corresponding to engine's faction variant / version.