@kuncat/avoidant 0.2.4 → 0.3.0

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.
Files changed (250) hide show
  1. package/README.md +29 -18
  2. package/dist/components/AvoidantGame.svelte +743 -457
  3. package/dist/components/AvoidantGame.svelte.d.ts +2 -1
  4. package/dist/components/GameHistory.svelte +103 -0
  5. package/dist/components/GameHistory.svelte.d.ts +8 -0
  6. package/dist/components/MapIcon.svelte +40 -0
  7. package/dist/components/MapIcon.svelte.d.ts +7 -0
  8. package/dist/components/MatchResults.svelte +29 -0
  9. package/dist/components/MatchResults.svelte.d.ts +8 -0
  10. package/dist/components/MultiplayerGame.svelte +504 -0
  11. package/dist/components/MultiplayerGame.svelte.d.ts +11 -0
  12. package/dist/components/OptionHelp.svelte +96 -0
  13. package/dist/components/OptionHelp.svelte.d.ts +7 -0
  14. package/dist/components/ScoreSummary.svelte +43 -0
  15. package/dist/components/ScoreSummary.svelte.d.ts +8 -0
  16. package/dist/components/board.svelte +54 -5
  17. package/dist/components/board.svelte.d.ts +4 -2
  18. package/dist/components/fragment.glsl +34 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/multiplayer/client.d.ts +21 -0
  21. package/dist/multiplayer/client.js +111 -0
  22. package/dist/multiplayer/duration.d.ts +1 -0
  23. package/dist/multiplayer/duration.js +6 -0
  24. package/dist/multiplayer/local-identity.d.ts +1 -0
  25. package/dist/multiplayer/local-identity.js +13 -0
  26. package/dist/multiplayer/maps.json +275 -0
  27. package/dist/multiplayer/reveal.d.ts +11 -0
  28. package/dist/multiplayer/reveal.js +16 -0
  29. package/dist/multiplayer/types.d.ts +80 -0
  30. package/dist/multiplayer/types.js +10 -0
  31. package/dist/paraglide/messages/_index.d.ts +103 -0
  32. package/dist/paraglide/messages/_index.js +104 -1
  33. package/dist/paraglide/messages/action_copied.d.ts +16 -0
  34. package/dist/paraglide/messages/action_copied.js +29 -0
  35. package/dist/paraglide/messages/action_copy_invitation.d.ts +16 -0
  36. package/dist/paraglide/messages/action_copy_invitation.js +29 -0
  37. package/dist/paraglide/messages/action_download_replay.d.ts +16 -0
  38. package/dist/paraglide/messages/action_download_replay.js +29 -0
  39. package/dist/paraglide/messages/action_game_history.d.ts +16 -0
  40. package/dist/paraglide/messages/action_game_history.js +29 -0
  41. package/dist/paraglide/messages/action_load_more.d.ts +16 -0
  42. package/dist/paraglide/messages/action_load_more.js +29 -0
  43. package/dist/paraglide/messages/action_login.d.ts +16 -0
  44. package/dist/paraglide/messages/action_login.js +29 -0
  45. package/dist/paraglide/messages/action_login_again.d.ts +16 -0
  46. package/dist/paraglide/messages/action_login_again.js +29 -0
  47. package/dist/paraglide/messages/action_logout.d.ts +16 -0
  48. package/dist/paraglide/messages/action_logout.js +29 -0
  49. package/dist/paraglide/messages/action_pass.d.ts +16 -0
  50. package/dist/paraglide/messages/action_pass.js +29 -0
  51. package/dist/paraglide/messages/action_reconnect.d.ts +16 -0
  52. package/dist/paraglide/messages/action_reconnect.js +29 -0
  53. package/dist/paraglide/messages/action_register.d.ts +16 -0
  54. package/dist/paraglide/messages/action_register.js +29 -0
  55. package/dist/paraglide/messages/action_save_name.d.ts +16 -0
  56. package/dist/paraglide/messages/action_save_name.js +29 -0
  57. package/dist/paraglide/messages/action_start_match.d.ts +16 -0
  58. package/dist/paraglide/messages/action_start_match.js +29 -0
  59. package/dist/paraglide/messages/error_connection_failed.d.ts +16 -0
  60. package/dist/paraglide/messages/error_connection_failed.js +29 -0
  61. package/dist/paraglide/messages/error_connection_interrupted.d.ts +16 -0
  62. package/dist/paraglide/messages/error_connection_interrupted.js +29 -0
  63. package/dist/paraglide/messages/error_history.d.ts +16 -0
  64. package/dist/paraglide/messages/error_history.js +29 -0
  65. package/dist/paraglide/messages/error_invitation_invalid.d.ts +16 -0
  66. package/dist/paraglide/messages/error_invitation_invalid.js +29 -0
  67. package/dist/paraglide/messages/error_login_to_join.d.ts +16 -0
  68. package/dist/paraglide/messages/error_login_to_join.js +29 -0
  69. package/dist/paraglide/messages/error_map_version.d.ts +16 -0
  70. package/dist/paraglide/messages/error_map_version.js +29 -0
  71. package/dist/paraglide/messages/error_match_join.d.ts +16 -0
  72. package/dist/paraglide/messages/error_match_join.js +29 -0
  73. package/dist/paraglide/messages/error_match_version.d.ts +16 -0
  74. package/dist/paraglide/messages/error_match_version.js +29 -0
  75. package/dist/paraglide/messages/error_name_not_saved.d.ts +16 -0
  76. package/dist/paraglide/messages/error_name_not_saved.js +29 -0
  77. package/dist/paraglide/messages/error_name_server_update.d.ts +16 -0
  78. package/dist/paraglide/messages/error_name_server_update.js +29 -0
  79. package/dist/paraglide/messages/error_player_name.d.ts +16 -0
  80. package/dist/paraglide/messages/error_player_name.js +29 -0
  81. package/dist/paraglide/messages/error_reconnect_to_play.d.ts +16 -0
  82. package/dist/paraglide/messages/error_reconnect_to_play.js +29 -0
  83. package/dist/paraglide/messages/error_replay.d.ts +16 -0
  84. package/dist/paraglide/messages/error_replay.js +29 -0
  85. package/dist/paraglide/messages/error_unsupported_map.d.ts +16 -0
  86. package/dist/paraglide/messages/error_unsupported_map.js +29 -0
  87. package/dist/paraglide/messages/field_bordering.d.ts +16 -0
  88. package/dist/paraglide/messages/field_bordering.js +29 -0
  89. package/dist/paraglide/messages/field_duration_unit.d.ts +16 -0
  90. package/dist/paraglide/messages/field_duration_unit.js +29 -0
  91. package/dist/paraglide/messages/field_finite_flood.d.ts +16 -0
  92. package/dist/paraglide/messages/field_finite_flood.js +29 -0
  93. package/dist/paraglide/messages/field_flood_cells.d.ts +16 -0
  94. package/dist/paraglide/messages/field_flood_cells.js +29 -0
  95. package/dist/paraglide/messages/field_flood_limit.d.ts +16 -0
  96. package/dist/paraglide/messages/field_flood_limit.js +29 -0
  97. package/dist/paraglide/messages/field_infinite_flood.d.ts +16 -0
  98. package/dist/paraglide/messages/field_infinite_flood.js +29 -0
  99. package/dist/paraglide/messages/field_invitation_link.d.ts +16 -0
  100. package/dist/paraglide/messages/field_invitation_link.js +29 -0
  101. package/dist/paraglide/messages/field_language.d.ts +16 -0
  102. package/dist/paraglide/messages/field_language.js +29 -0
  103. package/dist/paraglide/messages/field_map.d.ts +16 -0
  104. package/dist/paraglide/messages/field_map.js +29 -0
  105. package/dist/paraglide/messages/field_map_size.d.ts +1 -1
  106. package/dist/paraglide/messages/field_map_size.js +3 -3
  107. package/dist/paraglide/messages/field_match_duration.d.ts +16 -0
  108. package/dist/paraglide/messages/field_match_duration.js +29 -0
  109. package/dist/paraglide/messages/field_match_minutes.d.ts +16 -0
  110. package/dist/paraglide/messages/field_match_minutes.js +29 -0
  111. package/dist/paraglide/messages/field_play_mode.d.ts +16 -0
  112. package/dist/paraglide/messages/field_play_mode.js +29 -0
  113. package/dist/paraglide/messages/field_size.d.ts +1 -1
  114. package/dist/paraglide/messages/field_size.js +3 -3
  115. package/dist/paraglide/messages/field_turn_based.d.ts +16 -0
  116. package/dist/paraglide/messages/field_turn_based.js +29 -0
  117. package/dist/paraglide/messages/field_turn_duration.d.ts +16 -0
  118. package/dist/paraglide/messages/field_turn_duration.js +29 -0
  119. package/dist/paraglide/messages/field_turn_duration_unit.d.ts +16 -0
  120. package/dist/paraglide/messages/field_turn_duration_unit.js +29 -0
  121. package/dist/paraglide/messages/field_turn_timer.d.ts +16 -0
  122. package/dist/paraglide/messages/field_turn_timer.js +29 -0
  123. package/dist/paraglide/messages/help_bordering.d.ts +16 -0
  124. package/dist/paraglide/messages/help_bordering.js +29 -0
  125. package/dist/paraglide/messages/help_flood_limit.d.ts +16 -0
  126. package/dist/paraglide/messages/help_flood_limit.js +29 -0
  127. package/dist/paraglide/messages/help_map.d.ts +16 -0
  128. package/dist/paraglide/messages/help_map.js +29 -0
  129. package/dist/paraglide/messages/help_map_size.d.ts +16 -0
  130. package/dist/paraglide/messages/help_map_size.js +29 -0
  131. package/dist/paraglide/messages/help_match_duration.d.ts +16 -0
  132. package/dist/paraglide/messages/help_match_duration.js +29 -0
  133. package/dist/paraglide/messages/help_participation_time.d.ts +16 -0
  134. package/dist/paraglide/messages/help_participation_time.js +29 -0
  135. package/dist/paraglide/messages/help_play_mode.d.ts +16 -0
  136. package/dist/paraglide/messages/help_play_mode.js +29 -0
  137. package/dist/paraglide/messages/help_player_name.d.ts +16 -0
  138. package/dist/paraglide/messages/help_player_name.js +29 -0
  139. package/dist/paraglide/messages/help_seed.d.ts +16 -0
  140. package/dist/paraglide/messages/help_seed.js +29 -0
  141. package/dist/paraglide/messages/help_size.d.ts +16 -0
  142. package/dist/paraglide/messages/help_size.js +29 -0
  143. package/dist/paraglide/messages/help_spikiness.d.ts +16 -0
  144. package/dist/paraglide/messages/help_spikiness.js +29 -0
  145. package/dist/paraglide/messages/help_turn_based.d.ts +16 -0
  146. package/dist/paraglide/messages/help_turn_based.js +29 -0
  147. package/dist/paraglide/messages/help_turn_duration.d.ts +16 -0
  148. package/dist/paraglide/messages/help_turn_duration.js +29 -0
  149. package/dist/paraglide/messages/help_turn_time.d.ts +16 -0
  150. package/dist/paraglide/messages/help_turn_time.js +29 -0
  151. package/dist/paraglide/messages/help_turn_timer.d.ts +16 -0
  152. package/dist/paraglide/messages/help_turn_timer.js +29 -0
  153. package/dist/paraglide/messages/help_tutorial_mode.d.ts +16 -0
  154. package/dist/paraglide/messages/help_tutorial_mode.js +29 -0
  155. package/dist/paraglide/messages/help_void_fraction.d.ts +16 -0
  156. package/dist/paraglide/messages/help_void_fraction.js +29 -0
  157. package/dist/paraglide/messages/history_empty.d.ts +16 -0
  158. package/dist/paraglide/messages/history_empty.js +29 -0
  159. package/dist/paraglide/messages/label_claims.d.ts +18 -0
  160. package/dist/paraglide/messages/label_claims.js +29 -0
  161. package/dist/paraglide/messages/label_cumulative_time.d.ts +16 -0
  162. package/dist/paraglide/messages/label_cumulative_time.js +29 -0
  163. package/dist/paraglide/messages/label_custom_map_options.d.ts +16 -0
  164. package/dist/paraglide/messages/label_custom_map_options.js +29 -0
  165. package/dist/paraglide/messages/label_gameplay_options.d.ts +16 -0
  166. package/dist/paraglide/messages/label_gameplay_options.js +29 -0
  167. package/dist/paraglide/messages/label_map_options.d.ts +16 -0
  168. package/dist/paraglide/messages/label_map_options.js +29 -0
  169. package/dist/paraglide/messages/label_match_ends.d.ts +18 -0
  170. package/dist/paraglide/messages/label_match_ends.js +29 -0
  171. package/dist/paraglide/messages/label_match_id.d.ts +18 -0
  172. package/dist/paraglide/messages/label_match_id.js +29 -0
  173. package/dist/paraglide/messages/label_player_number.d.ts +18 -0
  174. package/dist/paraglide/messages/label_player_number.js +29 -0
  175. package/dist/paraglide/messages/label_points.d.ts +18 -0
  176. package/dist/paraglide/messages/label_points.js +29 -0
  177. package/dist/paraglide/messages/label_revealed_count.d.ts +18 -0
  178. package/dist/paraglide/messages/label_revealed_count.js +29 -0
  179. package/dist/paraglide/messages/label_team_score.d.ts +18 -0
  180. package/dist/paraglide/messages/label_team_score.js +29 -0
  181. package/dist/paraglide/messages/label_turn_remaining.d.ts +18 -0
  182. package/dist/paraglide/messages/label_turn_remaining.js +29 -0
  183. package/dist/paraglide/messages/label_you.d.ts +16 -0
  184. package/dist/paraglide/messages/label_you.js +29 -0
  185. package/dist/paraglide/messages/mode_collaborative.d.ts +16 -0
  186. package/dist/paraglide/messages/mode_collaborative.js +29 -0
  187. package/dist/paraglide/messages/mode_collaborative_hint.d.ts +16 -0
  188. package/dist/paraglide/messages/mode_collaborative_hint.js +29 -0
  189. package/dist/paraglide/messages/mode_solo.d.ts +16 -0
  190. package/dist/paraglide/messages/mode_solo.js +29 -0
  191. package/dist/paraglide/messages/mode_solo_hint.d.ts +16 -0
  192. package/dist/paraglide/messages/mode_solo_hint.js +29 -0
  193. package/dist/paraglide/messages/mode_territory.d.ts +16 -0
  194. package/dist/paraglide/messages/mode_territory.js +29 -0
  195. package/dist/paraglide/messages/mode_territory_hint.d.ts +16 -0
  196. package/dist/paraglide/messages/mode_territory_hint.js +29 -0
  197. package/dist/paraglide/messages/multiplayer_title.d.ts +16 -0
  198. package/dist/paraglide/messages/multiplayer_title.js +29 -0
  199. package/dist/paraglide/messages/option_help.d.ts +18 -0
  200. package/dist/paraglide/messages/option_help.js +29 -0
  201. package/dist/paraglide/messages/shape_label.d.ts +5 -5
  202. package/dist/paraglide/messages/shape_label.js +15 -15
  203. package/dist/paraglide/messages/status_connecting.d.ts +16 -0
  204. package/dist/paraglide/messages/status_connecting.js +29 -0
  205. package/dist/paraglide/messages/status_draw.d.ts +16 -0
  206. package/dist/paraglide/messages/status_draw.js +29 -0
  207. package/dist/paraglide/messages/status_match_complete.d.ts +16 -0
  208. package/dist/paraglide/messages/status_match_complete.js +29 -0
  209. package/dist/paraglide/messages/status_match_expired.d.ts +16 -0
  210. package/dist/paraglide/messages/status_match_expired.js +29 -0
  211. package/dist/paraglide/messages/status_name_saved.d.ts +16 -0
  212. package/dist/paraglide/messages/status_name_saved.js +29 -0
  213. package/dist/paraglide/messages/status_named_turn.d.ts +18 -0
  214. package/dist/paraglide/messages/status_named_turn.js +29 -0
  215. package/dist/paraglide/messages/status_named_winner.d.ts +18 -0
  216. package/dist/paraglide/messages/status_named_winner.js +29 -0
  217. package/dist/paraglide/messages/status_player_turn.d.ts +18 -0
  218. package/dist/paraglide/messages/status_player_turn.js +29 -0
  219. package/dist/paraglide/messages/status_realtime_claims.d.ts +16 -0
  220. package/dist/paraglide/messages/status_realtime_claims.js +29 -0
  221. package/dist/paraglide/messages/status_reconnecting.d.ts +16 -0
  222. package/dist/paraglide/messages/status_reconnecting.js +29 -0
  223. package/dist/paraglide/messages/status_session_complete.d.ts +16 -0
  224. package/dist/paraglide/messages/status_session_complete.js +29 -0
  225. package/dist/paraglide/messages/status_winner.d.ts +18 -0
  226. package/dist/paraglide/messages/status_winner.js +29 -0
  227. package/dist/paraglide/messages/text_account_multiplayer.d.ts +16 -0
  228. package/dist/paraglide/messages/text_account_multiplayer.js +29 -0
  229. package/dist/paraglide/messages/text_multiplayer_login.d.ts +16 -0
  230. package/dist/paraglide/messages/text_multiplayer_login.js +29 -0
  231. package/dist/paraglide/messages/text_waiting_lobby.d.ts +16 -0
  232. package/dist/paraglide/messages/text_waiting_lobby.js +29 -0
  233. package/dist/paraglide/messages/unit_hours.d.ts +16 -0
  234. package/dist/paraglide/messages/unit_hours.js +29 -0
  235. package/dist/paraglide/messages/unit_hours_selected.d.ts +19 -0
  236. package/dist/paraglide/messages/unit_hours_selected.js +35 -0
  237. package/dist/paraglide/messages/unit_minutes.d.ts +16 -0
  238. package/dist/paraglide/messages/unit_minutes.js +29 -0
  239. package/dist/paraglide/messages/unit_minutes_selected.d.ts +19 -0
  240. package/dist/paraglide/messages/unit_minutes_selected.js +35 -0
  241. package/dist/paraglide/messages/unit_seconds.d.ts +16 -0
  242. package/dist/paraglide/messages/unit_seconds.js +29 -0
  243. package/dist/paraglide/messages/unit_seconds_selected.d.ts +19 -0
  244. package/dist/paraglide/messages/unit_seconds_selected.js +35 -0
  245. package/dist/styles/global.css +12 -51
  246. package/dist/wasm/avoidant_wasm.d.ts +11 -11
  247. package/dist/wasm/avoidant_wasm.js +43 -43
  248. package/dist/wasm/avoidant_wasm_bg.wasm +0 -0
  249. package/dist/wasm/avoidant_wasm_bg.wasm.d.ts +11 -11
  250. package/package.json +6 -4
