prnd with world seed

This commit is contained in:
azykov@mail.ru
2026-09-09 19:52:27 +03:00
parent 7e6b50d1bc
commit e0a50aac18
9 changed files with 161 additions and 24 deletions
+10 -2
View File
@@ -53,7 +53,11 @@ export class App {
}
private showSettings(): void {
const settings = createSettingsScreen(() => this.showMenu());
const settings = createSettingsScreen(
this.store.seed,
() => this.showMenu(),
(seed) => this.handleNewGame(seed),
);
this.root.replaceChildren(settings);
}
@@ -69,7 +73,9 @@ export class App {
this.gameScreen.mount();
}
private handleNewGame(): void {
/** Starts a fresh game — a freshly random seed by default, or an explicit one when called from
* Settings' seed field (which also acts as "restart the game with this seed"). */
private handleNewGame(seed?: number): void {
// A resumable save existing means there's a live (not-dead) game being abandoned by starting
// fresh instead of continuing it — record that as the last level's failure. A death already
// records its own failure at the moment it happens (see GameStore.landRabbitStrike) and clears
@@ -77,6 +83,8 @@ export class App {
if (hasSave())
this.analytics.death('restarted');
clearSave();
if (seed !== undefined)
this.store.setNextSeed(seed);
this.showGame();
}