@kuncat/avoidant 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AvoidantGame.svelte +39 -11
- package/dist/paraglide/messages/_index.d.ts +1 -0
- package/dist/paraglide/messages/_index.js +1 -0
- package/dist/paraglide/messages/action_random.d.ts +16 -0
- package/dist/paraglide/messages/action_random.js +29 -0
- package/dist/styles/global.css +2 -1
- package/package.json +1 -1
|
@@ -84,6 +84,11 @@
|
|
|
84
84
|
let voidFractionInput = $state(0.15625);
|
|
85
85
|
let spikinessInput = $state(0.8);
|
|
86
86
|
let rngSeedInput = $state(0);
|
|
87
|
+
let randomSeed = $state(true);
|
|
88
|
+
|
|
89
|
+
function resetRandomSeed() {
|
|
90
|
+
rngSeedInput = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
91
|
+
}
|
|
87
92
|
// Shape selection state. The shape kind drives which numeric inputs are shown; each per-shape numeric value persists independently so switching back and forth doesn't reset the user's edits.
|
|
88
93
|
let shapeKindInput = $state<ShapeKind>("icosahedron");
|
|
89
94
|
let playerNameInput = $state<string>(m.default_player_name());
|
|
@@ -227,7 +232,7 @@
|
|
|
227
232
|
}
|
|
228
233
|
|
|
229
234
|
onMount(() => {
|
|
230
|
-
|
|
235
|
+
resetRandomSeed();
|
|
231
236
|
relayServersInput = normalizeRelayServerList(relayServers).join("\n");
|
|
232
237
|
try {
|
|
233
238
|
playerNameInput = localStorage.getItem(PLAYER_NAME_STORAGE_KEY) ?? playerNameInput;
|
|
@@ -246,7 +251,9 @@
|
|
|
246
251
|
voidFractionInput = saved.voidFraction;
|
|
247
252
|
if (typeof saved.spikiness === "number" && saved.spikiness >= 0 && saved.spikiness <= 1)
|
|
248
253
|
spikinessInput = saved.spikiness;
|
|
249
|
-
|
|
254
|
+
randomSeed = saved.randomSeed !== false;
|
|
255
|
+
if (!randomSeed && Number.isSafeInteger(saved.rngSeed) && saved.rngSeed >= 0)
|
|
256
|
+
rngSeedInput = saved.rngSeed;
|
|
250
257
|
if (typeof saved.relayServers === "string") relayServersInput = saved.relayServers;
|
|
251
258
|
if (typeof saved.tutorialMode === "boolean") isTutorialMode = saved.tutorialMode;
|
|
252
259
|
}
|
|
@@ -296,7 +303,8 @@
|
|
|
296
303
|
numCells: numCellsInput,
|
|
297
304
|
voidFraction: voidFractionInput,
|
|
298
305
|
spikiness: spikinessInput,
|
|
299
|
-
|
|
306
|
+
randomSeed,
|
|
307
|
+
rngSeed: randomSeed ? undefined : rngSeedInput,
|
|
300
308
|
relayServers: relayServersInput,
|
|
301
309
|
tutorialMode: isTutorialMode,
|
|
302
310
|
};
|
|
@@ -409,6 +417,7 @@
|
|
|
409
417
|
let nextGameState: GameState | undefined;
|
|
410
418
|
try {
|
|
411
419
|
const relayUrls = parseRelayServersInput($state.snapshot(relayServersInput));
|
|
420
|
+
if (randomSeed) resetRandomSeed();
|
|
412
421
|
const options: GameOptions = {
|
|
413
422
|
elevationMax: 6.0,
|
|
414
423
|
elevationMin: 0.0,
|
|
@@ -844,14 +853,33 @@
|
|
|
844
853
|
<p class="field-help">{m.text_relay_servers_hint()}</p>
|
|
845
854
|
<div class="mt-6 w-full">
|
|
846
855
|
<label class="field-label" for="rng-seed-input">{m.field_seed()}</label>
|
|
847
|
-
<
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
856
|
+
<div class="mb-3 flex">
|
|
857
|
+
<input
|
|
858
|
+
class="field mb-0! min-w-0 rounded-r-none! disabled:opacity-60"
|
|
859
|
+
id="rng-seed-input"
|
|
860
|
+
type="number"
|
|
861
|
+
inputmode="numeric"
|
|
862
|
+
bind:value={rngSeedInput}
|
|
863
|
+
disabled={randomSeed}
|
|
864
|
+
min="0"
|
|
865
|
+
max={Number.MAX_SAFE_INTEGER}
|
|
866
|
+
step="1"
|
|
867
|
+
required
|
|
868
|
+
/>
|
|
869
|
+
<button
|
|
870
|
+
type="button"
|
|
871
|
+
class="btn shrink-0 rounded-l-none! text-xl"
|
|
872
|
+
class:btn-primary={randomSeed}
|
|
873
|
+
class:btn-secondary={!randomSeed}
|
|
874
|
+
title={m.action_random()}
|
|
875
|
+
aria-label={m.action_random()}
|
|
876
|
+
aria-pressed={randomSeed}
|
|
877
|
+
onclick={() => {
|
|
878
|
+
randomSeed = !randomSeed;
|
|
879
|
+
if (randomSeed) resetRandomSeed();
|
|
880
|
+
}}><span aria-hidden="true">⚄</span></button
|
|
881
|
+
>
|
|
882
|
+
</div>
|
|
855
883
|
</div>
|
|
856
884
|
</div>
|
|
857
885
|
{/if}
|
|
@@ -23,6 +23,7 @@ export * from "./field_radius_x.js";
|
|
|
23
23
|
export * from "./field_radius_y.js";
|
|
24
24
|
export * from "./field_radius_z.js";
|
|
25
25
|
export * from "./field_relay_servers.js";
|
|
26
|
+
export * from "./action_random.js";
|
|
26
27
|
export * from "./field_seed.js";
|
|
27
28
|
export * from "./field_size.js";
|
|
28
29
|
export * from "./field_spikiness.js";
|
|
@@ -25,6 +25,7 @@ export * from './field_radius_x.js'
|
|
|
25
25
|
export * from './field_radius_y.js'
|
|
26
26
|
export * from './field_radius_z.js'
|
|
27
27
|
export * from './field_relay_servers.js'
|
|
28
|
+
export * from './action_random.js'
|
|
28
29
|
export * from './field_seed.js'
|
|
29
30
|
export * from './field_size.js'
|
|
30
31
|
export * from './field_spikiness.js'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* | output |
|
|
3
|
+
* | --- |
|
|
4
|
+
* | "Random" |
|
|
5
|
+
*
|
|
6
|
+
* @param {Action_RandomInputs} inputs
|
|
7
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
8
|
+
* @returns {LocalizedString}
|
|
9
|
+
*/
|
|
10
|
+
export const action_random: ((inputs?: Action_RandomInputs, options?: {
|
|
11
|
+
locale?: "en" | "bn";
|
|
12
|
+
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Action_RandomInputs, {
|
|
13
|
+
locale?: "en" | "bn";
|
|
14
|
+
}, {}>;
|
|
15
|
+
export type LocalizedString = import("../runtime.js").LocalizedString;
|
|
16
|
+
export type Action_RandomInputs = {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
|
5
|
+
|
|
6
|
+
/** @typedef {{}} Action_RandomInputs */
|
|
7
|
+
|
|
8
|
+
const en_action_random = /** @type {(inputs: Action_RandomInputs) => LocalizedString} */ () => {
|
|
9
|
+
return /** @type {LocalizedString} */ (`Random`)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const bn_action_random = /** @type {(inputs: Action_RandomInputs) => LocalizedString} */ () => {
|
|
13
|
+
return /** @type {LocalizedString} */ (`এলোমেলো`)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* | output |
|
|
18
|
+
* | --- |
|
|
19
|
+
* | "Random" |
|
|
20
|
+
*
|
|
21
|
+
* @param {Action_RandomInputs} inputs
|
|
22
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
23
|
+
* @returns {LocalizedString}
|
|
24
|
+
*/
|
|
25
|
+
export const action_random = /** @type {((inputs?: Action_RandomInputs, options?: { locale?: "en" | "bn" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Action_RandomInputs, { locale?: "en" | "bn" }, {}>} */ ((inputs = {}, options = {}) => {
|
|
26
|
+
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
|
27
|
+
if (locale === "en") return en_action_random(inputs)
|
|
28
|
+
return bn_action_random(inputs)
|
|
29
|
+
});
|
package/dist/styles/global.css
CHANGED
package/package.json
CHANGED