@@ -1,5 +1,12 @@
1
1
  <script lang="ts">
2
2
  import { onMount } from "svelte";
3
+ import OptionHelp from "./OptionHelp.svelte";
4
+ import ScoreSummary from "./ScoreSummary.svelte";
5
+ import MapIcon from "./MapIcon.svelte";
6
+ import GameHistory from "./GameHistory.svelte";
7
+ let historyOpen = $state(false);
8
+ import MultiplayerGame from "./MultiplayerGame.svelte";
9
+ import type { CompetitiveConfig, MultiplayerSetup } from "../multiplayer/types";
3
10
  import { devicePixelRatio } from "svelte/reactivity/window";
4
11
  import { slide } from "svelte/transition";
5
12
  import { SvelteSet } from "svelte/reactivity";
@@ -18,8 +25,15 @@
18
25
  import { generateMap } from "../workers/mapgen-client";
19
26
  import { TutorialState } from "../tutorial.svelte";
20
27
 
21
- const SETTINGS_STORAGE_KEY = "avoidant:gameSettings:v1";
22
28
  const PLAYER_NAME_STORAGE_KEY = "avoidant:playerName";
29
+ let playerNameInput = $state<string>(m.default_player_name());
30
+ let playerNameLoaded = $state(false);
31
+ $effect(() => {
32
+ if (playerNameLoaded && playerNameInput !== m.default_player_name())
33
+ localStorage.setItem(PLAYER_NAME_STORAGE_KEY, playerNameInput);
34
+ });
35
+
36
+ const SETTINGS_STORAGE_KEY = "avoidant:gameSettings:v1";
23
37
  const SIZE_PRESETS = { small: 80, medium: 160, large: 320 } as const;
