@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.
@@ -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
- rngSeedInput = Math.floor(Date.now() / 1000);
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
- if (Number.isSafeInteger(saved.rngSeed) && saved.rngSeed >= 0) rngSeedInput = saved.rngSeed;
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
- rngSeed: rngSeedInput,
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
- <input
848
- class="field"
849
- id="rng-seed-input"
850
- type="number"
851
- inputmode="numeric"
852
- bind:value={rngSeedInput}
853
- min="0"
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
+ });
@@ -52,7 +52,8 @@ h1 {
52
52
  }
53
53
 
54
54
  .panel-card {
55
- @apply rounded bg-slate-300 px-6 text-center shadow-xl;
55
+ @apply overflow-y-auto overscroll-y-contain rounded bg-slate-300 px-6 text-center shadow-xl;
56
+ max-height: calc(100dvh - 2rem);
56
57
  }
57
58
 
58
59
  .panel-header {
package/package.json CHANGED
@@ -84,5 +84,5 @@
84
84
  "**/*.css"
85
85
  ],
86
86
  "type": "module",
87
- "version": "0.2.1"
87
+ "version": "0.2.2"
88
88
  }