-
Notifications
You must be signed in to change notification settings - Fork 3
fix: every field excursion is a different field (#3) #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,6 +196,7 @@ class Runa { | |
| this.dungeonReturn = null | ||
| this.player = new Player() | ||
| this.field = null | ||
| this.excursion = 0 | ||
| this.shop = null | ||
| this.cursor = 0 | ||
| this.title = true | ||
|
|
@@ -774,7 +775,10 @@ class Runa { | |
| this.pending = null | ||
|
|
||
| if (location.kind === 'field') { | ||
| this.field = new Field({ script: this.scriptSource, player: this.player }) | ||
| this.excursion++ | ||
| const seed = | ||
| (this.excursion * 2654435761 + this.player.xp * 40503 + this.player.gold) >>> 0 | ||
| this.field = new Field({ script: this.scriptSource, player: this.player, seed }) | ||
| this.field.player.x = clampNumber(location.x, 0, this.field.width - 1) | ||
| this.field.player.y = clampNumber(location.y, 0, this.field.height - 1) | ||
| } else { | ||
|
|
@@ -1177,7 +1181,10 @@ class Runa { | |
| switch (action.kind) { | ||
| case 'travel': | ||
| if (action.to === 'field') { | ||
| this.field = new Field({ player: this.player }) | ||
| this.excursion++ | ||
| const seed = | ||
| (this.excursion * 2654435761 + this.player.xp * 40503 + this.player.gold) >>> 0 | ||
| this.field = new Field({ player: this.player, seed }) | ||
|
Comment on lines
+1184
to
+1187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| this.field.setScript(this.scriptSource) | ||
| this.say('salis de la ciudad. pulsa t para volver cuando no estes peleando') | ||
| } else if (action.to === 'dungeon') { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Quality: Seed derivation formula duplicated in two places
The identical
(this.excursion * 2654435761 + this.player.xp * 40503 + this.player.gold) >>> 0expression appears in bothloadSlot()andenter(). Duplicating the magic constants risks the two paths drifting apart. Extract a small helper (e.g.nextFieldSeed()that also doesthis.excursion++) and call it from both sites.Centralize the seed derivation so both field entry points stay in sync.:
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