@kuncat/avoidant 0.3.1 → 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 +42 -0
- 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 +95 -42
- package/dist/components/AvoidantGame.svelte.d.ts +11 -0
- package/dist/components/MapControls.svelte +27 -1
- package/dist/components/MapControls.svelte.d.ts +2 -0
- package/dist/components/MultiplayerGame.svelte +69 -10
- 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 +2 -1
- package/dist/multiplayer/client.js +13 -5
- package/dist/multiplayer/current-match.d.ts +3 -0
- package/dist/multiplayer/current-match.js +37 -0
- package/dist/multiplayer/types.d.ts +10 -0
- package/dist/paraglide/messages/_index.d.ts +8 -0
- package/dist/paraglide/messages/_index.js +8 -0
- package/dist/paraglide/messages/action_see_plans.d.ts +16 -0
- 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/styles/global.css +11 -0
- package/dist/wasm/avoidant_wasm.d.ts +3 -3
- package/dist/wasm/avoidant_wasm.js +12 -12
- package/dist/wasm/avoidant_wasm_bg.wasm +0 -0
- package/dist/wasm/avoidant_wasm_bg.wasm.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,3 +95,45 @@ npm --prefix server test
|
|
|
95
95
|
The shared menu uses DaisyUI 5 with Tailwind 4. Consumers of the Svelte package
|
|
96
96
|
must install `daisyui` and enable its Tailwind plugin (themes `winter` and `night`),
|
|
97
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,5 +1,5 @@
|
|
|
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";
|
|
@@ -61,13 +61,34 @@
|
|
|
61
61
|
type Locale = (typeof locales)[number];
|
|
62
62
|
type AvoidantGameProps = {
|
|
63
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]>;
|
|
64
74
|
};
|
|
65
75
|
|
|
66
|
-
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);
|
|
67
85
|
let competitiveOpen = $state(false);
|
|
68
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"));
|
|
69
89
|
let authMessage = $state("");
|
|
70
90
|
let playMode = $state<"solo" | MultiplayerSetup["mode"]>("solo");
|
|
91
|
+
let publicGame = $state(false);
|
|
71
92
|
let multiplayerSetup = $state<MultiplayerSetup>();
|
|
72
93
|
let invitation = $state<string>();
|
|
73
94
|
let bordering = $state(false);
|
|
@@ -86,7 +107,8 @@
|
|
|
86
107
|
] as const;
|
|
87
108
|
$effect(() => {
|
|
88
109
|
const config = competitive;
|
|
89
|
-
|
|
110
|
+
const auth = authentication;
|
|
111
|
+
if (!auth) return;
|
|
90
112
|
let active = true;
|
|
91
113
|
void (async () => {
|
|
92
114
|
try {
|
|
@@ -95,8 +117,12 @@
|
|
|
95
117
|
params.get("match") ??
|
|
96
118
|
(params.has("state") ? sessionStorage.getItem("avoidant:competitiveMatch") : null);
|
|
97
119
|
if (pending) sessionStorage.setItem("avoidant:competitiveMatch", pending);
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
if (config?.tvPair) {
|
|
121
|
+
playMode = "collaborative";
|
|
122
|
+
setupMode = "host";
|
|
123
|
+
}
|
|
124
|
+
await auth.completeLogin();
|
|
125
|
+
const current = await auth.account();
|
|
100
126
|
if (!active) return;
|
|
101
127
|
account = current;
|
|
102
128
|
if (
|
|
@@ -109,7 +135,7 @@
|
|
|
109
135
|
if (pending) {
|
|
110
136
|
invitation = pending;
|
|
111
137
|
ticketInput = pending;
|
|
112
|
-
if (current) competitiveOpen = true;
|
|
138
|
+
if (current && config) competitiveOpen = true;
|
|
113
139
|
else setupMode = "join";
|
|
114
140
|
}
|
|
115
141
|
} catch (error) {
|
|
@@ -122,14 +148,14 @@
|
|
|
122
148
|
});
|
|
123
149
|
async function login(register = false) {
|
|
124
150
|
try {
|
|
125
|
-
await
|
|
151
|
+
await authentication?.login(register);
|
|
126
152
|
} catch (error) {
|
|
127
153
|
authMessage = String(error);
|
|
128
154
|
}
|
|
129
155
|
}
|
|
130
156
|
async function logout() {
|
|
131
157
|
try {
|
|
132
|
-
await
|
|
158
|
+
await authentication?.logout();
|
|
133
159
|
account = null;
|
|
134
160
|
playMode = "solo";
|
|
135
161
|
} catch (error) {
|
|
@@ -439,6 +465,7 @@
|
|
|
439
465
|
if (playMode !== "solo") {
|
|
440
466
|
if (!competitive || !account || sizePreset === "custom") return;
|
|
441
467
|
multiplayerSetup = {
|
|
468
|
+
public: publicGame,
|
|
442
469
|
mode: playMode,
|
|
443
470
|
map: shapeKindInput === "icosahedron" ? sizePreset : `${shapeKindInput}-${sizePreset}`,
|
|
444
471
|
bordering: playMode === "territory" && bordering,
|
|
@@ -488,14 +515,13 @@
|
|
|
488
515
|
}
|
|
489
516
|
}
|
|
490
517
|
|
|
491
|
-
function joinGame() {
|
|
518
|
+
function joinGame(input = ticketInput.trim()) {
|
|
492
519
|
joinError = undefined;
|
|
493
520
|
if (!account || !competitive) {
|
|
494
521
|
joinError = m.error_login_to_join();
|
|
495
522
|
return;
|
|
496
523
|
}
|
|
497
524
|
try {
|
|
498
|
-
const input = ticketInput.trim();
|
|
499
525
|
const id = parseInvitation(input);
|
|
500
526
|
if (!id) throw new Error(m.error_invitation_invalid());
|
|
501
527
|
invitation = id;
|
|
@@ -633,16 +659,19 @@
|
|
|
633
659
|
|
|
634
660
|
{#if !gameState}
|
|
635
661
|
<div class="my-3 flex flex-wrap justify-center gap-2">
|
|
636
|
-
{#if account}
|
|
637
|
-
|
|
638
|
-
|
|
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
|
+
>
|
|
639
668
|
{:else}<button
|
|
640
669
|
class="btn btn-secondary btn-sm"
|
|
641
|
-
disabled={!
|
|
670
|
+
disabled={!authentication}
|
|
642
671
|
onclick={() => login()}>{m.action_login()}</button
|
|
643
672
|
><button
|
|
644
673
|
class="btn btn-secondary btn-sm"
|
|
645
|
-
disabled={!
|
|
674
|
+
disabled={!authentication}
|
|
646
675
|
onclick={() => login(true)}>{m.action_register()}</button
|
|
647
676
|
>{/if}
|
|
648
677
|
</div>
|
|
@@ -668,13 +697,13 @@
|
|
|
668
697
|
><OptionHelp label={m.field_play_mode()} help={m.help_play_mode()} /></span
|
|
669
698
|
>
|
|
670
699
|
<div class="grid grid-cols-3 gap-2">
|
|
671
|
-
{#each playModes as mode (mode.id)}
|
|
700
|
+
{#each playModes.filter((mode) => !competitive?.tvPair || mode.id !== "solo") as mode (mode.id)}
|
|
672
701
|
<button
|
|
673
702
|
type="button"
|
|
674
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"
|
|
675
704
|
class:btn-primary={playMode === mode.id}
|
|
676
705
|
aria-pressed={playMode === mode.id}
|
|
677
|
-
disabled={mode.id !== "solo" && (!account || !competitive)}
|
|
706
|
+
disabled={mode.id !== "solo" && (!account || !competitive || !canHost)}
|
|
678
707
|
onclick={() => selectMode(mode.id)}
|
|
679
708
|
>
|
|
680
709
|
<span class="preset-icon"
|
|
@@ -708,6 +737,11 @@
|
|
|
708
737
|
</div>
|
|
709
738
|
{#if !account}<p class="field-help mt-2">
|
|
710
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
|
+
>
|
|
711
745
|
</p>{/if}
|
|
712
746
|
</div>
|
|
713
747
|
|
|
@@ -1185,6 +1219,21 @@
|
|
|
1185
1219
|
</fieldset>
|
|
1186
1220
|
{/if}
|
|
1187
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}
|
|
1188
1237
|
<div class="flex flex-wrap justify-center gap-2">
|
|
1189
1238
|
<button class="btn btn-secondary" type="button" onclick={() => (setupMode = undefined)}>
|
|
1190
1239
|
{m.action_back()}
|
|
@@ -1201,28 +1250,10 @@
|
|
|
1201
1250
|
await joinGame();
|
|
1202
1251
|
}}
|
|
1203
1252
|
>
|
|
1204
|
-
<
|
|
1205
|
-
|
|
1206
|
-
<label class="field-label" for="ticket-input"
|
|
1207
|
-
>{m.field_ticket_or_invitation_url()}</label
|
|
1208
|
-
>
|
|
1209
|
-
<input
|
|
1210
|
-
class="input mb-3 w-full input-sm"
|
|
1211
|
-
id="ticket-input"
|
|
1212
|
-
type="text"
|
|
1213
|
-
bind:value={ticketInput}
|
|
1214
|
-
oninput={() => (joinError = undefined)}
|
|
1215
|
-
/>
|
|
1216
|
-
</div>
|
|
1217
|
-
{#if joinError}
|
|
1218
|
-
<div class="w-full px-3" transition:slide={{ duration: 150 }}>
|
|
1219
|
-
<p class="join-error" role="alert">{joinError}</p>
|
|
1220
|
-
</div>
|
|
1221
|
-
{/if}
|
|
1222
|
-
</div>
|
|
1223
|
-
<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">
|
|
1224
1255
|
<button
|
|
1225
|
-
class="btn btn-secondary"
|
|
1256
|
+
class="btn btn-secondary btn-sm"
|
|
1226
1257
|
type="button"
|
|
1227
1258
|
onclick={() => {
|
|
1228
1259
|
setupMode = undefined;
|
|
@@ -1231,10 +1262,29 @@
|
|
|
1231
1262
|
>
|
|
1232
1263
|
{m.action_back()}
|
|
1233
1264
|
</button>
|
|
1234
|
-
<
|
|
1235
|
-
|
|
1236
|
-
|
|
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>
|
|
1237
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}
|
|
1238
1288
|
</form>
|
|
1239
1289
|
{:else}
|
|
1240
1290
|
<div class="mt-4 flex flex-wrap justify-center gap-2" transition:slide={{ duration: 220 }}>
|
|
@@ -1247,7 +1297,9 @@
|
|
|
1247
1297
|
disabled={!account || !competitive}
|
|
1248
1298
|
onclick={() => (setupMode = "join")}
|
|
1249
1299
|
>
|
|
1250
|
-
{m.action_join_game()}
|
|
1300
|
+
{m.action_join_game()}{#if competitive && joinBadge}{@render joinBadge(
|
|
1301
|
+
getLocale(),
|
|
1302
|
+
)}{/if}
|
|
1251
1303
|
</button>
|
|
1252
1304
|
</div>
|
|
1253
1305
|
<div class="mt-4 flex justify-center" transition:slide={{ duration: 180 }}>
|
|
@@ -1268,6 +1320,7 @@
|
|
|
1268
1320
|
{/each}
|
|
1269
1321
|
</select>
|
|
1270
1322
|
</div>
|
|
1323
|
+
{#if menuFooter}<div class="mt-4">{@render menuFooter()}</div>{/if}
|
|
1271
1324
|
{/if}
|
|
1272
1325
|
{/if}
|
|
1273
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>;
|
|
@@ -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);
|