24
38
 
25
39
  // Default mapshape parameters used when a preset is picked or no custom value has been entered yet.
@@ -45,35 +59,96 @@
45
59
  type SizePreset = keyof typeof SIZE_PRESETS | "custom";
46
60
  type Locale = (typeof locales)[number];
47
61
  type AvoidantGameProps = {
48
- relayServers?: string[];
62
+ competitive?: CompetitiveConfig;
49
63
  };
50
64
 
51
- let { relayServers = [] }: AvoidantGameProps = $props();
65
+ let { competitive }: AvoidantGameProps = $props();
66
+ let competitiveOpen = $state(false);
67
+ let account = $state<{ id: string; capabilities: string[] } | null>(null);
68
+ let authMessage = $state("");
69
+ let playMode = $state<"solo" | MultiplayerSetup["mode"]>("solo");
70
+ let multiplayerSetup = $state<MultiplayerSetup>();
71
+ let invitation = $state<string>();
72
+ let bordering = $state(false);
73
+ let turnBased = $state(true);
74
+ let infiniteFlood = $state(true);
75
+ let matchDuration = $state(60);
76
+ let matchUnit = $state<"minutes" | "hours">("minutes");
77
+ let turnDuration = $state(5);
78
+ let turnUnit = $state<"seconds" | "minutes">("seconds");
79
+ let turnTimer = $state(true);
80
+ let floodLimit = $state(0);
81
+ const playModes = [
82
+ { id: "solo", label: m.mode_solo, description: m.mode_solo_hint },
83
+ { id: "collaborative", label: m.mode_collaborative, description: m.mode_collaborative_hint },
84
+ { id: "territory", label: m.mode_territory, description: m.mode_territory_hint },
85
+ ] as const;
86
+ $effect(() => {
87
+ const config = competitive;
88
+ if (!config) return;
89
+ let active = true;
90
+ void (async () => {
91
+ try {
92
+ const params = new URL(window.location.href).searchParams;
93
+ const pending =
94
+ params.get("match") ??
95
+ (params.has("state") ? sessionStorage.getItem("avoidant:competitiveMatch") : null);
96
+ if (pending) sessionStorage.setItem("avoidant:competitiveMatch", pending);
97
+ await config.account.completeLogin();
98
+ const current = await config.account.account();
99
+ if (!active) return;
100
+ account = current;
101
+ if (
102
+ current?.username &&
103
+ (!localStorage.getItem(PLAYER_NAME_STORAGE_KEY) ||
104
+ localStorage.getItem(PLAYER_NAME_STORAGE_KEY) === m.default_player_name())
105
+ ) {
106
+ playerNameInput = Array.from(current.username.trim()).slice(0, 32).join("");
107
+ }
108
+ if (pending) {
109
+ invitation = pending;
110
+ ticketInput = pending;
111
+ if (current) competitiveOpen = true;
112
+ else setupMode = "join";
113
+ }
114
+ } catch (error) {
115
+ if (active) authMessage = String(error);
116
+ }
117
+ })();
118
+ return () => {
119
+ active = false;
120
+ };
121
+ });
122
+ async function login(register = false) {
123
+ try {
124
+ await competitive?.account.login(register);
125
+ } catch (error) {
126
+ authMessage = String(error);
127
+ }
128
+ }
129
+ async function logout() {
130
+ try {
131
+ await competitive?.account.logout();
132
+ account = null;
133
+ playMode = "solo";
134
+ } catch (error) {
135
+ authMessage = String(error);
136
+ }
137
+ }
138
+ function selectMode(mode: typeof playMode) {
139
+ playMode = mode;
140
+ if (mode !== "solo") {
141
+ if (sizePreset === "custom") sizePreset = "medium";
142
+ isTutorialMode = false;
143
+ }
144
+ infiniteFlood = mode === "collaborative";
145
+ }
52
146
 
53
147
  const localeLabels: Record<Locale, string> = {
54
148
  en: "English",
55
149
  bn: "বাংলা",
56
150
  };
57
151
 
58
- function normalizeRelayServerList(input: string[]): string[] {
59
- // eslint-disable-next-line svelte/prefer-svelte-reactivity
60
- const seen = new Set<string>();
61
- const urls: string[] = [];
62
- for (const item of input) {
63
- const trimmed = item.trim();
64
- if (!trimmed || seen.has(trimmed)) {
65
- continue;
66
- }
67
- seen.add(trimmed);
68
- urls.push(trimmed);
69
- }
70
- return urls;
71
- }
72
-
73
- function parseRelayServersInput(input: string): string[] {
74
- return normalizeRelayServerList(input.split(/\r?\n/));
75
- }
76
-
77
152
  let status: string | undefined = $state(undefined);
78
153
  let gameState = $state<GameState | undefined>(undefined);
79
154
  let terrain = $state<MapData["terrain"] | undefined>(undefined);
@@ -91,7 +166,6 @@
91
166
  }
92
167
  // 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.
93
168
  let shapeKindInput = $state<ShapeKind>("icosahedron");
94
- let playerNameInput = $state<string>(m.default_player_name());
95
169
  let settingsLoaded = $state(false);
96
170
  let isTutorialMode = $state(false);
97
171
  let tutorial = $state<TutorialState | undefined>(undefined);
@@ -100,18 +174,8 @@
100
174
  let setupMode: "host" | "join" | undefined = $state(undefined);
101
175
  let sizePreset = $state<SizePreset>("medium");
102
176
  let isAdvancedSettingsOpen = $state(false);
103
- let relayServersInput = $state("");
104
- let hasRelayServersConfigured = $derived(parseRelayServersInput(relayServersInput).length > 0);
105
177
  let ticketInput = $state("");
106
178
  let joinError: string | undefined = $state(undefined);
107
- let inviteTicket = $state("");
108
- let inviteUrl = $derived(
109
- inviteTicket && typeof window !== "undefined"
110
- ? `${window.location.origin}${window.location.pathname}?ticket=${encodeURIComponent(inviteTicket)}`
111
- : "",
112
- );
113
- let isGeneratingInvite = $state(false);
114
- let networkSnapshot = $derived(gameState?.networkSnapshot);
115
179
  let score = $derived(gameState?.score);
116
180
  let cellMetadataStore = $derived(gameState?.cellMetadata);
117
181
  let cellsStore = $derived(gameState?.cells);
@@ -119,12 +183,6 @@
119
183
  let numSafeUnexploredCells = $derived(
120
184
  $score ? Math.max(0, $score.totalCells - $score.voidTotal - $score.safeExplored) : 0,
121
185
  );
122
- let isScoreBreakdownHovered = $state(false);
123
- let isScoreBreakdownPinned = $state(false);
124
- let showScoreBreakdown = $derived(isScoreBreakdownHovered || isScoreBreakdownPinned);
125
- let connectedPeerCount = $derived(
126
- ($networkSnapshot?.peers ?? []).filter((peer) => peer.isConnected).length,
127
- );
128
186
  let cameraFov = $state(50);
129
187
 
130
188
  let selectedCellCount = $derived(
@@ -184,17 +242,6 @@
184
242
  ],
185
243
  );
186
244
 
187
- function toggleScoreBreakdown() {
188
- isScoreBreakdownPinned = !isScoreBreakdownPinned;
189
- }
190
-
191
- function handleScoreSummaryKeydown(event: KeyboardEvent) {
192
- if (event.key === "Enter" || event.key === " ") {
193
- event.preventDefault();
194
- toggleScoreBreakdown();
195
- }
196
- }
197
-
198
245
  /**
199
246
  * Pick a perspective FOV so the bounding sphere of the generated shape (including the maximum elevation displacement) fits the viewport on both axes, with a small margin so cells near the silhouette aren't clipped.
200
247
  */
@@ -232,10 +279,10 @@
232
279
  }
233
280
 
