web: seed rerolls draw from a readable range
Per Justin: a full uint32 made rerolled seeds ten digits long. Rerolls now draw 0-9999; still thousands of distinct worlds, but the advanced fields and shared URLs stay legible.
This commit is contained in:
parent
c5cbfd3eea
commit
5c4a92b5a0
1 changed files with 3 additions and 1 deletions
|
|
@ -48,10 +48,12 @@ function setField(field: keyof Config, event: Event) {
|
||||||
if (Number.isFinite(nextValue)) store.setBaseField(field, nextValue)
|
if (Number.isFinite(nextValue)) store.setBaseField(field, nextValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Seeds are just names for worlds; a small range keeps the fields and
|
||||||
|
// shared URLs readable while still giving plenty of distinct worlds.
|
||||||
function freshSeed(): number {
|
function freshSeed(): number {
|
||||||
const buffer = new Uint32Array(1)
|
const buffer = new Uint32Array(1)
|
||||||
crypto.getRandomValues(buffer)
|
crypto.getRandomValues(buffer)
|
||||||
return buffer[0] ?? 0
|
return (buffer[0] ?? 0) % 10000
|
||||||
}
|
}
|
||||||
|
|
||||||
function reroll(field: keyof Config) {
|
function reroll(field: keyof Config) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue