Wire the seed input into GameState.run_seed #5

Merged
liamjd merged 1 commit from 2-wire-seed-input into main 2026-08-15 12:53:27 +01:00
Owner

The seed field collected a value nothing read, and New Game did nothing. Both are now wired through a single _start_new_game(), reached from NewGameBtn.pressed and SeedInput.text_submitted, so the two entry paths cannot drift.

Resolution rule:

input result
empty randi() — a fresh random each time
valid integer used literally
anything else hash(text), so word seeds like europa work

The resolved seed is echoed back into the field so the player can see and share what they are playing.

text_submitted carries a String the receiver does not need. Rather than unbind(1), it goes to a named _on_seed_submitted() that ignores the text and calls the shared function — keeping _on_new_game_pressed honest about what it handles.

max_length drops 20 → 19: is_valid_int() accepts 20 digits, but int64 tops out at 19 and to_int() would overflow.

Ordering matters

The echo must happen after resolution. Writing the previous seed into the field first overwrote the player's input before it was read — a typed seed was silently discarded on the button path while the Enter path honoured it. There is a comment on that line; it looks like a harmless reorder and is not.

Verification

Driving both paths headless:

--- typed 'europa', click New Game ---
  run_seed  = 4227705201  expected = 4227705201
  field now = '4227705201'
--- typed 'europa', press Enter ---
  run_seed  = 4227705201
  paths agree: true
--- blank field, click New Game twice ---
  first  = 154234638
  second = 154234638

The last block is the echo working as designed, not a regression: the first press fills the field, so repeat presses reuse that seed. If a blank field should reroll every time, that is a deliberate follow-up (drop the echo, or add a reroll control).

Note

print() in _start_new_game() is retained deliberately — there is no game scene yet, so the console is the only way to observe the resolved seed. It goes when the scene change lands.

Closes #2
Closes #3

The seed field collected a value nothing read, and New Game did nothing. Both are now wired through a single `_start_new_game()`, reached from `NewGameBtn.pressed` and `SeedInput.text_submitted`, so the two entry paths cannot drift. Resolution rule: | input | result | | --- | --- | | empty | `randi()` — a fresh random each time | | valid integer | used literally | | anything else | `hash(text)`, so word seeds like `europa` work | The resolved seed is echoed back into the field so the player can see and share what they are playing. `text_submitted` carries a `String` the receiver does not need. Rather than `unbind(1)`, it goes to a named `_on_seed_submitted()` that ignores the text and calls the shared function — keeping `_on_new_game_pressed` honest about what it handles. `max_length` drops 20 → 19: `is_valid_int()` accepts 20 digits, but int64 tops out at 19 and `to_int()` would overflow. ## Ordering matters The echo must happen *after* resolution. Writing the previous seed into the field first overwrote the player's input before it was read — a typed seed was silently discarded on the button path while the Enter path honoured it. There is a comment on that line; it looks like a harmless reorder and is not. ## Verification Driving both paths headless: ``` --- typed 'europa', click New Game --- run_seed = 4227705201 expected = 4227705201 field now = '4227705201' --- typed 'europa', press Enter --- run_seed = 4227705201 paths agree: true --- blank field, click New Game twice --- first = 154234638 second = 154234638 ``` The last block is the echo working as designed, not a regression: the first press fills the field, so repeat presses reuse that seed. If a blank field should reroll every time, that is a deliberate follow-up (drop the echo, or add a reroll control). ## Note `print()` in `_start_new_game()` is retained deliberately — there is no game scene yet, so the console is the only way to observe the resolved seed. It goes when the scene change lands. Closes #2 Closes #3
New Game and Enter both resolve the seed field through one shared path:
empty gives a fresh random, a valid integer is used literally, and anything
else is hashed so word seeds work. The resolved value is echoed back into
the field so the player can see and share it.

The echo has to happen after resolution - writing to the field first
overwrites the player's input before it is read.

max_length drops 20 -> 19, since is_valid_int() accepts 20 digits but
int64 tops out at 19 and to_int() would overflow.

Closes #2
Closes #3

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
liamjd merged commit 40fe4f3b51 into main 2026-08-15 12:53:27 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liamjd/UntitledColonyBuilder!5
No description provided.