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