Improve free jump detection: add log scan as third fallback - #89
Merged
Merged
Conversation
The topology check misses cases where the free-jumped city is reachable via the normal network (e.g. Sapporo is connected to the mainland via Hakodate-Admori). Scan the game log for any Build move with freeJump:true by the player — that flag is stored in the log even on older server builds that don't track usedFreeJump in engine state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
|
If it's only on older games we can ignore & just handle new games |
coyotte508
reviewed
May 27, 2026
Comment on lines
-1045
to
1049
| // Fallback: detect from network topology for game states where | ||
| // usedFreeJump wasn't tracked (games started before that field existed). | ||
| // 2. Network topology — works when the two networks are still disconnected. | ||
| if (player.cities.length >= 2) { | ||
| return countNetworks(this.G!.map.connections, player.cities.map(c => c.name)) >= 2; | ||
| if (countNetworks(this.G!.map.connections, player.cities.map(c => c.name)) >= 2) return true; | ||
| } | ||
| // 3. Log scan — works for explicit round 2+ free jumps on older server builds | ||
| // where usedFreeJump wasn't tracked: the freeJump:true flag is still stored | ||
| // in the move data even if the engine ignored it. | ||
| if (this.G?.log) { | ||
| for (const entry of this.G.log) { | ||
| if (entry.type === 'move' && (entry as any).player === playerIndex) { | ||
| const move = (entry as any).move; | ||
| if (move?.name === MoveName.Build && move?.data?.freeJump === true) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
actually would just rely on player.usedFreeJump. For existing games, they can be cancelled or I can manually set it in db
( & would delete the countNetworks code)
Contributor
Author
|
Thanks
I've had a lot of problems with the Japan map where you have a free jump and trying to track that. I thought I was working with the most recent version in a recent game I played where I found another bug, which led to the PR below, but I could try again and see if the current version works
Mike
On Wednesday, May 27, 2026 at 02:17:13 PM PDT, Eliott C. ***@***.***> wrote:
@coyotte508 commented on this pull request.
In viewer/src/components/Game.vue:
- // Fallback: detect from network topology for game states where
- // usedFreeJump wasn't tracked (games started before that field existed).
+ // 2. Network topology — works when the two networks are still disconnected.
if (player.cities.length >= 2) {
- return countNetworks(this.G!.map.connections, player.cities.map(c => c.name)) >= 2;
+ if (countNetworks(this.G!.map.connections, player.cities.map(c => c.name)) >= 2) return true;
+ }
+ // 3. Log scan — works for explicit round 2+ free jumps on older server builds
+ // where usedFreeJump wasn't tracked: the freeJump:true flag is still stored
+ // in the move data even if the engine ignored it.
+ if (this.G?.log) {
+ for (const entry of this.G.log) {
+ if (entry.type === 'move' && (entry as any).player === playerIndex) {
+ const move = (entry as any).move;
+ if (move?.name === MoveName.Build && move?.data?.freeJump === true) {
+ return true;
+ }
+ }
+ }
}
actually would just rely on player.usedFreeJump. For existing games, they can be cancelled or I can manually set it in db
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Engine flag and topology check are sufficient now that PR boardgamers#85 is merged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ostrophes
Prettier (singleQuote: true) flips a string to double quotes when it contains
more single quotes than double quotes, to avoid escaping. The two expanded
mapSpecificRules strings used escaped single quotes ('10', 'X'), which the
prettier-check CI job rejects. Use double-quoted form so the check passes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ESLint (quotes: single) requires single quotes; Prettier flips a string to double quotes when it contains apostrophes, to avoid escaping. The two expanded mapSpecificRules strings used '10' and 'X', making the two checks mutually unsatisfiable. Remove the inner quote marks so the single-quoted strings need no escaping, satisfying both prettier-check and eslint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
goldjohn6
added a commit
that referenced
this pull request
Jun 16, 2026
…emen rules dialog (#95) * Fix Japan free jump: track usage explicitly, not via network topology Free-jump availability was gated on countNetworks(ownedCities) < 2 as a proxy for "has the player started a second network". But Power Grid networks connect *through* unowned cities, so a single intended network routinely shows as multiple components — wrongly hiding the free jump even though the player never spent it (Sapporo unreachable while the indicator still showed the jump as available). Prior fixes (#89, #94) layered more detection heuristics on top; this removes the proxy and relies solely on the explicit player.usedFreeJump flag. - available-moves: offer the jump whenever !usedFreeJump - undo: return the jump only when the undone build was the one that spent it (a round-1 second starting-city build, or a freeJump:true move), fixing a latent bug where undoing any normal build could hand the jump back once the network had become fully connected - remove the now-unused countNetworks import - add regression tests for both availability and post-use suppression Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Bremen: clarify asymmetric district-cost example, drop confusing river note The flat district-cost connection rules confused players, especially the direction-dependent (asymmetric) cost. Add a short worked example to the in-game rules dialog. Also remove the "Weser and Lesum rivers can be crossed without extra cost" line: the online map shows no rivers, so the note caused confusion rather than clarity (the zero-cost crossings remain in the map data and code comments). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The topology check misses cases where the free-jumped city is reachable via the normal network (e.g. Sapporo is connected to the mainland via Hakodate-Admori). Scan the game log for any Build move with freeJump:true by the player — that flag is stored in the log even on older server builds that don't track usedFreeJump in engine state.