@kuncat/avoidant 0.3.0 → 0.4.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.
- package/README.md +43 -3
- package/dist/assets/favicon.svg +1 -1
- package/dist/assets/fonts/NOTO-SANS-SYMBOLS-LICENSE.txt +93 -0
- package/dist/assets/fonts/noto-sans-symbols-arrows.woff2 +0 -0
- package/dist/components/AvoidantGame.svelte +98 -44
- package/dist/components/AvoidantGame.svelte.d.ts +11 -0
- package/dist/components/GameHistory.svelte +1 -1
- package/dist/components/MapControls.svelte +27 -1
- package/dist/components/MapControls.svelte.d.ts +2 -0
- package/dist/components/MatchResults.svelte +1 -2
- package/dist/components/MatchResults.svelte.d.ts +0 -1
- package/dist/components/MultiplayerGame.svelte +73 -14
- package/dist/components/MultiplayerGame.svelte.d.ts +3 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/multiplayer/client.d.ts +5 -2
- package/dist/multiplayer/client.js +22 -6
- package/dist/multiplayer/current-match.d.ts +3 -0
- package/dist/multiplayer/current-match.js +37 -0
- package/dist/multiplayer/invitations.d.ts +2 -0
- package/dist/multiplayer/invitations.js +23 -0
- package/dist/multiplayer/types.d.ts +10 -0
- package/dist/paraglide/messages/_index.d.ts +8 -1
- package/dist/paraglide/messages/_index.js +8 -1
- package/dist/paraglide/messages/{field_relay_servers.d.ts → action_see_plans.d.ts} +5 -5
- package/dist/paraglide/messages/action_see_plans.js +29 -0
- package/dist/paraglide/messages/error_tv_pairing.d.ts +16 -0
- package/dist/paraglide/messages/error_tv_pairing.js +29 -0
- package/dist/paraglide/messages/field_public_game.d.ts +16 -0
- package/dist/paraglide/messages/field_public_game.js +29 -0
- package/dist/paraglide/messages/help_public_game.d.ts +16 -0
- package/dist/paraglide/messages/help_public_game.js +29 -0
- package/dist/paraglide/messages/share_watch_help.d.ts +16 -0
- package/dist/paraglide/messages/share_watch_help.js +29 -0
- package/dist/paraglide/messages/status_public_unlisted.d.ts +16 -0
- package/dist/paraglide/messages/status_public_unlisted.js +29 -0
- package/dist/paraglide/messages/status_tv_showing.d.ts +16 -0
- package/dist/paraglide/messages/status_tv_showing.js +29 -0
- package/dist/paraglide/messages/text_multiplayer_subscription.d.ts +16 -0
- package/dist/paraglide/messages/text_multiplayer_subscription.js +29 -0
- package/dist/paraglide/messages/text_waiting_lobby.d.ts +1 -1
- package/dist/paraglide/messages/text_waiting_lobby.js +2 -2
- package/dist/styles/global.css +13 -0
- 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 +1 -1
- package/dist/paraglide/messages/field_relay_servers.js +0 -29
package/README.md
CHANGED
|
@@ -67,9 +67,7 @@ The existing New Game menu offers Solo, Collaborative and Territory. All
|
|
|
67
67
|
multiplayer modes require a Kuncat account and use the trusted Rust authority.
|
|
68
68
|
Collaborative games share reveals and a team score; territory use their
|
|
69
69
|
respective competitive rules. Invitations join through the same menu and login flow.
|
|
70
|
-
Solo stays local and does not require an account.
|
|
71
|
-
remains in the Rust library, but its relay settings and host/join paths are no longer
|
|
72
|
-
exposed by the application.
|
|
70
|
+
Solo stays local and does not require an account. Iroh transport and peer host/join APIs have been removed.
|
|
73
71
|
|
|
74
72
|
See [the implementation plan](docs/multiplayer-plan.md) for rules, identity and
|
|
75
73
|
architecture diagrams, and [the server guide](server/README.md) for deployment.
|
|
@@ -97,3 +95,45 @@ npm --prefix server test
|
|
|
97
95
|
The shared menu uses DaisyUI 5 with Tailwind 4. Consumers of the Svelte package
|
|
98
96
|
must install `daisyui` and enable its Tailwind plugin (themes `winter` and `night`),
|
|
99
97
|
as configured in `src/app.css` and the sibling games site's stylesheet.
|
|
98
|
+
|
|
99
|
+
## Client package and embedding
|
|
100
|
+
|
|
101
|
+
`@kuncat/avoidant` provides one Svelte client package for embedders. Matchmaking
|
|
102
|
+
integration does not require a separate package edition.
|
|
103
|
+
|
|
104
|
+
`AvoidantGame` accepts optional integration props: `competitive` supplies the
|
|
105
|
+
multiplayer endpoint and account adapter, `accountClient` supports account access,
|
|
106
|
+
`plansUrl` supplies the subscription destination, and `menuFooter` supplies footer
|
|
107
|
+
content. The optional `matchmaking` snippet is rendered on the Join screen when
|
|
108
|
+
competitive play is configured. It receives the current locale and a function that
|
|
109
|
+
joins a game by its id or invitation, so embedders can supply their own open-game
|
|
110
|
+
browser. The optional `joinBadge` snippet is rendered inside the Join Game button,
|
|
111
|
+
for example a count of open games, and receives the current locale. The standalone
|
|
112
|
+
app currently supplies neither snippet.
|
|
113
|
+
|
|
114
|
+
The npm archive contains the client `dist`, including generated WASM and translations.
|
|
115
|
+
It does not contain or deploy the multiplayer Worker in `server/`. Hosting public
|
|
116
|
+
rooms requires a compatible multiplayer server with discovery support and configured
|
|
117
|
+
services. The current server implementation also imports shared modules outside
|
|
118
|
+
this repository; installing the client package alone does not provide a complete
|
|
119
|
+
standalone server deployment.
|
|
120
|
+
|
|
121
|
+
## TV spectators
|
|
122
|
+
|
|
123
|
+
`AvoidantSpectator` renders an existing match with a `SpectatorSession` capability.
|
|
124
|
+
The Games launcher offers “Watch a game”: entering an active sharing code obtains
|
|
125
|
+
that session without host approval. The existing “Scan to host” QR flow remains
|
|
126
|
+
available for creating a game from a phone. Anyone with a sharing code can join or
|
|
127
|
+
watch. `POST /pair` accepts `{code}` and returns `{id,capability}`; attempts are
|
|
128
|
+
limited to 60 per IP/hour. Display credentials expire after 24 hours or room cleanup.
|
|
129
|
+
Four active spectator sockets are allowed per match, with separate pending-ticket
|
|
130
|
+
capacity for players. Reconnects reuse the credential and replace the old display
|
|
131
|
+
socket. Up to 128 credentials are retained, pruning the oldest inactive credentials.
|
|
132
|
+
The server enforces read-only sockets independently of UI controls. Spectators
|
|
133
|
+
receive the same redacted snapshot as players and do not consume player seats.
|
|
134
|
+
`CompetitiveConfig.tvPair` links a phone-created match to a pending TV display.
|
|
135
|
+
The normal game menu hides solo mode during this setup.
|
|
136
|
+
|
|
137
|
+
With the Games dependencies installed, run `node server/tests/tv-browser.mjs` after
|
|
138
|
+
building the server and updating the bundled website package to test a TV and two
|
|
139
|
+
phones. This test uses only local test accounts, never production authentication.
|
package/dist/assets/favicon.svg
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><title>Avoidant</title><defs><linearGradient id="r" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#d6dee8"/><stop offset="1" stop-color="#9aa9bc"/></linearGradient><linearGradient id="h" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#76797f"/><stop offset="1" stop-color="#46474d"/></linearGradient><linearGradient id="w" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#4a5a73"/><stop offset=".35" stop-color="#1a2130"/></linearGradient><clipPath id="f"><rect width="64" height="64" rx="14"/></clipPath><clipPath id="vc"><path d="M41.7 23.3L43.2 23.8Q45.5 24.5 45.9 26.9L48 39.3Q48.4 41.6 46.4 43L39.8 47.4Q37.8 48.7 35.8 47.3L24.2 39.1Q22.2 37.8 22.2 37.4L22.2 37.3Q22.2 36.9 24 35.4L37.5 24.1Q39.4 22.6 41.7 23.3Z"/></clipPath></defs><g clip-path="url(#f)"><rect width="64" height="64" fill="#1a2130"/><g clip-path="url(#vc)"><path d="M41.7 23.3L43.2 23.8Q45.5 24.5 45.9 26.9L48 39.3Q48.4 41.6 46.4 43L39.8 47.4Q37.8 48.7 35.8 47.3L24.2 39.1Q22.2 37.8 22.2 37.4L22.2 37.3Q22.2 36.9 24 35.4L37.5 24.1Q39.4 22.6 41.7 23.3Z" fill="url(#w)"/><path d="M41.7 23.3L43.2 23.8Q45.5 24.5 45.9 26.9L48 39.3Q48.4 41.6 46.4 43L39.8 47.4Q37.8 48.7 35.8 47.3L24.2 39.1Q22.2 37.8 22.2 37.4L22.2 37.3Q22.2 36.9 24 35.4L37.5 24.1Q39.4 22.6 41.7 23.3Z" fill="#05070c" transform="translate(0 6.5)"/></g><path d="M-4.4 -6.8L23.7 -6.8Q26.1 -6.8 26.3 -4.4L27.1 3.9Q27.4 6.3 25.8 8.1L15 21.1Q13.5 23 11.2 22.2L-4.5 16.4Q-6.8 15.6 -6.8 13.2L-6.8 -4.4Q-6.8 -6.8 -4.4 -6.8Z" fill="url(#r)"/><path d="M30.9 -6.8L68.4 -6.8Q70.8 -6.8 70.8 -4.4L70.8 1.3Q70.8 3.7 68.9 5.1L48.3 20.8Q46.4 22.3 44.1 21.6L42.2 20.9Q39.9 20.2 38.5 18.2L31.2 8.2Q29.8 6.2 29.5 3.8L28.7 -4.4Q28.5 -6.8 30.9 -6.8Z" fill="url(#h)"/><path d="M70.8 9.1L70.8 44.6Q70.8 47 68.5 46.3L53.1 41.9Q50.8 41.2 50.4 38.9L48.3 26.5Q47.9 24.1 49.8 22.7L68.9 8.1Q70.8 6.7 70.8 9.1Z" fill="url(#h)"/><path d="M70.8 51.9L70.8 68.4Q70.8 70.8 68.4 70.8L38.6 70.8Q36.2 70.8 36.5 68.4L38.6 53.2Q38.9 50.8 40.9 49.5L47.9 44.8Q49.9 43.5 52.2 44.2L68.5 48.8Q70.8 49.5 70.8 51.9Z" fill="url(#h)"/><path d="M31.4 70.8L-4.4 70.8Q-6.8 70.8 -6.8 68.4L-6.8 64.6Q-6.8 62.2 -4.9 60.7L19.2 41.4Q21.1 39.9 23 41.3L34.5 49.3Q36.5 50.7 36.2 53.1L34.1 68.4Q33.8 70.8 31.4 70.8Z" fill="url(#r)"/><path d="M19.8 37.2L19.8 37.3Q19.8 37.8 17.9 39.3L-4.9 57.6Q-6.8 59.1 -6.8 56.7L-6.8 20.6Q-6.8 18.2 -4.5 19L10.8 24.6Q13 25.4 14.3 27.4L18.6 34.6Q19.8 36.7 19.8 37.2Z" fill="url(#r)"/><path d="M35.7 22.6L23.1 33Q21.3 34.5 20.1 32.5L16.5 26.6Q15.3 24.5 16.8 22.7L27 10.5Q28.6 8.6 29.9 10.6L36.1 19.1Q37.5 21 35.7 22.6Z" fill="url(#r)"/></g></svg>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/symbols)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { onMount } from "svelte";
|
|
2
|
+
import { onMount, type Snippet } from "svelte";
|
|
3
3
|
import OptionHelp from "./OptionHelp.svelte";
|
|
4
4
|
import ScoreSummary from "./ScoreSummary.svelte";
|
|
5
5
|
import MapIcon from "./MapIcon.svelte";
|
|
6
6
|
import GameHistory from "./GameHistory.svelte";
|
|
7
7
|
let historyOpen = $state(false);
|
|
8
8
|
import MultiplayerGame from "./MultiplayerGame.svelte";
|
|
9
|
+
import { parseInvitation } from "../multiplayer/invitations";
|
|
9
10
|
import type { CompetitiveConfig, MultiplayerSetup } from "../multiplayer/types";
|
|
10
11
|
import { devicePixelRatio } from "svelte/reactivity/window";
|
|
11
12
|
import { slide } from "svelte/transition";
|
|
@@ -60,13 +61,34 @@
|
|
|
60
61
|
type Locale = (typeof locales)[number];
|
|
61
62
|
type AvoidantGameProps = {
|
|
62
63
|
competitive?: CompetitiveConfig;
|
|
64
|
+
accountClient?: CompetitiveConfig["account"];
|
|
65
|
+
plansUrl?: string;
|
|
66
|
+
/** Shown at the bottom of the start menu only, for example a host's policy links. */
|
|
67
|
+
menuFooter?: Snippet;
|
|
68
|
+
/** Open public games, shown on the Join screen. Receives the current language and a
|
|
69
|
+
* function that joins a game by its id or invitation. */
|
|
70
|
+
matchmaking?: Snippet<[string, (invitation: string) => void]>;
|
|
71
|
+
/** Shown inside the Join Game button, for example a count of open games. Receives the
|
|
72
|
+
* current language. */
|
|
73
|
+
joinBadge?: Snippet<[string]>;
|
|
63
74
|
};
|
|
64
75
|
|
|
65
|
-
let {
|
|
76
|
+
let {
|
|
77
|
+
competitive,
|
|
78
|
+
accountClient,
|
|
79
|
+
plansUrl = "https://kuncat.com/subscriptions/",
|
|
80
|
+
menuFooter,
|
|
81
|
+
matchmaking,
|
|
82
|
+
joinBadge,
|
|
83
|
+
}: AvoidantGameProps = $props();
|
|
84
|
+
const authentication = $derived(accountClient ?? competitive?.account);
|
|
66
85
|
let competitiveOpen = $state(false);
|
|
67
86
|
let account = $state<{ id: string; capabilities: string[] } | null>(null);
|
|
87
|
+
// Hosting multiplayer is a Kuncat Games subscription feature; joining stays free.
|
|
88
|
+
const canHost = $derived(!!account?.capabilities?.includes("games:host"));
|
|
68
89
|
let authMessage = $state("");
|
|
69
90
|
let playMode = $state<"solo" | MultiplayerSetup["mode"]>("solo");
|
|
91
|
+
let publicGame = $state(false);
|
|
70
92
|
let multiplayerSetup = $state<MultiplayerSetup>();
|
|
71
93
|
let invitation = $state<string>();
|
|
72
94
|
let bordering = $state(false);
|
|
@@ -85,7 +107,8 @@
|
|
|
85
107
|
] as const;
|
|
86
108
|
$effect(() => {
|
|
87
109
|
const config = competitive;
|
|
88
|
-
|
|
110
|
+
const auth = authentication;
|
|
111
|
+
if (!auth) return;
|
|
89
112
|
let active = true;
|
|
90
113
|
void (async () => {
|
|
91
114
|
try {
|
|
@@ -94,8 +117,12 @@
|
|
|
94
117
|
params.get("match") ??
|
|
95
118
|
(params.has("state") ? sessionStorage.getItem("avoidant:competitiveMatch") : null);
|
|
96
119
|
if (pending) sessionStorage.setItem("avoidant:competitiveMatch", pending);
|
|
97
|
-
|
|
98
|
-
|
|
120
|
+
if (config?.tvPair) {
|
|
121
|
+
playMode = "collaborative";
|
|
122
|
+
setupMode = "host";
|
|
123
|
+
}
|
|
124
|
+
await auth.completeLogin();
|
|
125
|
+
const current = await auth.account();
|
|
99
126
|
if (!active) return;
|
|
100
127
|
account = current;
|
|
101
128
|
if (
|
|
@@ -108,7 +135,7 @@
|
|
|
108
135
|
if (pending) {
|
|
109
136
|
invitation = pending;
|
|
110
137
|
ticketInput = pending;
|
|
111
|
-
if (current) competitiveOpen = true;
|
|
138
|
+
if (current && config) competitiveOpen = true;
|
|
112
139
|
else setupMode = "join";
|
|
113
140
|
}
|
|
114
141
|
} catch (error) {
|
|
@@ -121,14 +148,14 @@
|
|
|
121
148
|
});
|
|
122
149
|
async function login(register = false) {
|
|
123
150
|
try {
|
|
124
|
-
await
|
|
151
|
+
await authentication?.login(register);
|
|
125
152
|
} catch (error) {
|
|
126
153
|
authMessage = String(error);
|
|
127
154
|
}
|
|
128
155
|
}
|
|
129
156
|
async function logout() {
|
|
130
157
|
try {
|
|
131
|
-
await
|
|
158
|
+
await authentication?.logout();
|
|
132
159
|
account = null;
|
|
133
160
|
playMode = "solo";
|
|
134
161
|
} catch (error) {
|
|
@@ -438,6 +465,7 @@
|
|
|
438
465
|
if (playMode !== "solo") {
|
|
439
466
|
if (!competitive || !account || sizePreset === "custom") return;
|
|
440
467
|
multiplayerSetup = {
|
|
468
|
+
public: publicGame,
|
|
441
469
|
mode: playMode,
|
|
442
470
|
map: shapeKindInput === "icosahedron" ? sizePreset : `${shapeKindInput}-${sizePreset}`,
|
|
443
471
|
bordering: playMode === "territory" && bordering,
|
|
@@ -487,16 +515,15 @@
|
|
|
487
515
|
}
|
|
488
516
|
}
|
|
489
517
|
|
|
490
|
-
function joinGame() {
|
|
518
|
+
function joinGame(input = ticketInput.trim()) {
|
|
491
519
|
joinError = undefined;
|
|
492
520
|
if (!account || !competitive) {
|
|
493
521
|
joinError = m.error_login_to_join();
|
|
494
522
|
return;
|
|
495
523
|
}
|
|
496
524
|
try {
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
if (!id || !/^[a-f0-9-]{36}$/.test(id)) throw new Error(m.error_invitation_invalid());
|
|
525
|
+
const id = parseInvitation(input);
|
|
526
|
+
if (!id) throw new Error(m.error_invitation_invalid());
|
|
500
527
|
invitation = id;
|
|
501
528
|
multiplayerSetup = undefined;
|
|
502
529
|
competitiveOpen = true;
|
|
@@ -632,16 +659,19 @@
|
|
|
632
659
|
|
|
633
660
|
{#if !gameState}
|
|
634
661
|
<div class="my-3 flex flex-wrap justify-center gap-2">
|
|
635
|
-
{#if account}
|
|
636
|
-
|
|
637
|
-
|
|
662
|
+
{#if account}{#if competitive}<button
|
|
663
|
+
class="btn btn-secondary btn-sm"
|
|
664
|
+
onclick={() => (historyOpen = true)}>{m.action_game_history()}</button
|
|
665
|
+
>{/if}<button class="btn btn-secondary btn-sm" onclick={logout}
|
|
666
|
+
>{m.action_logout()}</button
|
|
667
|
+
>
|
|
638
668
|
{:else}<button
|
|
639
669
|
class="btn btn-secondary btn-sm"
|
|
640
|
-
disabled={!
|
|
670
|
+
disabled={!authentication}
|
|
641
671
|
onclick={() => login()}>{m.action_login()}</button
|
|
642
672
|
><button
|
|
643
673
|
class="btn btn-secondary btn-sm"
|
|
644
|
-
disabled={!
|
|
674
|
+
disabled={!authentication}
|
|
645
675
|
onclick={() => login(true)}>{m.action_register()}</button
|
|
646
676
|
>{/if}
|
|
647
677
|
</div>
|
|
@@ -667,13 +697,13 @@
|
|
|
667
697
|
><OptionHelp label={m.field_play_mode()} help={m.help_play_mode()} /></span
|
|
668
698
|
>
|
|
669
699
|
<div class="grid grid-cols-3 gap-2">
|
|
670
|
-
{#each playModes as mode (mode.id)}
|
|
700
|
+
{#each playModes.filter((mode) => !competitive?.tvPair || mode.id !== "solo") as mode (mode.id)}
|
|
671
701
|
<button
|
|
672
702
|
type="button"
|
|
673
703
|
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
704
|
class:btn-primary={playMode === mode.id}
|
|
675
705
|
aria-pressed={playMode === mode.id}
|
|
676
|
-
disabled={mode.id !== "solo" && (!account || !competitive)}
|
|
706
|
+
disabled={mode.id !== "solo" && (!account || !competitive || !canHost)}
|
|
677
707
|
onclick={() => selectMode(mode.id)}
|
|
678
708
|
>
|
|
679
709
|
<span class="preset-icon"
|
|
@@ -707,6 +737,11 @@
|
|
|
707
737
|
</div>
|
|
708
738
|
{#if !account}<p class="field-help mt-2">
|
|
709
739
|
{m.text_multiplayer_login()}
|
|
740
|
+
</p>{:else if competitive && !canHost}<p class="field-help mt-2">
|
|
741
|
+
{m.text_multiplayer_subscription()}
|
|
742
|
+
<a class="link font-semibold link-primary" href={plansUrl}
|
|
743
|
+
>{m.action_see_plans()}</a
|
|
744
|
+
>
|
|
710
745
|
</p>{/if}
|
|
711
746
|
</div>
|
|
712
747
|
|
|
@@ -1184,6 +1219,21 @@
|
|
|
1184
1219
|
</fieldset>
|
|
1185
1220
|
{/if}
|
|
1186
1221
|
</div>
|
|
1222
|
+
{#if competitive && playMode !== "solo"}<div
|
|
1223
|
+
class="form-control mb-4 flex w-full flex-row items-center justify-between gap-4"
|
|
1224
|
+
>
|
|
1225
|
+
<label
|
|
1226
|
+
class="label w-full justify-between gap-4 text-left whitespace-normal text-base-content"
|
|
1227
|
+
><span
|
|
1228
|
+
><OptionHelp label={m.field_public_game()} help={m.help_public_game()} /></span
|
|
1229
|
+
><input
|
|
1230
|
+
type="checkbox"
|
|
1231
|
+
class="checkbox shrink-0 rounded-sm checkbox-sm checkbox-primary"
|
|
1232
|
+
aria-label={m.field_public_game()}
|
|
1233
|
+
bind:checked={publicGame}
|
|
1234
|
+
/></label
|
|
1235
|
+
>
|
|
1236
|
+
</div>{/if}
|
|
1187
1237
|
<div class="flex flex-wrap justify-center gap-2">
|
|
1188
1238
|
<button class="btn btn-secondary" type="button" onclick={() => (setupMode = undefined)}>
|
|
1189
1239
|
{m.action_back()}
|
|
@@ -1200,28 +1250,10 @@
|
|
|
1200
1250
|
await joinGame();
|
|
1201
1251
|
}}
|
|
1202
1252
|
>
|
|
1203
|
-
<
|
|
1204
|
-
|
|
1205
|
-
<label class="field-label" for="ticket-input"
|
|
1206
|
-
>{m.field_ticket_or_invitation_url()}</label
|
|
1207
|
-
>
|
|
1208
|
-
<input
|
|
1209
|
-
class="input mb-3 w-full input-sm"
|
|
1210
|
-
id="ticket-input"
|
|
1211
|
-
type="text"
|
|
1212
|
-
bind:value={ticketInput}
|
|
1213
|
-
oninput={() => (joinError = undefined)}
|
|
1214
|
-
/>
|
|
1215
|
-
</div>
|
|
1216
|
-
{#if joinError}
|
|
1217
|
-
<div class="w-full px-3" transition:slide={{ duration: 150 }}>
|
|
1218
|
-
<p class="join-error" role="alert">{joinError}</p>
|
|
1219
|
-
</div>
|
|
1220
|
-
{/if}
|
|
1221
|
-
</div>
|
|
1222
|
-
<div class="flex flex-wrap justify-center gap-2">
|
|
1253
|
+
<label class="field-label" for="ticket-input">{m.field_ticket_or_invitation_url()}</label>
|
|
1254
|
+
<div class="flex gap-2">
|
|
1223
1255
|
<button
|
|
1224
|
-
class="btn btn-secondary"
|
|
1256
|
+
class="btn btn-secondary btn-sm"
|
|
1225
1257
|
type="button"
|
|
1226
1258
|
onclick={() => {
|
|
1227
1259
|
setupMode = undefined;
|
|
@@ -1230,10 +1262,29 @@
|
|
|
1230
1262
|
>
|
|
1231
1263
|
{m.action_back()}
|
|
1232
1264
|
</button>
|
|
1233
|
-
<
|
|
1234
|
-
|
|
1235
|
-
|
|
1265
|
+
<div class="join min-w-0 flex-1">
|
|
1266
|
+
<input
|
|
1267
|
+
class="input join-item w-full input-sm"
|
|
1268
|
+
id="ticket-input"
|
|
1269
|
+
type="text"
|
|
1270
|
+
bind:value={ticketInput}
|
|
1271
|
+
oninput={() => (joinError = undefined)}
|
|
1272
|
+
/>
|
|
1273
|
+
<button
|
|
1274
|
+
class="btn join-item btn-primary btn-sm"
|
|
1275
|
+
type="submit"
|
|
1276
|
+
disabled={!account || !competitive}>{m.action_join()}</button
|
|
1277
|
+
>
|
|
1278
|
+
</div>
|
|
1236
1279
|
</div>
|
|
1280
|
+
{#if joinError}
|
|
1281
|
+
<p class="join-error mt-2" role="alert" transition:slide={{ duration: 150 }}>
|
|
1282
|
+
{joinError}
|
|
1283
|
+
</p>
|
|
1284
|
+
{/if}
|
|
1285
|
+
{#if competitive && matchmaking}<div class="mt-4 w-full">
|
|
1286
|
+
{@render matchmaking(getLocale(), joinGame)}
|
|
1287
|
+
</div>{/if}
|
|
1237
1288
|
</form>
|
|
1238
1289
|
{:else}
|
|
1239
1290
|
<div class="mt-4 flex flex-wrap justify-center gap-2" transition:slide={{ duration: 220 }}>
|
|
@@ -1246,7 +1297,9 @@
|
|
|
1246
1297
|
disabled={!account || !competitive}
|
|
1247
1298
|
onclick={() => (setupMode = "join")}
|
|
1248
1299
|
>
|
|
1249
|
-
{m.action_join_game()}
|
|
1300
|
+
{m.action_join_game()}{#if competitive && joinBadge}{@render joinBadge(
|
|
1301
|
+
getLocale(),
|
|
1302
|
+
)}{/if}
|
|
1250
1303
|
</button>
|
|
1251
1304
|
</div>
|
|
1252
1305
|
<div class="mt-4 flex justify-center" transition:slide={{ duration: 180 }}>
|
|
@@ -1267,6 +1320,7 @@
|
|
|
1267
1320
|
{/each}
|
|
1268
1321
|
</select>
|
|
1269
1322
|
</div>
|
|
1323
|
+
{#if menuFooter}<div class="mt-4">{@render menuFooter()}</div>{/if}
|
|
1270
1324
|
{/if}
|
|
1271
1325
|
{/if}
|
|
1272
1326
|
</div>
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
import { type Snippet } from "svelte";
|
|
1
2
|
import type { CompetitiveConfig } from "../multiplayer/types";
|
|
2
3
|
type AvoidantGameProps = {
|
|
3
4
|
competitive?: CompetitiveConfig;
|
|
5
|
+
accountClient?: CompetitiveConfig["account"];
|
|
6
|
+
plansUrl?: string;
|
|
7
|
+
/** Shown at the bottom of the start menu only, for example a host's policy links. */
|
|
8
|
+
menuFooter?: Snippet;
|
|
9
|
+
/** Open public games, shown on the Join screen. Receives the current language and a
|
|
10
|
+
* function that joins a game by its id or invitation. */
|
|
11
|
+
matchmaking?: Snippet<[string, (invitation: string) => void]>;
|
|
12
|
+
/** Shown inside the Join Game button, for example a count of open games. Receives the
|
|
13
|
+
* current language. */
|
|
14
|
+
joinBadge?: Snippet<[string]>;
|
|
4
15
|
};
|
|
5
16
|
declare const AvoidantGame: import("svelte").Component<AvoidantGameProps, {}, "">;
|
|
6
17
|
type AvoidantGame = ReturnType<typeof AvoidantGame>;
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
<p class="text-sm opacity-70">
|
|
82
82
|
{new Date(match.finishedAt).toLocaleString(getLocale())}
|
|
83
83
|
</p>
|
|
84
|
-
<MatchResults players={match.players}
|
|
84
|
+
<MatchResults players={match.players} />
|
|
85
85
|
{#if match.replayAvailable}<button
|
|
86
86
|
class="btn mt-2 btn-sm"
|
|
87
87
|
disabled={downloading !== null}
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
import { PerspectiveCamera, Raycaster, Vector2 } from "three";
|
|
4
4
|
import { cameraPlanePoint, orbitMap, orbitRadiansPerPixel, panMap, zoomMap } from "./map-camera";
|
|
5
5
|
|
|
6
|
-
let {
|
|
6
|
+
let {
|
|
7
|
+
flat,
|
|
8
|
+
radius,
|
|
9
|
+
keyboard = false,
|
|
10
|
+
pan: keyboardPan = false,
|
|
11
|
+
}: { flat: boolean; radius: number; keyboard?: boolean; pan?: boolean } = $props();
|
|
7
12
|
const { camera, renderer, scene, invalidate } = useThrelte();
|
|
8
13
|
|
|
9
14
|
$effect(() => {
|
|
@@ -11,6 +16,7 @@
|
|
|
11
16
|
if (!(selectedCamera instanceof PerspectiveCamera)) return;
|
|
12
17
|
const activeCamera: PerspectiveCamera = selectedCamera;
|
|
13
18
|
const isFlat = flat;
|
|
19
|
+
const enableKeyboard = keyboard;
|
|
14
20
|
const mapRadius = Math.max(1, radius);
|
|
15
21
|
const element = renderer.domElement;
|
|
16
22
|
// Gesture bookkeeping is deliberately non-reactive.
|
|
@@ -130,9 +136,28 @@
|
|
|
130
136
|
if (suppressClick) event.stopImmediatePropagation();
|
|
131
137
|
}
|
|
132
138
|
|
|
139
|
+
function key(event: KeyboardEvent) {
|
|
140
|
+
if (!enableKeyboard || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
141
|
+
if (
|
|
142
|
+
event.target instanceof HTMLElement &&
|
|
143
|
+
event.target.closest("input,select,textarea,button,a")
|
|
144
|
+
)
|
|
145
|
+
return;
|
|
146
|
+
const dx = event.key === "ArrowLeft" ? -24 : event.key === "ArrowRight" ? 24 : 0;
|
|
147
|
+
const dy = event.key === "ArrowUp" ? -24 : event.key === "ArrowDown" ? 24 : 0;
|
|
148
|
+
if (!dx && !dy) return;
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
if (keyboardPan || event.shiftKey) {
|
|
151
|
+
const rect = element.getBoundingClientRect();
|
|
152
|
+
const x = rect.left + rect.width / 2,
|
|
153
|
+
y = rect.top + rect.height / 2;
|
|
154
|
+
pan(x, y, x + dx, y + dy);
|
|
155
|
+
} else rotate(dx, dy);
|
|
156
|
+
}
|
|
133
157
|
function contextMenu(event: MouseEvent) {
|
|
134
158
|
event.preventDefault();
|
|
135
159
|
}
|
|
160
|
+
window.addEventListener("keydown", key);
|
|
136
161
|
element.addEventListener("click", click, true);
|
|
137
162
|
element.addEventListener("pointerdown", down);
|
|
138
163
|
element.addEventListener("pointermove", move);
|
|
@@ -142,6 +167,7 @@
|
|
|
142
167
|
element.addEventListener("wheel", wheel, { passive: false });
|
|
143
168
|
element.addEventListener("contextmenu", contextMenu);
|
|
144
169
|
return () => {
|
|
170
|
+
window.removeEventListener("keydown", key);
|
|
145
171
|
element.removeEventListener("click", click, true);
|
|
146
172
|
element.removeEventListener("pointerdown", down);
|
|
147
173
|
element.removeEventListener("pointermove", move);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { getLocale } from "../paraglide/runtime";
|
|
4
4
|
import { formatDuration } from "../multiplayer/duration";
|
|
5
5
|
import type { MatchSnapshot } from "../multiplayer/types";
|
|
6
|
-
let { players
|
|
6
|
+
let { players }: { players: MatchSnapshot["players"] } = $props();
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<div class="overflow-x-auto">
|
|
@@ -25,5 +25,4 @@
|
|
|
25
25
|
>{/each}</tbody
|
|
26
26
|
>
|
|
27
27
|
</table>
|
|
28
|
-
<p class="text-xs opacity-70">{turnBased ? m.help_turn_time() : m.help_participation_time()}</p>
|
|
29
28
|
</div>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { MatchSnapshot } from "../multiplayer/types";
|
|
2
2
|
type $$ComponentProps = {
|
|
3
3
|
players: MatchSnapshot["players"];
|
|
4
|
-
turnBased: boolean;
|
|
5
4
|
};
|
|
6
5
|
declare const MatchResults: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
6
|
type MatchResults = ReturnType<typeof MatchResults>;
|