234
281
  onMount(() => {
282
+ playerNameInput = localStorage.getItem(PLAYER_NAME_STORAGE_KEY) || m.default_player_name();
283
+ playerNameLoaded = true;
235
284
  resetRandomSeed();
236
- relayServersInput = normalizeRelayServerList(relayServers).join("\n");
237
285
  try {
238
- playerNameInput = localStorage.getItem(PLAYER_NAME_STORAGE_KEY) ?? playerNameInput;
239
286
  const saved = JSON.parse(localStorage.getItem(SETTINGS_STORAGE_KEY) ?? "null");
240
287
  if (saved && typeof saved === "object" && !Array.isArray(saved)) {
241
288
  if (SHAPE_KINDS.includes(saved.shapeKind)) shapeKindInput = saved.shapeKind;
@@ -254,7 +301,6 @@
254
301
  randomSeed = saved.randomSeed !== false;
255
302
  if (!randomSeed && Number.isSafeInteger(saved.rngSeed) && saved.rngSeed >= 0)
256
303
  rngSeedInput = saved.rngSeed;
257
- if (typeof saved.relayServers === "string") relayServersInput = saved.relayServers;
258
304
  if (typeof saved.tutorialMode === "boolean") isTutorialMode = saved.tutorialMode;
259
305
  }
260
306
  } catch {
@@ -267,14 +313,6 @@
267
313
  status = m.status_loading();
268
314
  await init();
269
315
  status = undefined;
270
-
271
- const sharedTicket = new URLSearchParams(window.location.search).get("ticket");
272
- if (sharedTicket) {
273
- // Clear the ticket from the visible URL so a refresh doesn't re-trigger join.
274
- window.history.replaceState({}, "", `${window.location.pathname}${window.location.hash}`);
275
- ticketInput = sharedTicket;
276
- setupMode = "join";
277
- }
278
316
  } catch (error) {
279
317
  status = m.status_initialization_failed();
280
318
  console.error("Failed to initialize wasm", error);
@@ -289,12 +327,6 @@
289
327
  setInitialCameraFov();
290
328
  });
291
329
 
292
- $effect(() => {
293
- if (gameState) return;
294
- isScoreBreakdownHovered = false;
295
- isScoreBreakdownPinned = false;
296
- });
297
-
298
330
  $effect(() => {
299
331
  if (settingsLoaded) {
300
332
  const settings = {
@@ -305,11 +337,9 @@
305
337
  spikiness: spikinessInput,
306
338
  randomSeed,
307
339
  rngSeed: randomSeed ? undefined : rngSeedInput,
308
- relayServers: relayServersInput,
309
340
  tutorialMode: isTutorialMode,
310
341
  };
311
342
  try {
312
- localStorage.setItem(PLAYER_NAME_STORAGE_KEY, playerNameInput);
313
343
  localStorage.setItem(SETTINGS_STORAGE_KEY, JSON.stringify(settings));
314
344
  } catch (error) {
315
345
  console.warn("Failed to persist game settings", error);
@@ -346,33 +376,24 @@
346
376
  }
347
377
  });
348
378
 
349
- function hexCells(radius: number): string[] {
350
- const cells: string[] = [];
351
- const dx = radius * Math.sqrt(3);
352
- const dy = radius * 1.5;
353
- const size = 40;
354
- for (let row = 0; ; row++) {
355
- const cy = row * dy + radius;
356
- if (cy - radius > size) break;
357
- const xOffset = (row % 2) * (dx / 2);
358
- for (let col = 0; ; col++) {
359
- const cx = col * dx + xOffset + dx / 2;
360
- if (cx - dx / 2 > size) break;
361
- cells.push(
362
- [
363
- [cx, cy - radius],
364
- [cx + dx / 2, cy - radius / 2],
365
- [cx + dx / 2, cy + radius / 2],
366
- [cx, cy + radius],
367
- [cx - dx / 2, cy + radius / 2],
368
- [cx - dx / 2, cy - radius / 2],
369
- ]
370
- .map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`)
371
- .join(" "),
372
- );
379
+ function mosaicCells(divisions: number): string[] {
380
+ const point = (x: number, y: number) => [
381
+ (x * 40) / divisions + (x > 0 && x < divisions ? Math.sin(x * 3 + y * 7) * 2 : 0),
382
+ (y * 40) / divisions + (y > 0 && y < divisions ? Math.cos(x * 5 + y * 3) * 2 : 0),
383
+ ];
384
+ const polygons: string[] = [];
385
+ for (let y = 0; y < divisions; y++)
386
+ for (let x = 0; x < divisions; x++) {
387
+ const [a, b, c, d] = [point(x, y), point(x + 1, y), point(x + 1, y + 1), point(x, y + 1)];
388
+ for (const polygon of (x + y) % 3 === 0
389
+ ? [
390
+ [a, b, c],
391
+ [a, c, d],
392
+ ]
393
+ : [[a, b, c, d]])
394
+ polygons.push(polygon.map((p) => p.join(",")).join(" "));
373
395
  }
374
- }
375
- return cells;
396
+ return polygons;
376
397
  }
377
398
 
378
399
  type PresetIcon = {
@@ -384,21 +405,21 @@
384
405
  const presetIcons: PresetIcon[] = [
385
406
  {
386
407
  value: "small",
387
- cells: hexCells(11),
408
+ cells: mosaicCells(2),
388
409
  get label() {
389
410
  return m.preset_small();
390
411
  },
391
412
  },
392
413
  {
393
414
  value: "medium",
394
- cells: hexCells(7),
415
+ cells: mosaicCells(3),
395
416
  get label() {
396
417
  return m.preset_medium();
397
418
  },
398
419
  },
399
420
  {
400
421
  value: "large",
401
- cells: hexCells(4.5),
422
+ cells: mosaicCells(5),
402
423
  get label() {
403
424
  return m.preset_large();
404
425
  },
@@ -414,15 +435,29 @@
414
435
 
415
436
  async function startGame() {
416
437
  if (status) return;
438
+ if (playMode !== "solo") {
439
+ if (!competitive || !account || sizePreset === "custom") return;
440
+ multiplayerSetup = {
441
+ mode: playMode,
442
+ map: shapeKindInput === "icosahedron" ? sizePreset : `${shapeKindInput}-${sizePreset}`,
443
+ bordering: playMode === "territory" && bordering,
444
+ turnBased: playMode === "territory" && turnBased,
445
+ floodLimit: infiniteFlood ? null : floodLimit,
446
+ matchMinutes: matchDuration * (matchUnit === "hours" ? 60 : 1),
447
+ turnSeconds: turnTimer ? turnDuration * (turnUnit === "minutes" ? 60 : 1) : null,
448
+ };
449
+ invitation = undefined;
450
+ competitiveOpen = true;
451
+ setupMode = undefined;
452
+ return;
453
+ }
417
454
  let nextGameState: GameState | undefined;
418
455
  try {
419
- const relayUrls = parseRelayServersInput($state.snapshot(relayServersInput));
420
456
  if (randomSeed) resetRandomSeed();
421
457
  const options: GameOptions = {
422
458
  elevationMax: 6.0,
423
459
  elevationMin: 0.0,
424
460
  numCells: selectedCellCount,
425
- relayUrls: relayUrls.length > 0 ? relayUrls : undefined,
426
461
  rngSeed: $state.snapshot(rngSeedInput),
427
462
  shape: resolveShape(),
428
463
  spikiness: $state.snapshot(spikinessInput),
@@ -439,7 +474,6 @@
439
474
  terrain = generated.terrain;
440
475
  surfaceArea = generated.surfaceArea;
441
476
  boundsRadius = generated.boundsRadius;
442
- inviteTicket = "";
443
477
  exploredCellsSeen = new SvelteSet<number>();
444
478
  pendingTutorialClick = undefined;
445
479
  tutorial = isTutorialMode ? new TutorialState() : undefined;
@@ -453,71 +487,22 @@
453
487
  }
454
488
  }
455
489
 
456
- function extractTicket(input: string): string {
457
- const trimmed = input.trim();
458
- if (!trimmed) {
459
- return "";
460
- }
461
- if (/^https?:\/\//i.test(trimmed)) {
462
- try {
463
- return new URL(trimmed).searchParams.get("ticket")?.trim() ?? "";
464
- } catch {
465
- return "";
466
- }
467
- }
468
- return trimmed;
469
- }
470
-
471
- async function joinGame() {
490
+ function joinGame() {
472
491
  joinError = undefined;
473
- let succeeded = false;
492
+ if (!account || !competitive) {
493
+ joinError = m.error_login_to_join();
494
+ return;
495
+ }
474
496
  try {
475
- status = m.status_joining_game();
476
- const ticket = extractTicket(ticketInput);
477
- if (!ticket) {
478
- throw new Error(m.error_join_ticket_required());
479
- }
480
- let options: GameOptions;
481
- try {
482
- options = GameState.optionsFromTicket(ticket);
483
- } catch (error) {
484
- console.error("Failed to parse ticket", error);
485
- throw new Error(m.error_join_ticket_invalid(), { cause: error });
486
- }
487
- const nextGameState = new GameState(options);
488
- status = m.status_generating_map();
489
- const generated = await generateMap(options);
490
- nextGameState.applyMapCells(generated.cells);
491
- status = m.status_joining_game();
492
- try {
493
- await nextGameState.joinAsPeer(ticket, playerNameInput);
494
- } catch (error) {
495
- console.error("Failed to join peer", error);
496
- try {
497
- nextGameState.free();
498
- } catch (freeError) {
499
- console.error("Failed to release game state", freeError);
500
- }
501
- throw new Error(m.error_join_connect_failed(), { cause: error });
502
- }
503
- isFlatMap = options.shape?.kind === "flat";
504
- gameState = nextGameState;
505
- terrain = generated.terrain;
506
- surfaceArea = generated.surfaceArea;
507
- boundsRadius = generated.boundsRadius;
508
- inviteTicket = "";
509
- succeeded = true;
497
+ const input = ticketInput.trim();
498
+ const id = /^https?:\/\//i.test(input) ? new URL(input).searchParams.get("match") : input;
499
+ if (!id || !/^[a-f0-9-]{36}$/.test(id)) throw new Error(m.error_invitation_invalid());
500
+ invitation = id;
501
+ multiplayerSetup = undefined;
502
+ competitiveOpen = true;
503
+ setupMode = undefined;
510
504
  } catch (error) {
511
- console.error("Failed to join game", error);
512
- joinError = error instanceof Error ? error.message : m.error_join_failed();
513
- } finally {
514
- status = undefined;
515
- if (succeeded) {
516
- setupMode = undefined;
517
- ticketInput = "";
518
- } else {
519
- setupMode = "join";
520
- }
505
+ joinError = String(error);
521
506
  }
522
507
  }
523
508
 
@@ -532,7 +517,6 @@
532
517
  surfaceArea = 0;
533
518
  boundsRadius = DEFAULT_RADIUS;
534
519
  setupMode = undefined;
535
- inviteTicket = "";
536
520
  ticketInput = "";
537
521
  joinError = undefined;
538
522
  status = undefined;
@@ -540,38 +524,31 @@
540
524
  exploredCellsSeen = new SvelteSet<number>();
541
525
  pendingTutorialClick = undefined;
542
526
  }
527
+ </script>
543
528
 
544
- async function copyInviteTicket() {
545
- if (!inviteUrl) {
546
- return;
547
- }
548
- try {
549
- await navigator.clipboard.writeText(inviteUrl);
550
- } catch (error) {
551
- console.error("Failed to copy invitation URL", error);
552
- }
553
- }
529
+ {#if historyOpen && competitive}<GameHistory
530
+ config={competitive}
531
+ onexit={() => (historyOpen = false)}
532
+ />{/if}
554
533
 
555
- async function generateInvite() {
556
- if (isGeneratingInvite) {
557
- return;
558
- }
559
- isGeneratingInvite = true;
560
- try {
561
- inviteTicket = (await gameState?.invite(playerNameInput)) ?? "";
562
- if (inviteTicket) {
563
- await copyInviteTicket();
564
- }
565
- } catch (error) {
566
- console.error("Failed to create invitation", error);
567
- } finally {
568
- isGeneratingInvite = false;
569
- }
570
- }
571
- </script>
534
+ {#if competitiveOpen && competitive}
535
+ <MultiplayerGame
536
+ bind:playerName={playerNameInput}
537
+ config={competitive}
538
+ setup={multiplayerSetup}
539
+ {invitation}
540
+ onexit={() => {
541
+ competitiveOpen = false;
542
+ multiplayerSetup = undefined;
543
+ invitation = undefined;
544
+ }}
545
+ />
546
+ {/if}
572
547
 
573
548
  <div
574
- class="panel-wrapper fixed inset-x-0 z-20 flex justify-center select-none"
549
+ data-theme="winter"
550
+ class="panel-wrapper fixed inset-x-0 z-20 flex justify-center bg-transparent select-none"
551
+ style:display={historyOpen || (competitiveOpen && competitive) ? "none" : undefined}
575
552
  class:[&_*]:text-white={gameState}
576
553
  class:panel-wrapper-card={!gameState}
577
554
  class:panel-wrapper-header={gameState}
@@ -581,7 +558,7 @@
581
558
  <div
582
559
  class="panel-shell w-full"
583
560
  class:max-w-full={gameState}
584
- class:max-w-md={!gameState && setupMode}
561
+ class:max-w-xl={!gameState && setupMode}
585
562
  class:max-w-xs={!gameState && !setupMode}
586
563
  class:panel-card={!gameState}
587
564
  class:panel-header={gameState}
@@ -599,24 +576,8 @@
599
576
  </h1>
600
577
  {#if gameState}
601
578
  {#if $score}
602
- <div
603
- class="relative text-sm text-slate-600"
604
- role="group"
605
- aria-label={m.aria_score_summary()}
606
- onmouseenter={() => (isScoreBreakdownHovered = true)}
607
- onmouseleave={() => (isScoreBreakdownHovered = false)}
608
- >
609
- <div
610
- class="score-summary"
611
- role="button"
612
- tabindex="0"
613
- aria-expanded={showScoreBreakdown}
614
- aria-controls="score-breakdown"
615
- onclick={toggleScoreBreakdown}
616
- onfocus={() => (isScoreBreakdownHovered = true)}
617
- onblur={() => (isScoreBreakdownHovered = false)}
618
- onkeydown={handleScoreSummaryKeydown}
619
- >
579
+ <ScoreSummary>
580
+ {#snippet summary()}
620
581
  {m.label_score()}:
621
582
  <strong class="text-slate-200!"
622
583
  >{Math.round($score.score).toLocaleString(getLocale())}</strong
@@ -639,61 +600,53 @@
639
600
  >
640
601
  </span>
641
602
  {/if}
642
- </div>
643
-
644
- {#if showScoreBreakdown}
645
- <div id="score-breakdown" class="score-breakdown" role="status">
646
- {#if $score.streak > 1}<p>
647
- <span class="opacity-70"
648
- >×{(1 + Math.min($score.streak, 10) * 0.1).toLocaleString(getLocale(), {
649
- maximumFractionDigits: 1,
650
- })}
651
- {m.label_streak()}</span
652
- >
653
- </p>
654
- {/if}
655
- <p class="text-emerald-600!">
656
- {m.label_safe_cells_explored({
657
- count: $score.safeExplored.toLocaleString(getLocale()),
658
- })}:
659
- <strong>{$score.safeExplored.toLocaleString(getLocale())}</strong>
660
- </p>
661
- <p class="text-rose-500!">
662
- {m.label_voids_discovered()}:
663
- <strong>{$score.voidExplored.toLocaleString(getLocale())}</strong>
603
+ {/snippet}
604
+ {#snippet breakdown()}
605
+ {#if $score.streak > 1}<p>
606
+ <span class="opacity-70"
607
+ >×{(1 + Math.min($score.streak, 10) * 0.1).toLocaleString(getLocale(), {
608
+ maximumFractionDigits: 1,
609
+ })}
610
+ {m.label_streak()}</span
611
+ >
664
612
  </p>
665
- </div>
666
- {/if}
667
- </div>
668
- {/if}
669
- <div class="ml-auto text-sm text-slate-200!">
670
- {#if connectedPeerCount > 0}
671
- {m.label_players({ count: connectedPeerCount + 1 })}:
672
- <strong>{connectedPeerCount + 1}</strong>
673
- {/if}
674
- </div>
675
- <div class="flex gap-2">
676
- {#if !isTutorialMode && hasRelayServersConfigured}
677
- <button
678
- class="btn btn-primary"
679
- type="button"
680
- onclick={generateInvite}
681
- disabled={isGeneratingInvite || ($score?.safeExplored ?? 0) === 0}
682
- title={($score?.safeExplored ?? 0) === 0 ? m.text_invite_after_opening() : undefined}
683
- >
684
- {#if isGeneratingInvite}
685
- <span class="spinner" aria-hidden="true"></span>
686
- <span>{m.status_preparing()}</span>
687
- {:else}
688
- {m.action_invite()}
689
613
  {/if}
690
- </button>
691
- {/if}
692
- <button class="btn btn-danger" type="button" onclick={exitGame}>{m.action_exit()}</button>
614
+ <p class="text-emerald-600!">
615
+ {m.label_safe_cells_explored({
616
+ count: $score.safeExplored.toLocaleString(getLocale()),
617
+ })}:
618
+ <strong>{$score.safeExplored.toLocaleString(getLocale())}</strong>
619
+ </p>
620
+ <p class="text-rose-500!">
621
+ {m.label_voids_discovered()}:
622
+ <strong>{$score.voidExplored.toLocaleString(getLocale())}</strong>
623
+ </p>
624
+ {/snippet}
625
+ </ScoreSummary>
626
+ {/if}
627
+ <div class="ml-auto flex gap-2">
628
+ <button class="btn btn-error" type="button" onclick={exitGame}>{m.action_exit()}</button>
693
629
  </div>
694
630
  {/if}
695
631
  </div>
696
632
 
633
+ {#if !gameState}
634
+ <div class="my-3 flex flex-wrap justify-center gap-2">
635
+ {#if account}<button class="btn btn-secondary btn-sm" onclick={() => (historyOpen = true)}
636
+ >{m.action_game_history()}</button
637
+ ><button class="btn btn-secondary btn-sm" onclick={logout}>{m.action_logout()}</button>
638
+ {:else}<button
639
+ class="btn btn-secondary btn-sm"
640
+ disabled={!competitive}
641
+ onclick={() => login()}>{m.action_login()}</button
642
+ ><button
643
+ class="btn btn-secondary btn-sm"
644
+ disabled={!competitive}
645
+ onclick={() => login(true)}>{m.action_register()}</button
646
+ >{/if}
647
+ </div>
648
+ {#if authMessage}<p role="status" class="text-sm">{authMessage}</p>{/if}
649
+ {/if}
697
650
  {#if status}
698
651
  <p class="mt-2 text-sm text-slate-600!">{status}</p>
699
652
  {/if}
@@ -710,189 +663,526 @@
710
663
  >
711
664
  <div class="-mx-3 mb-2 flex flex-wrap">
712
665
  <div class="mb-4 w-full px-3">
713
- <label class="field-label" for="player-name">{m.field_player_name()}</label>
714
- <input class="field" id="player-name" type="text" bind:value={playerNameInput} />
715
- </div>
716
- <div class="mb-4 w-full px-3">
717
- <label class="field-label" for="shape-select">{m.field_map_shape()}</label>
718
- <select id="shape-select" class="field" bind:value={shapeKindInput}>
719
- {#each SHAPE_KINDS as kind (kind)}
720
- <option value={kind}>{m.shape_label({ kind })}</option>
721
- {/each}
722
- </select>
723
- </div>
724
- <div class="mb-4 w-full px-3">
725
- <span class="field-label">{m.field_map_size()}</span>
726
- <div class="grid grid-cols-4 gap-2">
727
- {#each presetIcons as preset (preset.value)}
666
+ <span class="field-label"
667
+ ><OptionHelp label={m.field_play_mode()} help={m.help_play_mode()} /></span
668
+ >
669
+ <div class="grid grid-cols-3 gap-2">
670
+ {#each playModes as mode (mode.id)}
728
671
  <button
729
672
  type="button"
730
- class="preset-btn"
731
- class:preset-btn-active={sizePreset === preset.value}
732
- aria-pressed={sizePreset === preset.value}
733
- onclick={() => (sizePreset = preset.value)}
673
+ class="btn h-auto min-h-28 flex-col gap-1 py-3 font-normal disabled:bg-base-200 disabled:text-base-content/60 disabled:opacity-100"
674
+ class:btn-primary={playMode === mode.id}
675
+ aria-pressed={playMode === mode.id}
676
+ disabled={mode.id !== "solo" && (!account || !competitive)}
677
+ onclick={() => selectMode(mode.id)}
734
678
  >
735
- <span class="preset-icon">
736
- {#if preset.cells}
737
- <svg
738
- viewBox="0 0 40 40"
739
- fill="none"
740
- stroke="currentColor"
741
- stroke-width="1"
742
- stroke-linejoin="round"
743
- aria-hidden="true"
744
- >
745
- {#each preset.cells as points, i (i)}
746
- <polygon {points} />
747
- {/each}
748
- </svg>
749
- {:else}
750
- <svg
751
- viewBox="0 0 40 40"
752
- fill="none"
753
- stroke="currentColor"
754
- stroke-width="2.5"
755
- stroke-linecap="round"
756
- aria-hidden="true"
757
- >
758
- <line x1="8" y1="12" x2="32" y2="12" />
759
- <circle cx="15" cy="12" r="3.5" fill="currentColor" />
760
- <line x1="8" y1="20" x2="32" y2="20" />
761
- <circle cx="25" cy="20" r="3.5" fill="currentColor" />
762
- <line x1="8" y1="28" x2="32" y2="28" />
763
- <circle cx="19" cy="28" r="3.5" fill="currentColor" />
764
- </svg>
765
- {/if}
766
- </span>
767
- <span class="preset-label">{preset.label}</span>
768
- <span class="preset-count">
769
- {preset.value === "custom"
770
- ? ""
771
- : m.cells_count({ count: SIZE_PRESETS[preset.value] })}
772
- </span>
679
+ <span class="preset-icon"
680
+ ><svg
681
+ viewBox="0 0 40 40"
682
+ fill="none"
683
+ stroke="currentColor"
684
+ stroke-width="1.6"
685
+ aria-hidden="true"
686
+ >
687
+ {#if mode.id === "solo"}<circle cx="20" cy="10" r="5" /><path
688
+ d="M9 34v-8a11 11 0 0 1 22 0v8M15 25l5 5 5-5"
689
+ />
690
+ {:else if mode.id === "collaborative"}<circle
691
+ cx="12"
692
+ cy="10"
693
+ r="4"
694
+ /><circle cx="28" cy="10" r="4" /><path
695
+ d="M5 26v-5a7 7 0 0 1 14 0v5M21 26v-5a7 7 0 0 1 14 0v5M12 29h16M20 24v10"
696
+ />
697
+ {:else}<path
698
+ d="M4 5h15v13H4zM21 5h15v13H21zM4 20h15v15H4zM21 20h15v15H21zM7 14l9-6M24 31l9-7"
699
+ />{/if}
700
+ </svg></span
701
+ >
702
+ <span class="preset-label">{mode.label()}</span><span class="text-xs"
703
+ >{mode.description()}</span
704
+ >
773
705
  </button>
774
706
  {/each}
775
707
  </div>
708
+ {#if !account}<p class="field-help mt-2">
709
+ {m.text_multiplayer_login()}
710
+ </p>{/if}
776
711
  </div>
777
- {#if sizePreset === "custom"}
778
- <div class="mb-4 w-full px-3">
779
- <label class="field-label" for="size-input">{m.field_size()}</label>
780
712
 
781
- <input
782
- class="field"
783
- id="size-input"
784
- type="number"
785
- required
786
- min="32"
787
- max="5000"
788
- step="1"
789
- bind:value={numCellsInput}
790
- />
791
- </div>
792
- {/if}
793
- <p class="field-help mb-4 w-full px-3">
794
- {usesFaceDensity
795
- ? m.text_density_summary({ faces: faceCount, count: selectedCellCount })
796
- : m.cells_count({ count: selectedCellCount })}
797
- </p>
798
- <div class="mb-4 w-full px-3">
799
- <div class="advanced-settings" class:advanced-settings-open={isAdvancedSettingsOpen}>
800
- <button
801
- type="button"
802
- class="advanced-settings-summary w-full"
803
- aria-expanded={isAdvancedSettingsOpen}
804
- aria-controls="advanced-settings-content"
805
- onclick={() => (isAdvancedSettingsOpen = !isAdvancedSettingsOpen)}
713
+ <fieldset
714
+ class="mx-3 mb-6 fieldset min-w-0 flex-1 rounded-lg border border-secondary px-4 pb-4"
715
+ transition:slide={{ duration: 180 }}
716
+ >
717
+ <legend class="fieldset-legend">{m.label_gameplay_options()}</legend>
718
+ {#if playMode !== "solo"}
719
+ <label
720
+ class="label w-full justify-between gap-4 text-left whitespace-normal text-base-content"
806
721
  >
807
- {m.label_advanced_settings()}
808
- </button>
809
- {#if isAdvancedSettingsOpen}
810
- <div
811
- id="advanced-settings-content"
812
- class="advanced-settings-content"
813
- transition:slide={{ duration: 180 }}
722
+ <span
723
+ ><OptionHelp label={m.field_player_name()} help={m.help_player_name()} /></span
814
724
  >
815
- <label class="field-label" for="void-fraction-input"
816
- >{m.field_void_fraction()}</label
817
- >
725
+ <input
726
+ class="input w-30 min-w-0 text-right input-sm"
727
+ type="text"
728
+ maxlength="32"
729
+ required
730
+ aria-label={m.field_player_name()}
731
+ bind:value={playerNameInput}
732
+ />
733
+ </label>
734
+ {/if}
735
+ {#if playMode !== "solo"}
736
+ <div class="flex w-full items-center justify-between gap-4">
737
+ <label
738
+ class="label text-left whitespace-normal text-base-content"
739
+ for="match-duration"
740
+ ><OptionHelp
741
+ label={m.field_match_duration()}
742
+ help={m.help_match_duration()}
743
+ /></label
744
+ >
745
+ <div class="join w-36 shrink-0">
818
746
  <input
819
- class="field mb-3"
820
- id="void-fraction-input"
747
+ id="match-duration"
748
+ class="input join-item min-w-0 flex-1 text-right input-sm"
821
749
  type="number"
750
+ min="1"
751
+ max={matchUnit === "hours" ? 24 : 1440}
752
+ step="1"
822
753
  required
823
- min="0"
824
- max="0.999"
825
- step="0.00001"
826
- bind:value={voidFractionInput}
754
+ aria-label={m.field_match_duration()}
755
+ bind:value={matchDuration}
827
756
  />
828
- <label class="field-label" for="spikiness-input">{m.field_spikiness()}</label>
757
+ <div class="relative join-item w-24 shrink-0 border-0">
758
+ <select
759
+ class="duration-unit-select select w-full rounded-l-none select-sm"
760
+ aria-label={m.field_duration_unit()}
761
+ value={matchUnit}
762
+ onchange={(event) => {
763
+ const unit = event.currentTarget.value as "minutes" | "hours";
764
+ const minutes = matchDuration * (matchUnit === "hours" ? 60 : 1);
765
+ matchDuration = Math.min(
766
+ unit === "hours" ? 24 : 1440,
767
+ Math.max(1, Math.ceil(unit === "hours" ? minutes / 60 : minutes)),
768
+ );
769
+ matchUnit = unit;
770
+ }}
771
+ ><option value="minutes">{m.unit_minutes()}</option><option value="hours"
772
+ >{m.unit_hours()}</option
773
+ ></select
774
+ >
775
+ <span
776
+ aria-hidden="true"
777
+ class="pointer-events-none absolute inset-y-0 left-3 flex items-center text-sm text-base-content"
778
+ >
779
+ {matchUnit === "hours"
780
+ ? m.unit_hours_selected({ count: matchDuration ?? 0 })
781
+ : m.unit_minutes_selected({ count: matchDuration ?? 0 })}
782
+ </span>
783
+ </div>
784
+ </div>
785
+ </div>
786
+ {/if}
787
+ {#if playMode === "solo"}
788
+ <div class="flex flex-col items-start gap-2" transition:slide={{ duration: 180 }}>
789
+ <label
790
+ class="label w-full justify-between gap-4 text-left whitespace-normal text-base-content"
791
+ for="tutorial-mode"
792
+ >
793
+ <span
794
+ ><OptionHelp
795
+ label={m.field_tutorial_mode()}
796
+ help={m.help_tutorial_mode()}
797
+ /></span
798
+ >
829
799
  <input
830
- class="field mb-3"
831
- id="spikiness-input"
832
- type="number"
833
- required
834
- min="0"
835
- max="1"
836
- step="0.05"
837
- bind:value={spikinessInput}
800
+ id="tutorial-mode"
801
+ type="checkbox"
802
+ class="checkbox shrink-0 rounded-sm checkbox-sm checkbox-primary"
803
+ aria-label={m.field_tutorial_mode()}
804
+ bind:checked={isTutorialMode}
805
+ disabled={sizePreset === "custom"}
838
806
  />
839
- <label class="field-label" for="relay-servers"
840
- ><a
841
- href="https://docs.iroh.computer/deployment/dedicated-infrastructure"
842
- target="_blank"
843
- rel="noopener noreferrer">{m.field_relay_servers()}</a
844
- ></label
807
+ </label>
808
+ </div>
809
+ {/if}
810
+ {#if playMode !== "solo"}
811
+ {#if playMode === "territory"}
812
+ <div class="flex flex-col items-start gap-2" transition:slide={{ duration: 180 }}>
813
+ <div
814
+ class="form-control flex w-full flex-row items-center justify-between gap-4"
815
+ >
816
+ <label
817
+ class="label w-full justify-between gap-4 text-left whitespace-normal text-base-content"
818
+ ><span
819
+ ><OptionHelp
820
+ label={m.field_bordering()}
821
+ help={m.help_bordering()}
822
+ /></span
823
+ ><input
824
+ type="checkbox"
825
+ class="checkbox shrink-0 rounded-sm checkbox-sm checkbox-primary"
826
+ aria-label={m.field_bordering()}
827
+ bind:checked={bordering}
828
+ /></label
829
+ >
830
+ </div>
831
+ <div
832
+ class="form-control flex w-full flex-row items-center justify-between gap-4"
845
833
  >
846
- <textarea
847
- class="field field-textarea mb-1"
848
- id="relay-servers"
849
- bind:value={relayServersInput}
850
- rows="4"
851
- spellcheck="false"></textarea>
852
- <p class="field-help">{m.text_relay_servers_hint()}</p>
853
- <div class="mt-6 w-full">
854
- <label class="field-label" for="rng-seed-input">{m.field_seed()}</label>
855
- <div class="mb-3 flex">
856
- <input
857
- class="field mb-0! min-w-0 rounded-r-none! disabled:opacity-60"
858
- id="rng-seed-input"
859
- type="number"
860
- inputmode="numeric"
861
- bind:value={rngSeedInput}
862
- disabled={randomSeed}
863
- min="0"
864
- max={Number.MAX_SAFE_INTEGER}
865
- step="1"
866
- required
867
- />
868
- <button
869
- type="button"
870
- class="btn shrink-0 rounded-l-none! text-xl"
871
- class:btn-primary={randomSeed}
872
- class:btn-secondary={!randomSeed}
873
- title={m.action_random()}
874
- aria-label={m.action_random()}
875
- aria-pressed={randomSeed}
876
- onclick={() => {
877
- randomSeed = !randomSeed;
878
- if (randomSeed) resetRandomSeed();
879
- }}><span aria-hidden="true">⚄</span></button
834
+ <label
835
+ class="label w-full justify-between gap-4 text-left whitespace-normal text-base-content"
836
+ ><span
837
+ ><OptionHelp
838
+ label={m.field_turn_based()}
839
+ help={m.help_turn_based()}
840
+ /></span
841
+ ><input
842
+ type="checkbox"
843
+ class="checkbox shrink-0 rounded-sm checkbox-sm checkbox-primary"
844
+ aria-label={m.field_turn_based()}
845
+ bind:checked={turnBased}
846
+ /></label
847
+ >
848
+ </div>
849
+ </div>
850
+ {/if}
851
+ {#if playMode === "territory" && turnBased}
852
+ <div class="grid gap-2" transition:slide={{ duration: 180 }}>
853
+ <label
854
+ class="label w-full justify-between gap-4 text-left whitespace-normal text-base-content"
855
+ ><span
856
+ ><OptionHelp
857
+ label={m.field_turn_timer()}
858
+ help={m.help_turn_timer()}
859
+ /></span
860
+ ><input
861
+ type="checkbox"
862
+ class="checkbox shrink-0 rounded-sm checkbox-sm checkbox-primary"
863
+ aria-label={m.field_turn_timer()}
864
+ bind:checked={turnTimer}
865
+ /></label
866
+ >
867
+ {#if turnTimer}
868
+ <div
869
+ class="flex w-full items-center justify-between gap-4"
870
+ transition:slide={{ duration: 180 }}
871
+ >
872
+ <label
873
+ class="label text-left whitespace-normal text-base-content"
874
+ for="turn-duration"
880
875
  >
876
+ <OptionHelp
877
+ label={m.field_turn_duration()}
878
+ help={m.help_turn_duration()}
879
+ />
880
+ </label>
881
+ <div class="join w-36 shrink-0">
882
+ <input
883
+ id="turn-duration"
884
+ class="input join-item min-w-0 flex-1 text-right input-sm"
885
+ type="number"
886
+ min="1"
887
+ max={turnUnit === "minutes" ? 1440 : 86400}
888
+ step="1"
889
+ required
890
+ aria-label={m.field_turn_duration()}
891
+ bind:value={turnDuration}
892
+ />
893
+ <div class="relative join-item w-24 shrink-0 border-0">
894
+ <select
895
+ class="duration-unit-select select w-full rounded-l-none select-sm"
896
+ aria-label={m.field_turn_duration_unit()}
897
+ value={turnUnit}
898
+ onchange={(event) => {
899
+ const unit = event.currentTarget.value as "seconds" | "minutes";
900
+ const seconds = turnDuration * (turnUnit === "minutes" ? 60 : 1);
901
+ turnDuration = Math.min(
902
+ unit === "minutes" ? 1440 : 86400,
903
+ Math.max(
904
+ 1,
905
+ Math.ceil(unit === "minutes" ? seconds / 60 : seconds),
906
+ ),
907
+ );
908
+ turnUnit = unit;
909
+ }}
910
+ >
911
+ <option value="seconds">{m.unit_seconds()}</option>
912
+ <option value="minutes">{m.unit_minutes()}</option>
913
+ </select>
914
+ <span
915
+ aria-hidden="true"
916
+ class="pointer-events-none absolute inset-y-0 left-3 flex items-center text-sm text-base-content"
917
+ >
918
+ {turnUnit === "minutes"
919
+ ? m.unit_minutes_selected({ count: turnDuration ?? 0 })
920
+ : m.unit_seconds_selected({ count: turnDuration ?? 0 })}
921
+ </span>
922
+ </div>
923
+ </div>
881
924
  </div>
882
- </div>
925
+ {/if}
883
926
  </div>
884
927
  {/if}
928
+ <div class="form-control flex w-full flex-row items-center justify-between gap-4">
929
+ <label
930
+ class="label text-left whitespace-normal text-base-content"
931
+ for="flood-limit"
932
+ ><OptionHelp label={m.field_flood_limit()} help={m.help_flood_limit()} /></label
933
+ >
934
+ <div class="join w-24 shrink-0" role="group" aria-label={m.field_flood_limit()}>
935
+ <input
936
+ id="flood-limit"
937
+ class="input join-item min-w-0 flex-1 text-right input-sm focus:outline-none"
938
+ aria-label={m.field_flood_cells()}
939
+ type="number"
940
+ min={infiniteFlood ? undefined : 0}
941
+ max={infiniteFlood ? undefined : 4096}
942
+ step="1"
943
+ required={!infiniteFlood}
944
+ class:input-ghost={infiniteFlood}
945
+ class:border-base-300={infiniteFlood}
946
+ class:border-2={!infiniteFlood}
947
+ class:input-primary={!infiniteFlood}
948
+ bind:value={floodLimit}
949
+ onclick={() => (infiniteFlood = false)}
950
+ />
951
+ <button
952
+ type="button"
953
+ class="btn join-item btn-sm"
954
+ class:btn-primary={infiniteFlood}
955
+ class:btn-outline={!infiniteFlood}
956
+ class:border-base-300={!infiniteFlood}
957
+ aria-label={m.field_infinite_flood()}
958
+ aria-pressed={infiniteFlood}
959
+ onclick={() => (infiniteFlood = true)}
960
+ ><span aria-hidden="true" class="text-xl">∞</span></button
961
+ >
962
+ </div>
963
+ </div>
964
+ {/if}
965
+ </fieldset>
966
+ <div class="mb-4 w-full px-3" role="group" aria-label={m.field_map()}>
967
+ <span id="map-label" class="field-label"
968
+ ><OptionHelp label={m.field_map()} help={m.help_map()} /></span
969
+ >
970
+ <div class="grid grid-cols-2 gap-2 sm:grid-cols-4">
971
+ {#each SHAPE_KINDS as kind (kind)}
972
+ <button
973
+ type="button"
974
+ class="btn h-auto min-h-28 min-w-0 flex-col gap-2 px-2 py-3 font-normal"
975
+ class:btn-primary={shapeKindInput === kind}
976
+ aria-pressed={shapeKindInput === kind}
977
+ onclick={() => (shapeKindInput = kind)}
978
+ >
979
+ <span class="preset-icon"><MapIcon {kind} /></span>
980
+ <span class="text-xs whitespace-normal">{m.shape_label({ kind })}</span>
981
+ </button>
982
+ {/each}
885
983
  </div>
886
984
  </div>
887
- <div class="checkbox-field mb-4 flex w-full items-center gap-2 px-3">
888
- <label class="field-label mb-0!" for="tutorial-mode">{m.field_tutorial_mode()}</label>
889
- <input
890
- id="tutorial-mode"
891
- type="checkbox"
892
- bind:checked={isTutorialMode}
893
- disabled={sizePreset === "custom"}
894
- />
895
- </div>
985
+ <fieldset
986
+ class="mx-3 mb-6 fieldset w-full min-w-0 rounded-lg border border-secondary px-3"
987
+ transition:slide={{ duration: 180 }}
988
+ >
989
+ <legend class="fieldset-legend">{m.label_map_options()}</legend>
990
+ <div class="w-full">
991
+ <span class="field-label"
992
+ ><OptionHelp label={m.field_map_size()} help={m.help_map_size()} /></span
993
+ >
994
+ <div class="grid grid-cols-4 gap-2">
995
+ {#each presetIcons as preset (preset.value)}
996
+ <button
997
+ type="button"
998
+ class="btn h-auto min-h-24 flex-col gap-1 py-3 font-normal"
999
+ class:btn-primary={sizePreset === preset.value}
1000
+ disabled={playMode !== "solo" && preset.value === "custom"}
1001
+ aria-pressed={sizePreset === preset.value}
1002
+ onclick={() => (sizePreset = preset.value)}
1003
+ >
1004
+ <span class="preset-icon">
1005
+ {#if preset.cells}
1006
+ <svg
1007
+ viewBox="0 0 40 40"
1008
+ fill="none"
1009
+ stroke="currentColor"
1010
+ stroke-width="1"
1011
+ stroke-linejoin="round"
1012
+ aria-hidden="true"
1013
+ >
1014
+ {#each preset.cells as points, i (i)}
1015
+ <polygon {points} />
1016
+ {/each}
1017
+ </svg>
1018
+ {:else}
1019
+ <svg
1020
+ viewBox="0 0 40 40"
1021
+ fill="none"
1022
+ stroke="currentColor"
1023
+ stroke-width="2"
1024
+ stroke-linecap="round"
1025
+ aria-hidden="true"
1026
+ >
1027
+ <line x1="8" y1="10" x2="32" y2="10" />
1028
+ <circle cx="15" cy="10" r="1.5" fill="currentColor" />
1029
+ <line x1="8" y1="20" x2="32" y2="20" />
1030
+ <circle cx="25" cy="20" r="1.5" fill="currentColor" />
1031
+ <line x1="8" y1="30" x2="32" y2="30" />
1032
+ <circle cx="19" cy="30" r="1.5" fill="currentColor" />
1033
+ </svg>
1034
+ {/if}
1035
+ </span>
1036
+ <span class="preset-label">{preset.label}</span>
1037
+ <span class="preset-count">
1038
+ {preset.value === "custom"
1039
+ ? ""
1040
+ : m.cells_count({ count: SIZE_PRESETS[preset.value] })}
1041
+ </span>
1042
+ </button>
1043
+ {/each}
1044
+ </div>
1045
+ </div>
1046
+ {#if sizePreset === "custom"}
1047
+ <fieldset
1048
+ class="fieldset w-full min-w-0 rounded-lg border border-secondary px-3 pb-4"
1049
+ transition:slide={{ duration: 180 }}
1050
+ >
1051
+ <legend class="fieldset-legend">{m.label_custom_map_options()}</legend>
1052
+ <div class="form-control flex w-full flex-row items-center justify-between gap-4">
1053
+ <label
1054
+ class="label w-full justify-between gap-4 text-left whitespace-normal text-base-content"
1055
+ for="size-input"
1056
+ ><OptionHelp label={m.field_size()} help={m.help_size()} />
1057
+ <input
1058
+ class="input w-32 input-sm"
1059
+ id="size-input"
1060
+ type="number"
1061
+ required
1062
+ min="32"
1063
+ max="5000"
1064
+ step="1"
1065
+ aria-label={m.field_size()}
1066
+ bind:value={numCellsInput}
1067
+ />
1068
+ </label>
1069
+ </div>
1070
+ </fieldset>
1071
+ {/if}
1072
+ <div class="field-help my-4 w-full px-3">
1073
+ {usesFaceDensity
1074
+ ? m.text_density_summary({ faces: faceCount, count: selectedCellCount })
1075
+ : m.cells_count({ count: selectedCellCount })}
1076
+ </div>
1077
+ </fieldset>
1078
+ {#if playMode === "solo"}
1079
+ <fieldset class="mb-4 fieldset w-full px-3" transition:slide={{ duration: 180 }}>
1080
+ <div
1081
+ class="advanced-settings"
1082
+ class:advanced-settings-open={isAdvancedSettingsOpen}
1083
+ >
1084
+ <button
1085
+ type="button"
1086
+ class="advanced-settings-summary w-full"
1087
+ aria-expanded={isAdvancedSettingsOpen}
1088
+ aria-controls="advanced-settings-content"
1089
+ onclick={() => (isAdvancedSettingsOpen = !isAdvancedSettingsOpen)}
1090
+ >
1091
+ {m.label_advanced_settings()}
1092
+ </button>
1093
+ {#if isAdvancedSettingsOpen}
1094
+ <div
1095
+ id="advanced-settings-content"
1096
+ class="advanced-settings-content"
1097
+ transition:slide={{ duration: 180 }}
1098
+ >
1099
+ <div
1100
+ class="form-control flex w-full flex-row items-center justify-between gap-4"
1101
+ >
1102
+ <label
1103
+ class="label w-full justify-between gap-4 text-left whitespace-normal text-base-content"
1104
+ ><span
1105
+ ><OptionHelp
1106
+ label={m.field_void_fraction()}
1107
+ help={m.help_void_fraction()}
1108
+ /></span
1109
+ ><input
1110
+ class="input w-24 text-right input-sm"
1111
+ max="0.999"
1112
+ min="0"
1113
+ required
1114
+ step="0.00001"
1115
+ type="number"
1116
+ aria-label={m.field_void_fraction()}
1117
+ bind:value={voidFractionInput}
1118
+ /></label
1119
+ >
1120
+ </div>
1121
+ <div
1122
+ class="form-control flex w-full flex-row items-center justify-between gap-4"
1123
+ >
1124
+ <label
1125
+ class="label w-full justify-between gap-4 text-left whitespace-normal text-base-content"
1126
+ ><span
1127
+ ><OptionHelp
1128
+ label={m.field_spikiness()}
1129
+ help={m.help_spikiness()}
1130
+ /></span
1131
+ ><input
1132
+ class="input w-16 text-right input-sm"
1133
+ max="1"
1134
+ min="0"
1135
+ required
1136
+ step="0.05"
1137
+ type="number"
1138
+ aria-label={m.field_spikiness()}
1139
+ bind:value={spikinessInput}
1140
+ /></label
1141
+ >
1142
+ </div>
1143
+ <div
1144
+ class="form-control flex w-full flex-row items-center justify-between gap-4"
1145
+ >
1146
+ <label
1147
+ class="label text-left whitespace-normal text-base-content"
1148
+ for="rng-seed-input"
1149
+ ><OptionHelp label={m.field_seed()} help={m.help_seed()} /></label
1150
+ >
1151
+ <div class="join w-48 shrink-0" role="group" aria-label={m.field_seed()}>
1152
+ <input
1153
+ id="rng-seed-input"
1154
+ class="input join-item min-w-0 flex-1 text-right input-sm focus:outline-none"
1155
+ type="number"
1156
+ min="0"
1157
+ max={Number.MAX_SAFE_INTEGER}
1158
+ step="1"
1159
+ required
1160
+ class:input-ghost={randomSeed}
1161
+ class:border-base-300={randomSeed}
1162
+ class:border-2={!randomSeed}
1163
+ class:input-primary={!randomSeed}
1164
+ aria-label={m.field_seed()}
1165
+ bind:value={rngSeedInput}
1166
+ onclick={() => (randomSeed = false)}
1167
+ />
1168
+ <button
1169
+ aria-label={m.action_random()}
1170
+ aria-pressed={randomSeed}
1171
+ class="btn join-item btn-sm"
1172
+ class:border-base-300={!randomSeed}
1173
+ class:btn-outline={!randomSeed}
1174
+ class:btn-primary={randomSeed}
1175
+ onclick={() => (randomSeed = true)}
1176
+ title={m.action_random()}
1177
+ type="button"><span aria-hidden="true" class="text-xl">⚄</span></button
1178
+ >
1179
+ </div>
1180
+ </div>
1181
+ </div>
1182
+ {/if}
1183
+ </div>
1184
+ </fieldset>
1185
+ {/if}
896
1186
  </div>
897
1187
  <div class="flex flex-wrap justify-center gap-2">
898
1188
  <button class="btn btn-secondary" type="button" onclick={() => (setupMode = undefined)}>
@@ -911,16 +1201,12 @@
911
1201
  }}
912
1202
  >
913
1203
  <div class="-mx-3 mb-2 flex flex-wrap">
914
- <div class="mb-6 w-full px-3 md:mb-0">
915
- <label class="field-label" for="join-player-name">{m.field_player_name()}</label>
916
- <input class="field" id="join-player-name" type="text" bind:value={playerNameInput} />
917
- </div>
918
1204
  <div class="mb-6 w-full px-3 md:mb-0">
919
1205
  <label class="field-label" for="ticket-input"
920
1206
  >{m.field_ticket_or_invitation_url()}</label
921
1207
  >
922
1208
  <input
923
- class="field"
1209
+ class="input mb-3 w-full input-sm"
924
1210
  id="ticket-input"
925
1211
  type="text"
926
1212
  bind:value={ticketInput}
@@ -944,7 +1230,9 @@
944
1230
  >
945
1231
  {m.action_back()}
946
1232
  </button>
947
- <button class="btn btn-primary" type="submit">{m.action_join()}</button>
1233
+ <button class="btn btn-primary" type="submit" disabled={!account || !competitive}
1234
+ >{m.action_join()}</button
1235
+ >
948
1236
  </div>
949
1237
  </form>
950
1238
  {:else}
@@ -952,17 +1240,22 @@
952
1240
  <button class="btn btn-primary" type="button" onclick={() => (setupMode = "host")}>
953
1241
  {m.action_new_game()}
954
1242
  </button>
955
- <button class="btn btn-primary" type="button" onclick={() => (setupMode = "join")}>
1243
+ <button
1244
+ class="btn btn-primary"
1245
+ type="button"
1246
+ disabled={!account || !competitive}
1247
+ onclick={() => (setupMode = "join")}
1248
+ >
956
1249
  {m.action_join_game()}
957
1250
  </button>
958
1251
  </div>
959
1252
  <div class="mt-4 flex justify-center" transition:slide={{ duration: 180 }}>
960
- <label class="sr-only" for="language-select">Language</label>
1253
+ <label class="sr-only" for="language-select">{m.field_language()}</label>
961
1254
  <select
962
1255
  id="language-select"
963
- class="locale-select min-w-1/2"
1256
+ class="select w-40 select-sm"
964
1257
  value={getLocale()}
965
- aria-label="Language"
1258
+ aria-label={m.field_language()}
966
1259
  onchange={(event) => {
967
1260
  setLocale((event.currentTarget as HTMLSelectElement).value as Locale);
968
1261
  }}
@@ -975,32 +1268,6 @@
975
1268
  </select>
976
1269
  </div>
977
1270
  {/if}
978
- {:else if inviteTicket}
979
- <div class="mt-3" transition:slide={{ duration: 200 }}>
980
- <div class="mb-2 flex items-center justify-between gap-2">
981
- <label class="field-label mb-0" for="invite-ticket">{m.field_invitation_url()}</label>
982
- <button
983
- class="icon-btn"
984
- type="button"
985
- aria-label={m.aria_close_invitation()}
986
- onclick={() => (inviteTicket = "")}
987
- >
988
- ×
989
- </button>
990
- </div>
991
- <div class="flex items-stretch gap-2">
992
- <input
993
- id="invite-ticket"
994
- class="field mb-0 flex-1"
995
- type="text"
996
- readonly
997
- value={inviteUrl}
998
- />
999
- <button class="btn btn-secondary" type="button" onclick={copyInviteTicket}>
1000
- {m.action_copy()}
1001
- </button>
1002
- </div>
1003
- </div>
1004
1271
  {/if}
1005
1272
  </div>
1006
1273
  </div>
@@ -1024,7 +1291,7 @@
1024
1291
  />
1025
1292
  <Board
1026
1293
  flat={isFlatMap}
1027
- bind:gameState
1294
+ {gameState}
1028
1295
  {terrain}
1029
1296
  {surfaceArea}
1030
1297
  interactive={tutorial?.isExplorationAllowed ?? true}
@@ -1059,3 +1326,22 @@
1059
1326
  </div>
1060
1327
  </div>
1061
1328
  {/if}
1329
+
1330
+ <style>
1331
+ .duration-unit-select {
1332
+ /* Hide only the native selected text; DaisyUI's arrow uses currentColor. */
1333
+ text-indent: -9999px;
1334
+ color: var(--color-base-content);
1335
+ outline: none;
1336
+ }
1337
+
1338
+ .duration-unit-select:focus-visible {
1339
+ outline: 2px solid var(--color-primary);
1340
+ outline-offset: 2px;
1341
+ }
1342
+
1343
+ .duration-unit-select option,
1344
+ .duration-unit-select::picker(select) {
1345
+ text-indent: 0;
1346
+ }
1347
+ </style>