@minicode-dev/chat 0.1.15 → 0.1.17
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/CHANGELOG.md +12 -0
- package/README.md +2 -0
- package/dist/chunks/{BattleshipGameCard-8H-sBCsv.js → BattleshipGameCard-DwNzgH5G.js} +199 -199
- package/dist/chunks/{BattleshipGameCard-8H-sBCsv.js.map → BattleshipGameCard-DwNzgH5G.js.map} +1 -1
- package/dist/chunks/{BattleshipPrototype-CmQd5AUO.js → BattleshipPrototype-CSQxQJt5.js} +52 -52
- package/dist/chunks/{BattleshipPrototype-CmQd5AUO.js.map → BattleshipPrototype-CSQxQJt5.js.map} +1 -1
- package/dist/chunks/{ChatContext-CVW58bzC.js → ChatContext-D5rqvt5D.js} +2 -2
- package/dist/chunks/{ChatContext-CVW58bzC.js.map → ChatContext-D5rqvt5D.js.map} +1 -1
- package/dist/chunks/RacingLiveGameCard-_wvhDRlG.js +1873 -0
- package/dist/chunks/RacingLiveGameCard-_wvhDRlG.js.map +1 -0
- package/dist/chunks/{TanksGameCard-DnCufSH6.js → TanksGameCard-B-gtDYYg.js} +137 -137
- package/dist/chunks/{TanksGameCard-DnCufSH6.js.map → TanksGameCard-B-gtDYYg.js.map} +1 -1
- package/dist/chunks/{TanksLiveGameCard-D_27Jomp.js → TanksLiveGameCard-DXgd1J2Y.js} +392 -392
- package/dist/chunks/{TanksLiveGameCard-D_27Jomp.js.map → TanksLiveGameCard-DXgd1J2Y.js.map} +1 -1
- package/dist/chunks/{avalancheScene3d-CIE2WKQn.js → avalancheScene3d-CNbQyGUd.js} +2 -2
- package/dist/chunks/{avalancheScene3d-CIE2WKQn.js.map → avalancheScene3d-CNbQyGUd.js.map} +1 -1
- package/dist/chunks/{connect4Sounds-BqEHULjv.js → connect4Sounds-3a6h7gUC.js} +8 -8
- package/dist/chunks/{connect4Sounds-BqEHULjv.js.map → connect4Sounds-3a6h7gUC.js.map} +1 -1
- package/dist/chunks/createLiveScene-jrzyQogh.js +756 -0
- package/dist/chunks/{createLiveScene-MTGRv8rx.js.map → createLiveScene-jrzyQogh.js.map} +1 -1
- package/dist/chunks/createRaceScene-C-aw0dlX.js +291 -0
- package/dist/chunks/createRaceScene-C-aw0dlX.js.map +1 -0
- package/dist/chunks/{createTankScene-yhX6la27.js → createTankScene-6asWHKFf.js} +123 -125
- package/dist/chunks/{createTankScene-yhX6la27.js.map → createTankScene-6asWHKFf.js.map} +1 -1
- package/dist/chunks/fx-BNJvJYOu.js +871 -0
- package/dist/chunks/fx-BNJvJYOu.js.map +1 -0
- package/dist/chunks/{games-Bl_8raG6.js → games-D_9SiSBT.js} +708 -697
- package/dist/chunks/games-D_9SiSBT.js.map +1 -0
- package/dist/chunks/tank-DIn6Jyt8.js +605 -0
- package/dist/chunks/tank-DIn6Jyt8.js.map +1 -0
- package/dist/chunks/{tanks-live-BcKmrhnV.js → tanks-live-BRhYW4MG.js} +36 -36
- package/dist/chunks/{tanks-live-BcKmrhnV.js.map → tanks-live-BRhYW4MG.js.map} +1 -1
- package/dist/chunks/{tanksSounds-DTnidbiq.js → tanksSounds-tYPzje61.js} +4 -4
- package/dist/chunks/{tanksSounds-DTnidbiq.js.map → tanksSounds-tYPzje61.js.map} +1 -1
- package/dist/chunks/track-C1TWWT19.js +557 -0
- package/dist/chunks/track-C1TWWT19.js.map +1 -0
- package/dist/index.js +4236 -4020
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/index.d.ts +3 -1
- package/package.json +1 -1
- package/dist/chunks/RacingLiveGameCard-8j9QLnxW.js +0 -1654
- package/dist/chunks/RacingLiveGameCard-8j9QLnxW.js.map +0 -1
- package/dist/chunks/createLiveScene-MTGRv8rx.js +0 -758
- package/dist/chunks/createRaceScene-BiEtQsVs.js +0 -306
- package/dist/chunks/createRaceScene-BiEtQsVs.js.map +0 -1
- package/dist/chunks/decor-CyyCnmct.js +0 -418
- package/dist/chunks/decor-CyyCnmct.js.map +0 -1
- package/dist/chunks/fx-1ZwzmPWj.js +0 -458
- package/dist/chunks/fx-1ZwzmPWj.js.map +0 -1
- package/dist/chunks/games-Bl_8raG6.js.map +0 -1
- package/dist/chunks/rolldown-runtime-CGnMp29N.js +0 -10
- package/dist/chunks/tank-DjEQ4FXF.js +0 -553
- package/dist/chunks/tank-DjEQ4FXF.js.map +0 -1
- package/dist/chunks/track-BcnnpnAm.js +0 -259
- package/dist/chunks/track-BcnnpnAm.js.map +0 -1
- package/dist/chunks/util-DwI9bfS7.js +0 -57
- package/dist/chunks/util-DwI9bfS7.js.map +0 -1
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { a as
|
|
8
|
-
import { memo as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { C as e, D as t, E as n, O as r, S as i, T as a, a as o, b as s, v as c, w as l, x as u, y as d } from "./games-D_9SiSBT.js";
|
|
2
|
+
import { n as f, o as p, s as ee } from "./createPeerLink-DBVs_yvQ.js";
|
|
3
|
+
import { t as m } from "./ChatContext-D5rqvt5D.js";
|
|
4
|
+
import { o as h } from "./connect4Sounds-3a6h7gUC.js";
|
|
5
|
+
import { n as g, r as _, t as v } from "./tanks-live-BRhYW4MG.js";
|
|
6
|
+
import { c as y } from "./RacingLiveGameCard-_wvhDRlG.js";
|
|
7
|
+
import { a as te, c as ne, i as b, n as re, o as x, r as ie, s as S, t as C } from "./tanksSounds-tYPzje61.js";
|
|
8
|
+
import { memo as w, useContext as T, useEffect as E, useRef as D, useState as O } from "react";
|
|
9
|
+
import { Fragment as k, jsx as A, jsxs as j } from "react/jsx-runtime";
|
|
10
|
+
import { AlertTriangle as M, CheckCircle2 as ae, Link2 as N, Loader2 as oe, Settings2 as P } from "lucide-react";
|
|
11
11
|
// src/games/tanks-live/net/createLiveMatch.js
|
|
12
|
-
var
|
|
12
|
+
var se = Object.freeze({
|
|
13
13
|
respawnMs: 3e3,
|
|
14
14
|
shieldMs: 2e3
|
|
15
|
-
}),
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
let
|
|
19
|
-
if (!
|
|
20
|
-
let
|
|
21
|
-
if (!
|
|
22
|
-
let
|
|
15
|
+
}), ce = (e) => typeof e == "number" && Number.isFinite(e), le = (e) => typeof e == "string" && e.length > 0 && e.length < 160;
|
|
16
|
+
function F({ game: o, selfId: m, isHost: h = String(m) === String(o.hostId), signaling: g, onChange: _ = () => {}, peerFactory: v = f, iceServers: y, iceTransportPolicy: te, RTCPeerConnectionImpl: ne } = {}) {
|
|
17
|
+
m = String(m);
|
|
18
|
+
let b = [String(o.hostId), String(o.guestId)];
|
|
19
|
+
if (!b.includes(m) || b[0] === b[1]) throw Error("Invalid live match players");
|
|
20
|
+
let re = (y || []).some((e) => [e.urls].flat().some((e) => /^turns?:/i.test(String(e)))), x = b.find((e) => e !== m), ie = o.liveConfig ?? null, S = !ie, C = S ? u() : c(ie.mapId, ie.seed);
|
|
21
|
+
if (!S && C.hash !== ie.mapHash) throw Error("El mapa no coincide con la invitación");
|
|
22
|
+
let w = S ? 1 : ie.lives;
|
|
23
23
|
if (![
|
|
24
24
|
1,
|
|
25
25
|
3,
|
|
26
26
|
5
|
|
27
|
-
].includes(
|
|
28
|
-
let
|
|
27
|
+
].includes(w)) throw Error("Vidas inválidas");
|
|
28
|
+
let T = (C.destructibles || []).map((e) => ({
|
|
29
29
|
id: e.id,
|
|
30
30
|
hp: e.hp
|
|
31
|
-
})),
|
|
32
|
-
let n =
|
|
31
|
+
})), E = (e, t) => {
|
|
32
|
+
let n = i(e, t), r = C.spawns?.[t];
|
|
33
33
|
return r && Object.assign(n, {
|
|
34
34
|
x: r.x,
|
|
35
35
|
z: r.z,
|
|
36
36
|
yaw: r.yaw,
|
|
37
37
|
turretYaw: r.yaw
|
|
38
38
|
}), n;
|
|
39
|
-
},
|
|
39
|
+
}, D = (e) => (C.destructibles || []).find((t) => t.id === e), O = b.map(E), k = [], A = [], j = {}, M = 0, ae = 0, N = 0, oe = 0, P = [w, w], F = [0, 0], I = [null, null], L = "connecting", R = null, z = !1, B = {
|
|
40
40
|
phase: "idle",
|
|
41
41
|
rtt: null,
|
|
42
42
|
route: null
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
status:
|
|
46
|
-
winner:
|
|
47
|
-
net:
|
|
43
|
+
}, ue = !1, V = !1, H = null, U = [], W = null, G = null, de = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Set(), fe = /* @__PURE__ */ new Set(), q = () => O.find((e) => e.id === m), pe = () => O.find((e) => e.id === x), me = () => {
|
|
44
|
+
z || _({
|
|
45
|
+
status: L,
|
|
46
|
+
winner: R,
|
|
47
|
+
net: B
|
|
48
48
|
});
|
|
49
49
|
}, J = (e) => {
|
|
50
|
-
|
|
51
|
-
}, Y = (
|
|
52
|
-
...
|
|
53
|
-
g:
|
|
54
|
-
r:
|
|
50
|
+
A.push(e), A.length > 200 && A.shift();
|
|
51
|
+
}, Y = (e) => $.sendEvent({
|
|
52
|
+
...e,
|
|
53
|
+
g: o.gameId,
|
|
54
|
+
r: N
|
|
55
55
|
}), X = (e) => {
|
|
56
56
|
K.add(e), K.size > 2048 && K.delete(K.values().next().value);
|
|
57
|
-
}, Z = (e) => Math.max(0, Math.round(
|
|
57
|
+
}, Z = (e) => Math.max(0, Math.round(F[e] - M)), he = () => ({
|
|
58
58
|
k: "snapshot",
|
|
59
|
-
hp:
|
|
60
|
-
status:
|
|
61
|
-
winner:
|
|
59
|
+
hp: O.map((e) => e.hp),
|
|
60
|
+
status: L,
|
|
61
|
+
winner: R,
|
|
62
62
|
reason: H,
|
|
63
|
-
...
|
|
64
|
-
lives: [...
|
|
63
|
+
...S ? {} : {
|
|
64
|
+
lives: [...P],
|
|
65
65
|
shield: [0, 1].map(Z),
|
|
66
|
-
destructibles: (
|
|
66
|
+
destructibles: (C.destructibles || []).map((e) => ({
|
|
67
67
|
id: e.id,
|
|
68
68
|
hp: e.hp
|
|
69
69
|
}))
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
function ge() {
|
|
73
|
-
(
|
|
74
|
-
e.hp =
|
|
73
|
+
(C.destructibles || []).forEach((e, t) => {
|
|
74
|
+
e.hp = T[t].hp, e.alive = !0;
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
function _e(e) {
|
|
78
|
-
let t =
|
|
79
|
-
Object.assign(
|
|
78
|
+
let t = E(b[e], e);
|
|
79
|
+
Object.assign(O[e], {
|
|
80
80
|
x: t.x,
|
|
81
81
|
z: t.z,
|
|
82
82
|
yaw: t.yaw,
|
|
@@ -84,36 +84,36 @@ function P({ game: e, selfId: s, isHost: h = String(s) === String(e.hostId), sig
|
|
|
84
84
|
speed: 0,
|
|
85
85
|
hp: 100,
|
|
86
86
|
alive: !0
|
|
87
|
-
}),
|
|
87
|
+
}), I[e] = null, F[e] = M + se.shieldMs, b[e] === x && (U = [], G = null, W = null), J({
|
|
88
88
|
k: "respawn",
|
|
89
|
-
target:
|
|
89
|
+
target: b[e],
|
|
90
90
|
x: t.x,
|
|
91
91
|
z: t.z,
|
|
92
|
-
shield:
|
|
92
|
+
shield: se.shieldMs
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
function ve(e, t) {
|
|
96
|
-
|
|
96
|
+
P[e] = t, J({
|
|
97
97
|
k: "life_lost",
|
|
98
|
-
target:
|
|
99
|
-
lives: [...
|
|
100
|
-
}), t === 1 &&
|
|
98
|
+
target: b[e],
|
|
99
|
+
lives: [...P]
|
|
100
|
+
}), t === 1 && w > 1 && J({
|
|
101
101
|
k: "last_life",
|
|
102
|
-
target:
|
|
103
|
-
}),
|
|
102
|
+
target: b[e]
|
|
103
|
+
}), I[e] = t > 0 ? M + se.respawnMs : null;
|
|
104
104
|
}
|
|
105
105
|
function Q(e, t) {
|
|
106
|
-
|
|
106
|
+
S ? P[e] = 0 : (ve(e, Math.max(0, P[e] - 1)), Y({
|
|
107
107
|
k: "life_lost",
|
|
108
|
-
target:
|
|
109
|
-
lives: [...
|
|
108
|
+
target: b[e],
|
|
109
|
+
lives: [...P]
|
|
110
110
|
}));
|
|
111
111
|
let n = {
|
|
112
112
|
k: "destroyed",
|
|
113
|
-
target:
|
|
113
|
+
target: b[e]
|
|
114
114
|
};
|
|
115
|
-
if (Y(n), J(n),
|
|
116
|
-
let n = t ===
|
|
115
|
+
if (Y(n), J(n), P[e] === 0 && L === "playing") {
|
|
116
|
+
let n = t === b[e] ? b[1 - e] : t;
|
|
117
117
|
Y({
|
|
118
118
|
k: "over",
|
|
119
119
|
winner: n
|
|
@@ -123,29 +123,29 @@ function P({ game: e, selfId: s, isHost: h = String(s) === String(e.hostId), sig
|
|
|
123
123
|
function ye(e, t) {
|
|
124
124
|
let n = [];
|
|
125
125
|
for (let { id: t, dmg: r } of e) {
|
|
126
|
-
let e =
|
|
127
|
-
e < 0 || !
|
|
126
|
+
let e = b.indexOf(t);
|
|
127
|
+
e < 0 || !O[e].alive || F[e] > M || (O[e].hp = Math.max(0, O[e].hp - r), O[e].alive = O[e].hp > 0, O[e].alive || n.push(e));
|
|
128
128
|
}
|
|
129
129
|
return () => n.forEach((e) => Q(e, t));
|
|
130
130
|
}
|
|
131
131
|
function be() {
|
|
132
|
-
|
|
132
|
+
O = b.map(E), k = [], P = [w, w], F = [0, 0], I = [null, null], ge(), U = [], W = null, G = null, de.clear(), K.clear(), fe.clear(), V = !1, H = null, R = null, L = B.phase === "connected" ? "playing" : "connecting", J({ k: "rematch" }), me();
|
|
133
133
|
}
|
|
134
134
|
function xe(e, t = !1) {
|
|
135
|
-
(
|
|
135
|
+
(L !== "over" || t && R !== e) && (L = "over", R = e, k = [], $.clearManualTurn?.(), J({
|
|
136
136
|
k: "over",
|
|
137
|
-
winner:
|
|
137
|
+
winner: R
|
|
138
138
|
}), me());
|
|
139
139
|
}
|
|
140
140
|
function Se(e, t, n) {
|
|
141
|
-
if (
|
|
142
|
-
let r =
|
|
143
|
-
if (!r?.alive ||
|
|
141
|
+
if (L !== "playing" || !le(t.id) || K.has(t.id)) return !1;
|
|
142
|
+
let r = O.find((t) => t.id === e);
|
|
143
|
+
if (!r?.alive || M - (de.get(e) ?? -Infinity) < d.reloadMs - 20 || ![
|
|
144
144
|
t.x,
|
|
145
145
|
t.z,
|
|
146
146
|
t.yaw
|
|
147
|
-
].every(
|
|
148
|
-
X(t.id), de.set(e,
|
|
147
|
+
].every(ce) || Math.hypot(t.x - (e === x && G ? G.x : r.x), t.z - (e === x && G ? G.z : r.z)) > 6) return !1;
|
|
148
|
+
X(t.id), de.set(e, M);
|
|
149
149
|
let i = {
|
|
150
150
|
...t,
|
|
151
151
|
k: "fire",
|
|
@@ -155,34 +155,34 @@ function P({ game: e, selfId: s, isHost: h = String(s) === String(e.hostId), sig
|
|
|
155
155
|
y: 1.4,
|
|
156
156
|
age: 0
|
|
157
157
|
};
|
|
158
|
-
return
|
|
158
|
+
return k.push(i), J(i), n && Y({
|
|
159
159
|
...t,
|
|
160
160
|
k: "fire"
|
|
161
161
|
}), !0;
|
|
162
162
|
}
|
|
163
|
-
function Ce(
|
|
164
|
-
if (
|
|
165
|
-
let [n,
|
|
166
|
-
if (!pe().alive || !
|
|
167
|
-
...
|
|
163
|
+
function Ce(e) {
|
|
164
|
+
if (z || L !== "playing" || e?.g !== o.gameId || e.r !== N || !Array.isArray(e.p) || e.p.length !== 5 || !e.p.every(ce)) return;
|
|
165
|
+
let [t, n, i, a, s] = e.p;
|
|
166
|
+
if (!pe().alive || !r(t, n, {
|
|
167
|
+
...C,
|
|
168
168
|
destructibles: []
|
|
169
|
-
}) || Math.abs(s) >
|
|
170
|
-
let c = W === null ? .1 : Math.max(0, (
|
|
171
|
-
if (Math.hypot(
|
|
169
|
+
}) || Math.abs(s) > d.speed + .1 || Math.abs(i) > 1e6 || Math.abs(a) > 1e6) return;
|
|
170
|
+
let c = W === null ? .1 : Math.max(0, (M - W) / 1e3), l = G || pe();
|
|
171
|
+
if (Math.hypot(t - l.x, n - l.z) > d.speed * c + 3) return;
|
|
172
172
|
let u = {
|
|
173
173
|
...pe(),
|
|
174
|
-
x:
|
|
175
|
-
z:
|
|
176
|
-
yaw:
|
|
177
|
-
turretYaw:
|
|
174
|
+
x: t,
|
|
175
|
+
z: n,
|
|
176
|
+
yaw: i,
|
|
177
|
+
turretYaw: a,
|
|
178
178
|
speed: s
|
|
179
179
|
};
|
|
180
|
-
G = u, W =
|
|
181
|
-
time:
|
|
180
|
+
G = u, W = M, U.push({
|
|
181
|
+
time: M,
|
|
182
182
|
pose: u
|
|
183
183
|
}), U.length > 30 && U.shift();
|
|
184
184
|
}
|
|
185
|
-
let we = (e, t) => Object.keys(e).every((e) => t.includes(e)), Te = (e) => Array.isArray(e) && e.length === 2 && e.every((e) => Number.isInteger(e) && e >= 0 && e <=
|
|
185
|
+
let we = (e, t) => Object.keys(e).every((e) => t.includes(e)), Te = (e) => Array.isArray(e) && e.length === 2 && e.every((e) => Number.isInteger(e) && e >= 0 && e <= w), Ee = (e) => Te(e.lives) && Array.isArray(e.shield) && e.shield.length === 2 && e.shield.every((e) => Number.isInteger(e) && e >= 0 && e <= se.shieldMs) && Array.isArray(e.destructibles) && e.destructibles.length === T.length && e.destructibles.every((e, t) => e && we(e, ["id", "hp"]) && e.id === T[t].id && Number.isInteger(e.hp) && e.hp >= 0 && e.hp <= T[t].hp);
|
|
186
186
|
function De(e, t, n, r) {
|
|
187
187
|
J({
|
|
188
188
|
k: "destructible_hit",
|
|
@@ -199,50 +199,50 @@ function P({ game: e, selfId: s, isHost: h = String(s) === String(e.hostId), sig
|
|
|
199
199
|
z: e.z
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
|
-
function Oe(
|
|
203
|
-
if (
|
|
204
|
-
if (
|
|
205
|
-
|
|
202
|
+
function Oe(e) {
|
|
203
|
+
if (z || !e || e.g !== o.gameId || !Number.isInteger(e.r)) return;
|
|
204
|
+
if (e.k === "round" && !h && L === "over" && fe.has(m) && e.r === N + 1) {
|
|
205
|
+
N = e.r, be();
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
-
if (
|
|
209
|
-
if (
|
|
208
|
+
if (e.r !== N) return;
|
|
209
|
+
if (e.k === "sync" && h) {
|
|
210
210
|
Y(he());
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
|
-
if (
|
|
214
|
-
if (!
|
|
215
|
-
let
|
|
213
|
+
if (e.k === "snapshot" && !h && Array.isArray(e.hp) && e.hp.length === 2 && e.hp.every((e) => Number.isInteger(e) && e >= 0 && e <= 100)) {
|
|
214
|
+
if (!S && !Ee(e)) return;
|
|
215
|
+
let t = S ? P : e.lives, n = e.status === "playing" && e.winner === null && e.hp.every((e, n) => e > 0 || !S && t[n] > 0), r = e.status === "over" && b.includes(e.winner) && (e.hp[1 - b.indexOf(e.winner)] === 0 && t[1 - b.indexOf(e.winner)] === (S ? P[1 - b.indexOf(e.winner)] : 0) || e.reason === "resigned");
|
|
216
216
|
if (!n && !r) return;
|
|
217
|
-
|
|
218
|
-
let n =
|
|
217
|
+
S || (e.destructibles.forEach((e, t) => {
|
|
218
|
+
let n = C.destructibles[t];
|
|
219
219
|
n.hp = e.hp, n.alive = e.hp > 0;
|
|
220
|
-
}),
|
|
221
|
-
let r =
|
|
222
|
-
|
|
223
|
-
})),
|
|
224
|
-
|
|
225
|
-
}), r && (V = !1, H =
|
|
220
|
+
}), O.forEach((t, n) => {
|
|
221
|
+
let r = t.hp === 0;
|
|
222
|
+
P[n] = e.lives[n], r && e.hp[n] > 0 && _e(n), F[n] = e.shield[n] ? M + e.shield[n] : 0, e.hp[n] === 0 && P[n] > 0 && I[n] === null && (I[n] = M + se.respawnMs);
|
|
223
|
+
})), O.forEach((t, n) => {
|
|
224
|
+
t.hp = e.hp[n], t.alive = t.hp > 0;
|
|
225
|
+
}), r && (V = !1, H = e.reason, xe(e.winner, !0));
|
|
226
226
|
return;
|
|
227
227
|
}
|
|
228
|
-
if (
|
|
229
|
-
H = "resigned", xe(
|
|
228
|
+
if (e.k === "resign") {
|
|
229
|
+
H = "resigned", xe(m, h), h && Y(he());
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
|
-
if (
|
|
233
|
-
fe.add(
|
|
232
|
+
if (e.k === "rematch" && L === "over") {
|
|
233
|
+
fe.add(x), ke();
|
|
234
234
|
return;
|
|
235
235
|
}
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
}),
|
|
239
|
-
let
|
|
240
|
-
if (
|
|
236
|
+
if (L !== "playing" || (e.k === "fire" && Se(x, e, !1), !h && e.k === "hit" && le(e.id) && !K.has(`hit:${e.id}`) && b.includes(e.target) && Array.isArray(e.hp) && e.hp.length === 2 && e.hp.every((e, t) => Number.isInteger(e) && e >= 0 && e <= O[t].hp) && [e.x, e.z].every(ce) && (X(`hit:${e.id}`), O.forEach((t, n) => {
|
|
237
|
+
t.hp = e.hp[n], t.alive = t.hp > 0;
|
|
238
|
+
}), k = k.filter((t) => t.id !== e.id), J(e)), !h && e.k === "destroyed" && b.includes(e.target) && !K.has(`destroyed:${e.target}:${P[b.indexOf(e.target)]}`) && O.find((t) => t.id === e.target).hp === 0 && (X(`destroyed:${e.target}:${P[b.indexOf(e.target)]}`), J(e)), !h && e.k === "over" && b.includes(e.winner) && O.find((t) => t.id !== e.winner).hp === 0 && (S || P[1 - b.indexOf(e.winner)] === 0) && xe(e.winner), h || S)) return;
|
|
239
|
+
let t = b.indexOf(e.target);
|
|
240
|
+
if (e.k === "life_lost" && t >= 0 && O[t].hp === 0 && Te(e.lives) && e.lives[t] === P[t] - 1 && e.lives[1 - t] === P[1 - t] && ve(t, e.lives[t]), e.k === "respawn" && t >= 0 && O[t].hp === 0 && P[t] > 0 && we(e, [
|
|
241
241
|
"k",
|
|
242
242
|
"target",
|
|
243
243
|
"g",
|
|
244
244
|
"r"
|
|
245
|
-
]) && _e(
|
|
245
|
+
]) && _e(t), e.k === "destructible_hit" && le(e.id) && !K.has(`dh:${e.id}`) && we(e, [
|
|
246
246
|
"k",
|
|
247
247
|
"id",
|
|
248
248
|
"target",
|
|
@@ -251,97 +251,97 @@ function P({ game: e, selfId: s, isHost: h = String(s) === String(e.hostId), sig
|
|
|
251
251
|
"z",
|
|
252
252
|
"g",
|
|
253
253
|
"r"
|
|
254
|
-
]) && [
|
|
255
|
-
let
|
|
256
|
-
if (!
|
|
257
|
-
X(`dh:${
|
|
254
|
+
]) && [e.x, e.z].every(ce)) {
|
|
255
|
+
let t = D(e.target);
|
|
256
|
+
if (!n(t) || !Number.isInteger(e.hp) || e.hp < 0 || e.hp >= t.hp) return;
|
|
257
|
+
X(`dh:${e.id}`), t.hp = e.hp, t.alive = e.hp > 0, k = k.filter((t) => t.id !== e.id), De(t, e.id, e.x, e.z);
|
|
258
258
|
}
|
|
259
|
-
if (
|
|
259
|
+
if (e.k === "barrel_explode" && we(e, [
|
|
260
260
|
"k",
|
|
261
261
|
"target",
|
|
262
262
|
"chained",
|
|
263
263
|
"hp",
|
|
264
264
|
"g",
|
|
265
265
|
"r"
|
|
266
|
-
]) && !K.has(`be:${
|
|
267
|
-
let
|
|
268
|
-
if (
|
|
269
|
-
X(`be:${
|
|
270
|
-
|
|
266
|
+
]) && !K.has(`be:${e.target}`)) {
|
|
267
|
+
let t = D(e.target), r = e.chained === null ? null : D(e.chained);
|
|
268
|
+
if (t?.kind !== "barrel" || n(t) || e.chained !== null && (r?.kind !== "barrel" || !n(r) || r === t) || !Array.isArray(e.hp) || e.hp.length !== 2 || !e.hp.every((e, t) => Number.isInteger(e) && e >= 0 && e <= O[t].hp)) return;
|
|
269
|
+
X(`be:${e.target}`), r && (r.hp = 0, r.alive = !1), O.forEach((t, n) => {
|
|
270
|
+
t.hp = e.hp[n], t.alive = t.hp > 0;
|
|
271
271
|
}), J({
|
|
272
272
|
k: "barrel_explode",
|
|
273
|
-
id:
|
|
274
|
-
x:
|
|
275
|
-
z:
|
|
276
|
-
chained:
|
|
277
|
-
id:
|
|
278
|
-
x:
|
|
279
|
-
z:
|
|
273
|
+
id: t.id,
|
|
274
|
+
x: t.x,
|
|
275
|
+
z: t.z,
|
|
276
|
+
chained: r ? {
|
|
277
|
+
id: r.id,
|
|
278
|
+
x: r.x,
|
|
279
|
+
z: r.z
|
|
280
280
|
} : null,
|
|
281
|
-
hp: [...
|
|
281
|
+
hp: [...e.hp]
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
let $ = v({
|
|
286
286
|
configurationAuthority: h,
|
|
287
287
|
signaling: g && {
|
|
288
|
-
send(
|
|
289
|
-
let
|
|
290
|
-
if (!
|
|
291
|
-
let
|
|
292
|
-
...
|
|
293
|
-
liveGame:
|
|
288
|
+
send(e) {
|
|
289
|
+
let t = p(e);
|
|
290
|
+
if (!t) return Promise.reject(/* @__PURE__ */ Error("Invalid live signal"));
|
|
291
|
+
let n = ee({
|
|
292
|
+
...t,
|
|
293
|
+
liveGame: o.gameId
|
|
294
294
|
});
|
|
295
|
-
return
|
|
295
|
+
return n ? g.send(n) : Promise.reject(/* @__PURE__ */ Error("Live signal too large"));
|
|
296
296
|
},
|
|
297
|
-
subscribe(
|
|
298
|
-
return g.subscribe((
|
|
299
|
-
|
|
297
|
+
subscribe(e) {
|
|
298
|
+
return g.subscribe((t) => {
|
|
299
|
+
p(t?.text)?.liveGame === o.gameId && e(t);
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
302
|
},
|
|
303
|
-
selfId:
|
|
304
|
-
peerId:
|
|
305
|
-
roomId:
|
|
306
|
-
iceServers:
|
|
307
|
-
iceTransportPolicy:
|
|
308
|
-
RTCPeerConnectionImpl:
|
|
303
|
+
selfId: m,
|
|
304
|
+
peerId: x,
|
|
305
|
+
roomId: o.roomId,
|
|
306
|
+
iceServers: y,
|
|
307
|
+
iceTransportPolicy: te,
|
|
308
|
+
RTCPeerConnectionImpl: ne,
|
|
309
309
|
onMove: Ce,
|
|
310
310
|
onEvent: Oe,
|
|
311
311
|
onChange(e) {
|
|
312
|
-
let t =
|
|
313
|
-
if (
|
|
314
|
-
let e =
|
|
315
|
-
|
|
316
|
-
|
|
312
|
+
let t = B.phase;
|
|
313
|
+
if (B = e, e.phase === "connected") {
|
|
314
|
+
let e = ue;
|
|
315
|
+
ue = !0, L !== "over" && (L = "playing"), t !== "connected" && queueMicrotask(() => {
|
|
316
|
+
z || (V && Y({ k: "resign" }), h && e ? Y(he()) : h || Y({ k: "sync" }));
|
|
317
317
|
});
|
|
318
|
-
} else
|
|
318
|
+
} else L !== "over" && (L = ue ? "disconnected" : "connecting");
|
|
319
319
|
me();
|
|
320
320
|
}
|
|
321
321
|
});
|
|
322
322
|
function ke() {
|
|
323
|
-
h && fe.size === 2 && (
|
|
323
|
+
h && fe.size === 2 && (N++, Y({ k: "round" }), be());
|
|
324
324
|
}
|
|
325
325
|
return h ? $.connect() : $.setListening(!0), {
|
|
326
326
|
setInput(e) {
|
|
327
|
-
|
|
327
|
+
j = { ...e };
|
|
328
328
|
},
|
|
329
|
-
step(
|
|
330
|
-
if (
|
|
331
|
-
let
|
|
332
|
-
if (
|
|
333
|
-
let
|
|
334
|
-
for (let e = 0; e < 2; e++)
|
|
329
|
+
step(n) {
|
|
330
|
+
if (z) return;
|
|
331
|
+
let r = Math.max(0, Math.min(Number(n) || 0, 100));
|
|
332
|
+
if (M += r, L !== "playing") return;
|
|
333
|
+
let i = r / 1e3;
|
|
334
|
+
for (let e = 0; e < 2; e++) F[e] && M >= F[e] && (F[e] = 0, J({
|
|
335
335
|
k: "shield_end",
|
|
336
|
-
target:
|
|
337
|
-
})), h &&
|
|
336
|
+
target: b[e]
|
|
337
|
+
})), h && I[e] !== null && M >= I[e] && P[e] > 0 && (_e(e), Y({
|
|
338
338
|
k: "respawn",
|
|
339
|
-
target:
|
|
339
|
+
target: b[e]
|
|
340
340
|
}));
|
|
341
|
-
let
|
|
342
|
-
for (; U.length > 1 && U[1].time <=
|
|
341
|
+
let c = M - 100;
|
|
342
|
+
for (; U.length > 1 && U[1].time <= c;) U.shift();
|
|
343
343
|
if (U.length) {
|
|
344
|
-
let e = U[0], t = U[1] || e, n =
|
|
344
|
+
let e = U[0], t = U[1] || e, n = a(e.pose, t.pose, t.time === e.time ? 1 : (c - e.time) / (t.time - e.time));
|
|
345
345
|
for (let e of [
|
|
346
346
|
"x",
|
|
347
347
|
"z",
|
|
@@ -350,155 +350,155 @@ function P({ game: e, selfId: s, isHost: h = String(s) === String(e.hostId), sig
|
|
|
350
350
|
"speed"
|
|
351
351
|
]) pe()[e] = n[e];
|
|
352
352
|
}
|
|
353
|
-
for (let e =
|
|
354
|
-
|
|
355
|
-
id: `${
|
|
353
|
+
for (let e = i; e > 0; e -= .016) t(q(), j, Math.min(e, .016), C);
|
|
354
|
+
j.fire && Se(m, {
|
|
355
|
+
id: `${m}:${N}:${++oe}`,
|
|
356
356
|
x: q().x,
|
|
357
357
|
z: q().z,
|
|
358
358
|
yaw: q().turretYaw,
|
|
359
|
-
t:
|
|
359
|
+
t: M
|
|
360
360
|
}, !0);
|
|
361
|
-
let
|
|
362
|
-
if (
|
|
363
|
-
|
|
364
|
-
let
|
|
361
|
+
let u = B.rtt > 250 || B.move?.lossPct > 15 ? 10 : B.rtt > 100 ? 15 : 20;
|
|
362
|
+
if (M >= ae) {
|
|
363
|
+
ae = M + 1e3 / u;
|
|
364
|
+
let e = q();
|
|
365
365
|
$.sendMove({
|
|
366
|
-
g:
|
|
367
|
-
r:
|
|
366
|
+
g: o.gameId,
|
|
367
|
+
r: N,
|
|
368
368
|
p: [
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
369
|
+
e.x,
|
|
370
|
+
e.z,
|
|
371
|
+
e.yaw,
|
|
372
|
+
e.turretYaw,
|
|
373
|
+
e.speed
|
|
374
374
|
],
|
|
375
|
-
t:
|
|
375
|
+
t: M
|
|
376
376
|
});
|
|
377
377
|
}
|
|
378
|
-
|
|
379
|
-
let n =
|
|
378
|
+
k = k.filter((t) => {
|
|
379
|
+
let n = s(t, i, C, O);
|
|
380
380
|
if (!n) return !0;
|
|
381
|
-
if (h && n.target &&
|
|
381
|
+
if (h && n.target && L === "playing" && F[b.indexOf(n.target)] > M) J({
|
|
382
382
|
k: "impact",
|
|
383
383
|
kind: "shield",
|
|
384
384
|
target: n.target,
|
|
385
|
-
x:
|
|
386
|
-
z:
|
|
385
|
+
x: t.x,
|
|
386
|
+
z: t.z
|
|
387
387
|
});
|
|
388
|
-
else if (h && n.target &&
|
|
389
|
-
let
|
|
390
|
-
|
|
388
|
+
else if (h && n.target && L === "playing") {
|
|
389
|
+
let e = O.find((e) => e.id === n.target);
|
|
390
|
+
e.hp = Math.max(0, e.hp - d.damage), e.alive = e.hp > 0;
|
|
391
391
|
let r = {
|
|
392
392
|
k: "hit",
|
|
393
|
-
id:
|
|
394
|
-
target:
|
|
395
|
-
dmg:
|
|
396
|
-
hp:
|
|
397
|
-
x:
|
|
398
|
-
z:
|
|
393
|
+
id: t.id,
|
|
394
|
+
target: e.id,
|
|
395
|
+
dmg: d.damage,
|
|
396
|
+
hp: O.map((e) => e.hp),
|
|
397
|
+
x: t.x,
|
|
398
|
+
z: t.z
|
|
399
399
|
};
|
|
400
|
-
Y(r), J(r),
|
|
401
|
-
} else if (h && n.kind === "destructible" &&
|
|
402
|
-
let r =
|
|
400
|
+
Y(r), J(r), e.alive || Q(b.indexOf(e.id), t.owner);
|
|
401
|
+
} else if (h && n.kind === "destructible" && L === "playing") {
|
|
402
|
+
let r = D(n.id), i = e(C, n.id, 1);
|
|
403
403
|
if (Y({
|
|
404
404
|
k: "destructible_hit",
|
|
405
|
-
id:
|
|
405
|
+
id: t.id,
|
|
406
406
|
target: n.id,
|
|
407
407
|
hp: i.hp,
|
|
408
|
-
x:
|
|
409
|
-
z:
|
|
410
|
-
}), De(r,
|
|
411
|
-
let
|
|
408
|
+
x: t.x,
|
|
409
|
+
z: t.z
|
|
410
|
+
}), De(r, t.id, t.x, t.z), i.destroyed && r.kind === "barrel") {
|
|
411
|
+
let e = l(C, r.id, O), n = ye(e.hits, t.owner), i = {
|
|
412
412
|
k: "barrel_explode",
|
|
413
413
|
target: r.id,
|
|
414
|
-
chained:
|
|
415
|
-
hp:
|
|
414
|
+
chained: e.chained?.id ?? null,
|
|
415
|
+
hp: O.map((e) => e.hp)
|
|
416
416
|
};
|
|
417
417
|
Y(i), J({
|
|
418
418
|
k: "barrel_explode",
|
|
419
419
|
id: r.id,
|
|
420
420
|
x: r.x,
|
|
421
421
|
z: r.z,
|
|
422
|
-
chained:
|
|
422
|
+
chained: e.chained,
|
|
423
423
|
hp: [...i.hp]
|
|
424
424
|
}), n();
|
|
425
425
|
}
|
|
426
426
|
} else J({
|
|
427
427
|
k: "impact",
|
|
428
428
|
kind: n.kind,
|
|
429
|
-
x:
|
|
430
|
-
z:
|
|
429
|
+
x: t.x,
|
|
430
|
+
z: t.z
|
|
431
431
|
}), n.shape === "rect" && J({
|
|
432
432
|
k: "wall_hit",
|
|
433
433
|
id: n.id,
|
|
434
434
|
kind: n.obstacleKind,
|
|
435
|
-
x:
|
|
436
|
-
z:
|
|
435
|
+
x: t.x,
|
|
436
|
+
z: t.z
|
|
437
437
|
});
|
|
438
438
|
return !1;
|
|
439
439
|
});
|
|
440
440
|
},
|
|
441
441
|
getRender() {
|
|
442
442
|
let e = {
|
|
443
|
-
arena:
|
|
444
|
-
map:
|
|
445
|
-
maxLives:
|
|
446
|
-
lives: [...
|
|
443
|
+
arena: C,
|
|
444
|
+
map: C,
|
|
445
|
+
maxLives: w,
|
|
446
|
+
lives: [...P],
|
|
447
447
|
shield: [0, 1].map(Z),
|
|
448
|
-
respawn:
|
|
449
|
-
destructibles: (
|
|
448
|
+
respawn: I.map((e) => e === null ? null : Math.max(0, Math.round(e - M))),
|
|
449
|
+
destructibles: (C.destructibles || []).map((e) => ({
|
|
450
450
|
id: e.id,
|
|
451
451
|
kind: e.kind,
|
|
452
452
|
x: e.x,
|
|
453
453
|
z: e.z,
|
|
454
454
|
r: e.r,
|
|
455
455
|
hp: e.hp,
|
|
456
|
-
alive:
|
|
456
|
+
alive: n(e)
|
|
457
457
|
})),
|
|
458
|
-
tanks:
|
|
458
|
+
tanks: O.map((e) => ({
|
|
459
459
|
...e,
|
|
460
|
-
self: e.id ===
|
|
461
|
-
reload: Math.min(1, (
|
|
460
|
+
self: e.id === m,
|
|
461
|
+
reload: Math.min(1, (M - (de.get(e.id) ?? -Infinity)) / d.reloadMs)
|
|
462
462
|
})),
|
|
463
|
-
shells:
|
|
464
|
-
events:
|
|
465
|
-
status:
|
|
466
|
-
winner:
|
|
463
|
+
shells: k.map((e) => ({ ...e })),
|
|
464
|
+
events: A,
|
|
465
|
+
status: L,
|
|
466
|
+
winner: R,
|
|
467
467
|
net: {
|
|
468
|
-
...
|
|
469
|
-
turnConfigured:
|
|
468
|
+
...B,
|
|
469
|
+
turnConfigured: B.turnConfigured ?? re
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
|
-
return
|
|
472
|
+
return A = [], e;
|
|
473
473
|
},
|
|
474
474
|
configureTurn(e, t) {
|
|
475
|
-
return
|
|
475
|
+
return z || L === "over" ? Promise.reject(/* @__PURE__ */ Error("La partida ya terminó.")) : $.configureTurn(e, t);
|
|
476
476
|
},
|
|
477
477
|
reconnect() {
|
|
478
|
-
!
|
|
478
|
+
!z && L !== "over" && ($.requestReconnect ? $.requestReconnect() : $.connect());
|
|
479
479
|
},
|
|
480
480
|
rematch() {
|
|
481
|
-
!
|
|
481
|
+
!z && L === "over" && (fe.add(m), Y({ k: "rematch" }), ke());
|
|
482
482
|
},
|
|
483
483
|
resign() {
|
|
484
|
-
!
|
|
484
|
+
!z && L !== "over" && (V = !0, H = "resigned", Y({ k: "resign" }), xe(x));
|
|
485
485
|
},
|
|
486
486
|
destroy() {
|
|
487
|
-
|
|
487
|
+
z || (z = !0, $.destroy(), k = [], U = [], A = []);
|
|
488
488
|
}
|
|
489
489
|
};
|
|
490
490
|
}
|
|
491
|
-
var
|
|
492
|
-
function
|
|
491
|
+
var I = 180 / Math.PI, L = (e, t) => Number.isFinite(e) ? e : t;
|
|
492
|
+
function R(e) {
|
|
493
493
|
let t = e || {}, n = t.bounds || t;
|
|
494
|
-
if (Number.isFinite(n.minX) && Number.isFinite(n.maxX) && Number.isFinite(n.minZ) && Number.isFinite(n.maxZ)) return
|
|
494
|
+
if (Number.isFinite(n.minX) && Number.isFinite(n.maxX) && Number.isFinite(n.minZ) && Number.isFinite(n.maxZ)) return z({
|
|
495
495
|
minX: n.minX,
|
|
496
496
|
minZ: n.minZ,
|
|
497
497
|
maxX: n.maxX,
|
|
498
498
|
maxZ: n.maxZ
|
|
499
499
|
});
|
|
500
|
-
let r =
|
|
501
|
-
return
|
|
500
|
+
let r = L(t.width, L(t.size, 120)), i = L(t.depth, L(t.height, L(t.size, r)));
|
|
501
|
+
return z(t.centered === !0 || t.origin === "center" ? {
|
|
502
502
|
minX: -r / 2,
|
|
503
503
|
minZ: -i / 2,
|
|
504
504
|
maxX: r / 2,
|
|
@@ -510,7 +510,7 @@ function L(e) {
|
|
|
510
510
|
maxZ: i
|
|
511
511
|
});
|
|
512
512
|
}
|
|
513
|
-
function
|
|
513
|
+
function z(e) {
|
|
514
514
|
return {
|
|
515
515
|
...e,
|
|
516
516
|
width: e.maxX - e.minX,
|
|
@@ -519,15 +519,15 @@ function R(e) {
|
|
|
519
519
|
cz: (e.minZ + e.maxZ) / 2
|
|
520
520
|
};
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function B(e) {
|
|
523
523
|
return (e?.obstacles || []).filter((e) => Number.isFinite(e?.x) && Number.isFinite(e?.z)).map((e) => ({
|
|
524
524
|
x: e.x,
|
|
525
525
|
z: e.z,
|
|
526
|
-
r:
|
|
526
|
+
r: L(e.r, L(e.radius, 1.5)),
|
|
527
527
|
kind: e.kind === "tree" ? "tree" : "rock"
|
|
528
528
|
}));
|
|
529
529
|
}
|
|
530
|
-
var
|
|
530
|
+
var ue = (e) => e ? e.k ?? e.type ?? null : null;
|
|
531
531
|
function V(e, t) {
|
|
532
532
|
let n = t || [], r = e?.tank ?? e?.by ?? e?.owner ?? e?.from;
|
|
533
533
|
if (r != null) {
|
|
@@ -578,7 +578,7 @@ function de({ moveSpeed: e = .6, turnSpeed: t = .35, holdMs: n = 160 } = {}) {
|
|
|
578
578
|
};
|
|
579
579
|
}
|
|
580
580
|
function K(e) {
|
|
581
|
-
switch (
|
|
581
|
+
switch (ue(e)) {
|
|
582
582
|
case "fire": return [{ type: "fire" }, { type: "projectile_start" }];
|
|
583
583
|
case "impact": return [{
|
|
584
584
|
type: "impact",
|
|
@@ -613,16 +613,16 @@ function Y(e) {
|
|
|
613
613
|
shape: "rect",
|
|
614
614
|
x: e.x,
|
|
615
615
|
z: e.z,
|
|
616
|
-
w:
|
|
617
|
-
d:
|
|
618
|
-
rot:
|
|
616
|
+
w: L(e.w, 2),
|
|
617
|
+
d: L(e.d, 2),
|
|
618
|
+
rot: L(e.rot, 0),
|
|
619
619
|
kind: e.kind || "wall"
|
|
620
620
|
} : {
|
|
621
621
|
id: e.id,
|
|
622
622
|
shape: "circle",
|
|
623
623
|
x: e.x,
|
|
624
624
|
z: e.z,
|
|
625
|
-
r:
|
|
625
|
+
r: L(e.r, L(e.radius, 1.5)),
|
|
626
626
|
kind: e.kind || "rock"
|
|
627
627
|
});
|
|
628
628
|
}
|
|
@@ -631,7 +631,7 @@ function X(e) {
|
|
|
631
631
|
id: String(e.id),
|
|
632
632
|
x: e.x,
|
|
633
633
|
z: e.z,
|
|
634
|
-
r:
|
|
634
|
+
r: L(e.r, e.kind === "barrel" ? .9 : 1.2),
|
|
635
635
|
kind: e.kind === "barrel" ? "barrel" : "crate"
|
|
636
636
|
}));
|
|
637
637
|
}
|
|
@@ -665,7 +665,7 @@ var Q = /* @__PURE__ */ new Set([
|
|
|
665
665
|
"health_pickup"
|
|
666
666
|
]);
|
|
667
667
|
function ye(e, t) {
|
|
668
|
-
let n =
|
|
668
|
+
let n = ue(e), r = e?.target ?? e?.tank ?? e?.id, i = U(t?.tanks), a = i != null && r != null && String(r) === String(i.id);
|
|
669
669
|
switch (n) {
|
|
670
670
|
case "life_lost": return ["life_lost"];
|
|
671
671
|
case "crate_break": return ["crate_break"];
|
|
@@ -726,10 +726,10 @@ function Ce(e, { arena: t } = {}) {
|
|
|
726
726
|
n.style.cssText = "width:100%;height:100%;display:block", e.appendChild(n);
|
|
727
727
|
let r = n.getContext("2d");
|
|
728
728
|
if (!r) throw n.remove(), Error("Canvas 2D unavailable");
|
|
729
|
-
let i =
|
|
729
|
+
let i = R(t), a = me(t) ? t : null, o = a ? be[a.id] : {
|
|
730
730
|
bg: "#152519",
|
|
731
731
|
ground: "#526348"
|
|
732
|
-
}, s = a ? Y(t) :
|
|
732
|
+
}, s = a ? Y(t) : B(t).map((e) => ({
|
|
733
733
|
...e,
|
|
734
734
|
shape: "circle"
|
|
735
735
|
})), c = a ? X(t) : [], l = a ? (t.decor || []).filter((e) => Se[e?.kind] && Number.isFinite(e.x) && Number.isFinite(e.z)) : [], u = 0, d = 1, f = 1, p = 1, ee = 0, m = 0;
|
|
@@ -770,19 +770,19 @@ function Ce(e, { arena: t } = {}) {
|
|
|
770
770
|
};
|
|
771
771
|
}
|
|
772
772
|
// src/games/tanks-live/TanksLiveGameCard.jsx
|
|
773
|
-
var we = /* @__PURE__ */
|
|
774
|
-
|
|
773
|
+
var we = /* @__PURE__ */ y({ default: () => je }), Te = (e, t) => {
|
|
774
|
+
o.getState().act(e, t).catch(() => {});
|
|
775
775
|
}, Ee = (e) => {
|
|
776
776
|
e.throttle = 0, e.steer = 0, e.fire = !1;
|
|
777
777
|
}, De = 3e3, Oe = (e) => me(e?.map) ? e.map : e?.arena;
|
|
778
778
|
function $({ lives: e, max: t, label: n }) {
|
|
779
779
|
if (!Number.isFinite(e)) return null;
|
|
780
780
|
let r = Math.max(e, t || e);
|
|
781
|
-
return /* @__PURE__ */
|
|
781
|
+
return /* @__PURE__ */ A("span", {
|
|
782
782
|
className: `tl-hearts${e === 1 && r > 1 ? " tl-hearts--last" : ""}`,
|
|
783
783
|
role: "img",
|
|
784
784
|
"aria-label": `${n}: ${e} ${e === 1 ? "vida" : "vidas"}`,
|
|
785
|
-
children: Array.from({ length: r }, (t, n) => /* @__PURE__ */
|
|
785
|
+
children: Array.from({ length: r }, (t, n) => /* @__PURE__ */ A("span", {
|
|
786
786
|
className: n < e ? "tl-heart" : "tl-heart tl-heart--lost",
|
|
787
787
|
"aria-hidden": "true",
|
|
788
788
|
children: n < e ? "❤️" : "🖤"
|
|
@@ -794,45 +794,45 @@ function ke(e, t) {
|
|
|
794
794
|
return n?.status === "applying" ? "Aplicando configuración…" : n?.status === "sharing" ? "Sincronizando con el otro jugador…" : n?.status === "waiting_peer" ? "Esperando al otro jugador para compartir la configuración…" : e?.phase === "connected" ? "¡Conexión establecida!" : n?.status === "failed" || e?.phase === "failed" || e?.ice === "failed" ? "No pudimos conectar. Puedes reintentar." : t ? "La conexión está tardando más de lo esperado" : e?.phase === "restarting" || e?.phase === "reconnecting" ? "Reconectando…" : e?.phase === "listening" ? "Esperando la conexión del otro jugador…" : e?.phase === "calling" ? "Buscando al otro jugador…" : e?.phase === "negotiating" ? "Buscando una conexión entre los jugadores…" : "Preparando partida…";
|
|
795
795
|
}
|
|
796
796
|
function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspended: i = !1 }) {
|
|
797
|
-
let a =
|
|
797
|
+
let a = T(m)?.config?.webrtc, s = o((t) => t.games[e]), c = D(i);
|
|
798
798
|
c.current = i;
|
|
799
|
-
let l =
|
|
799
|
+
let l = D(null), u = D(null), d = D(null), f = D({
|
|
800
800
|
throttle: 0,
|
|
801
801
|
steer: 0,
|
|
802
802
|
fire: !1
|
|
803
|
-
}), [p, ee] =
|
|
804
|
-
|
|
805
|
-
if (!
|
|
806
|
-
|
|
803
|
+
}), [p, ee] = O(null), [y, w] = O(""), [se, ce] = O(!1), [le, I] = O("loading"), [L, R] = O(!1), [z, B] = O(0), V = p?.net?.phase === "connected";
|
|
804
|
+
E(() => {
|
|
805
|
+
if (!s || s.status !== "active" || V) {
|
|
806
|
+
B(0);
|
|
807
807
|
return;
|
|
808
808
|
}
|
|
809
|
-
let e = Date.now(), t = setInterval(() =>
|
|
809
|
+
let e = Date.now(), t = setInterval(() => B(Date.now() - e), 1e3);
|
|
810
810
|
return () => clearInterval(t);
|
|
811
811
|
}, [
|
|
812
812
|
e,
|
|
813
|
-
|
|
813
|
+
s?.status,
|
|
814
814
|
V
|
|
815
|
-
]),
|
|
816
|
-
|
|
817
|
-
}, [e,
|
|
818
|
-
i ? (Ee(f.current),
|
|
815
|
+
]), E(() => {
|
|
816
|
+
R(!1);
|
|
817
|
+
}, [e, s?.status]), E(() => {
|
|
818
|
+
i ? (Ee(f.current), S()) : d.current?.resize();
|
|
819
819
|
}, [i]);
|
|
820
|
-
let H = ["active", "won"].includes(
|
|
821
|
-
if (
|
|
820
|
+
let H = ["active", "won"].includes(s?.status), [W, G] = O(null);
|
|
821
|
+
if (E(() => {
|
|
822
822
|
if (!H || !W || !l.current) return;
|
|
823
823
|
let e = !1, t = null, n = {
|
|
824
824
|
arena: W,
|
|
825
825
|
lowPower: matchMedia("(pointer: coarse)").matches,
|
|
826
826
|
reducedMotion: matchMedia("(prefers-reduced-motion: reduce)").matches,
|
|
827
827
|
onEvent: (e) => {
|
|
828
|
-
e.type === "context_lost" &&
|
|
828
|
+
e.type === "context_lost" && ce(!0);
|
|
829
829
|
}
|
|
830
830
|
}, r = () => {
|
|
831
|
-
e || (t = Ce(l.current, n), d.current = t,
|
|
831
|
+
e || (t = Ce(l.current, n), d.current = t, I("2d"));
|
|
832
832
|
};
|
|
833
|
-
return
|
|
833
|
+
return se ? r() : import("./createLiveScene-jrzyQogh.js").then(({ createLiveScene: i }) => {
|
|
834
834
|
if (!e) try {
|
|
835
|
-
t = i(l.current, n), d.current = t,
|
|
835
|
+
t = i(l.current, n), d.current = t, I("3d");
|
|
836
836
|
} catch {
|
|
837
837
|
r();
|
|
838
838
|
}
|
|
@@ -842,32 +842,32 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
842
842
|
}, [
|
|
843
843
|
H,
|
|
844
844
|
W,
|
|
845
|
-
|
|
846
|
-
]),
|
|
847
|
-
if (!H ||
|
|
845
|
+
se
|
|
846
|
+
]), E(() => {
|
|
847
|
+
if (!H || s.status !== "active" || !l.current) return;
|
|
848
848
|
let n = !1, r = 0, i = performance.now(), p = 0, m = null, h = de(), g = /* @__PURE__ */ new Set();
|
|
849
|
-
|
|
849
|
+
x();
|
|
850
850
|
let _;
|
|
851
851
|
try {
|
|
852
|
-
let n =
|
|
853
|
-
_ =
|
|
852
|
+
let n = o.getState().createLiveSignaling(e);
|
|
853
|
+
_ = F({
|
|
854
854
|
iceServers: a?.iceServers,
|
|
855
855
|
iceTransportPolicy: a?.iceTransportPolicy,
|
|
856
|
-
game:
|
|
856
|
+
game: s,
|
|
857
857
|
selfId: String(t),
|
|
858
|
-
isHost: String(
|
|
858
|
+
isHost: String(s.hostId) === String(t),
|
|
859
859
|
signaling: n
|
|
860
860
|
}), u.current = _;
|
|
861
861
|
} catch (e) {
|
|
862
|
-
|
|
862
|
+
w(e.message || "No se pudo iniciar WebRTC");
|
|
863
863
|
return;
|
|
864
864
|
}
|
|
865
865
|
G(Oe(_.getRender()));
|
|
866
|
-
let v = null,
|
|
867
|
-
function
|
|
868
|
-
g.clear(), Ee(f.current),
|
|
866
|
+
let v = null, y = !1;
|
|
867
|
+
function C() {
|
|
868
|
+
g.clear(), Ee(f.current), S();
|
|
869
869
|
}
|
|
870
|
-
function
|
|
870
|
+
function T(e, t) {
|
|
871
871
|
/^(INPUT|TEXTAREA|SELECT)$/.test(e.target?.tagName) || [
|
|
872
872
|
"KeyW",
|
|
873
873
|
"KeyA",
|
|
@@ -880,57 +880,57 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
880
880
|
"Space"
|
|
881
881
|
].includes(e.code) && (e.preventDefault(), t ? g.add(e.code) : g.delete(e.code), f.current.throttle = Number(g.has("KeyW") || g.has("ArrowUp")) - Number(g.has("KeyS") || g.has("ArrowDown")), f.current.steer = Number(g.has("KeyD") || g.has("ArrowRight")) - Number(g.has("KeyA") || g.has("ArrowLeft")), f.current.fire = g.has("Space"));
|
|
882
882
|
}
|
|
883
|
-
let
|
|
884
|
-
|
|
885
|
-
let
|
|
886
|
-
document.hidden &&
|
|
883
|
+
let E = (e) => T(e, !0), D = (e) => T(e, !1), O = l.current;
|
|
884
|
+
O.addEventListener("keydown", E), O.addEventListener("keyup", D), O.addEventListener("blur", C);
|
|
885
|
+
let k = () => {
|
|
886
|
+
document.hidden && C();
|
|
887
887
|
};
|
|
888
|
-
document.addEventListener("visibilitychange",
|
|
889
|
-
function
|
|
888
|
+
document.addEventListener("visibilitychange", k), re({ type: "engine_start" }, e);
|
|
889
|
+
function A(t) {
|
|
890
890
|
if (n) return;
|
|
891
891
|
let a = Math.min(80, t - i);
|
|
892
892
|
i = t;
|
|
893
|
-
let
|
|
894
|
-
_.setInput(
|
|
893
|
+
let s = c.current || document.hidden;
|
|
894
|
+
_.setInput(s ? {
|
|
895
895
|
throttle: 0,
|
|
896
896
|
steer: 0,
|
|
897
897
|
fire: !1
|
|
898
898
|
} : f.current), _.step(a);
|
|
899
899
|
let l = _.getRender();
|
|
900
|
-
if (
|
|
901
|
-
if (!
|
|
900
|
+
if (s || d.current?.render(l, a), s && (g.clear(), h.reset(), S(), y = !1), !s) for (let e of l.events || []) for (let t of K(e)) re(t, e.id);
|
|
901
|
+
if (!s) for (let e of l.events || []) for (let t of ye(e, l)) b(t);
|
|
902
902
|
let u = U(l.tanks);
|
|
903
903
|
for (let e of l.events || []) {
|
|
904
904
|
let n = e?.target ?? e?.tank;
|
|
905
|
-
u && n != null && String(n) === String(u.id) && (
|
|
905
|
+
u && n != null && String(n) === String(u.id) && (ue(e) === "life_lost" && (v = t + (Number.isFinite(e.respawnMs) ? e.respawnMs : De)), ue(e) === "respawn" && (v = null));
|
|
906
906
|
}
|
|
907
907
|
u?.alive !== !1 && v != null && t >= v && (v = null);
|
|
908
|
-
let
|
|
909
|
-
|
|
910
|
-
let
|
|
911
|
-
if (!
|
|
912
|
-
let
|
|
913
|
-
|
|
908
|
+
let x = !s && l.status === "playing" && u?.alive !== !1 && _e(l, u) > 0;
|
|
909
|
+
x !== y && (y = x, x ? te("shield_loop") : ne("shield_loop"));
|
|
910
|
+
let C = u ? l.tanks.indexOf(u) : -1, w = Number.isFinite(l.respawn?.[C]) ? l.respawn[C] : v != null && l.status === "playing" ? Math.max(0, v - t) : 0;
|
|
911
|
+
if (!s) for (let e of h.update(U(l.tanks), a)) re(e);
|
|
912
|
+
let T = fe(l);
|
|
913
|
+
T && !m && (v = null, ee({
|
|
914
914
|
...l,
|
|
915
915
|
respawnIn: 0
|
|
916
|
-
}), m =
|
|
916
|
+
}), m = T, s || ie(m, e), o.getState().liveFinish?.(e, l.winner)), t - p > 100 && (p = t, ee({
|
|
917
917
|
...l,
|
|
918
|
-
respawnIn:
|
|
919
|
-
})), r = requestAnimationFrame(
|
|
918
|
+
respawnIn: w
|
|
919
|
+
})), r = requestAnimationFrame(A);
|
|
920
920
|
}
|
|
921
|
-
return r = requestAnimationFrame(
|
|
922
|
-
n = !0, cancelAnimationFrame(r),
|
|
921
|
+
return r = requestAnimationFrame(A), () => {
|
|
922
|
+
n = !0, cancelAnimationFrame(r), C(), _.destroy(), u.current = null, O.removeEventListener("keydown", E), O.removeEventListener("keyup", D), O.removeEventListener("blur", C), document.removeEventListener("visibilitychange", k);
|
|
923
923
|
};
|
|
924
924
|
}, [
|
|
925
925
|
H,
|
|
926
926
|
e,
|
|
927
927
|
t
|
|
928
|
-
]), !
|
|
929
|
-
let q = String(t) === String(
|
|
928
|
+
]), !s) return null;
|
|
929
|
+
let q = String(t) === String(s.guestId), Y = p?.status === "over" || s.status === "won", X = p?.net, Z = X?.manualTurn, he = [
|
|
930
930
|
"waiting_peer",
|
|
931
931
|
"sharing",
|
|
932
932
|
"applying"
|
|
933
|
-
].includes(Z?.status), Q = !V && (
|
|
933
|
+
].includes(Z?.status), Q = !V && (z >= 12e3 || X?.phase === "failed" || X?.ice === "failed" || Z?.status === "failed" || !!y), be = me(W) ? W : null, xe = ve(p), Se = (p?.tanks || []).some((e) => Number.isFinite(ge(p, e))) && (be != null || xe > 1), we = Math.ceil((p?.respawnIn || 0) / 1e3), Ae = V ? X?.route?.relay === !0 ? "TURN Relay" : X?.route?.relay === !1 ? "P2P" : null : null, je = async (e, t) => {
|
|
934
934
|
if (!u.current?.configureTurn) throw Error("La partida aún no está preparada. Espera un momento y vuelve a intentarlo.");
|
|
935
935
|
await u.current.configureTurn(e, t);
|
|
936
936
|
};
|
|
@@ -954,22 +954,22 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
954
954
|
f.current[e] = e !== "fire" && 0;
|
|
955
955
|
}
|
|
956
956
|
});
|
|
957
|
-
return /* @__PURE__ */
|
|
957
|
+
return /* @__PURE__ */ j("section", {
|
|
958
958
|
className: `chat-game-card tl-card${H ? " tl-card--active" : ""}`,
|
|
959
959
|
"aria-label": "Tanques LIVE 3D",
|
|
960
960
|
children: [
|
|
961
|
-
/* @__PURE__ */
|
|
961
|
+
/* @__PURE__ */ j("header", {
|
|
962
962
|
className: "tl-header",
|
|
963
|
-
children: [/* @__PURE__ */
|
|
963
|
+
children: [/* @__PURE__ */ A("strong", { children: "Tanques LIVE 3D" }), /* @__PURE__ */ j("div", {
|
|
964
964
|
className: "tl-header-actions",
|
|
965
965
|
children: [
|
|
966
|
-
/* @__PURE__ */
|
|
967
|
-
n && /* @__PURE__ */
|
|
966
|
+
/* @__PURE__ */ A(h, { manager: C() }),
|
|
967
|
+
n && /* @__PURE__ */ A("button", {
|
|
968
968
|
onClick: n,
|
|
969
969
|
"aria-label": "Minimizar",
|
|
970
970
|
children: "−"
|
|
971
971
|
}),
|
|
972
|
-
r && /* @__PURE__ */
|
|
972
|
+
r && /* @__PURE__ */ A("button", {
|
|
973
973
|
onClick: r,
|
|
974
974
|
"aria-label": "Ocultar",
|
|
975
975
|
children: "×"
|
|
@@ -977,83 +977,83 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
977
977
|
]
|
|
978
978
|
})]
|
|
979
979
|
}),
|
|
980
|
-
|
|
980
|
+
s.status === "invited" && /* @__PURE__ */ j("div", {
|
|
981
981
|
className: "tl-invite",
|
|
982
982
|
children: [
|
|
983
|
-
/* @__PURE__ */
|
|
983
|
+
/* @__PURE__ */ A("span", {
|
|
984
984
|
className: "tl-invite-icon",
|
|
985
985
|
"aria-hidden": "true",
|
|
986
986
|
children: "🪖"
|
|
987
987
|
}),
|
|
988
|
-
/* @__PURE__ */
|
|
989
|
-
/* @__PURE__ */
|
|
990
|
-
q && /* @__PURE__ */
|
|
988
|
+
/* @__PURE__ */ A("strong", { children: q ? "¿Listo para combatir?" : "Invitación enviada" }),
|
|
989
|
+
/* @__PURE__ */ A("p", { children: q ? "Te invitaron a un combate en tiempo real." : "Esperando que el rival acepte…" }),
|
|
990
|
+
q && /* @__PURE__ */ j("div", {
|
|
991
991
|
className: "tl-invite-actions",
|
|
992
|
-
children: [/* @__PURE__ */
|
|
992
|
+
children: [/* @__PURE__ */ A("button", {
|
|
993
993
|
className: "tl-button-primary",
|
|
994
994
|
onClick: () => Te(e, "game_accept"),
|
|
995
995
|
children: "Aceptar combate"
|
|
996
|
-
}), /* @__PURE__ */
|
|
996
|
+
}), /* @__PURE__ */ A("button", {
|
|
997
997
|
onClick: () => Te(e, "game_decline"),
|
|
998
998
|
children: "Rechazar"
|
|
999
999
|
})]
|
|
1000
1000
|
})
|
|
1001
1001
|
]
|
|
1002
1002
|
}),
|
|
1003
|
-
H && !Y && /* @__PURE__ */
|
|
1003
|
+
H && !Y && /* @__PURE__ */ j("div", {
|
|
1004
1004
|
className: `tl-connection tl-connection--${V ? "connected" : Q ? "problem" : "pending"}`,
|
|
1005
1005
|
children: [
|
|
1006
|
-
/* @__PURE__ */
|
|
1006
|
+
/* @__PURE__ */ j("div", {
|
|
1007
1007
|
className: "tl-connection-heading",
|
|
1008
1008
|
children: [
|
|
1009
|
-
V ? /* @__PURE__ */
|
|
1009
|
+
V ? /* @__PURE__ */ A(ae, {
|
|
1010
1010
|
size: 18,
|
|
1011
1011
|
"aria-hidden": "true"
|
|
1012
|
-
}) : Q ? /* @__PURE__ */ M
|
|
1012
|
+
}) : Q ? /* @__PURE__ */ A(M, {
|
|
1013
1013
|
size: 18,
|
|
1014
1014
|
"aria-hidden": "true"
|
|
1015
|
-
}) : /* @__PURE__ */
|
|
1015
|
+
}) : /* @__PURE__ */ A(oe, {
|
|
1016
1016
|
size: 18,
|
|
1017
1017
|
className: "tl-connection-spinner",
|
|
1018
1018
|
"aria-hidden": "true"
|
|
1019
1019
|
}),
|
|
1020
|
-
/* @__PURE__ */
|
|
1021
|
-
Ae && /* @__PURE__ */
|
|
1020
|
+
/* @__PURE__ */ j("div", { children: [/* @__PURE__ */ A("strong", { children: Q ? "Problemas de conexión" : ke(X, !1) }), Q && /* @__PURE__ */ A("p", { children: "No pudimos establecer una conexión con el otro jugador. Puedes configurar una conexión alternativa para continuar." })] }),
|
|
1021
|
+
Ae && /* @__PURE__ */ A("span", {
|
|
1022
1022
|
className: "tl-route-badge",
|
|
1023
1023
|
children: Ae
|
|
1024
1024
|
})
|
|
1025
1025
|
]
|
|
1026
1026
|
}),
|
|
1027
|
-
!V && /* @__PURE__ */
|
|
1027
|
+
!V && /* @__PURE__ */ A("p", {
|
|
1028
1028
|
className: "tl-connection-message",
|
|
1029
1029
|
role: "status",
|
|
1030
|
-
children: Q ? ke(X,
|
|
1030
|
+
children: Q ? ke(X, z >= 12e3) : g(X)
|
|
1031
1031
|
}),
|
|
1032
|
-
Z?.status === "synchronized" && /* @__PURE__ */
|
|
1032
|
+
Z?.status === "synchronized" && /* @__PURE__ */ A("p", {
|
|
1033
1033
|
className: "tl-connection-shared",
|
|
1034
1034
|
role: "status",
|
|
1035
1035
|
children: Z.received ? "Configuración recibida del otro jugador y aplicada en ambos." : "Configuración compartida y aplicada en ambos jugadores."
|
|
1036
1036
|
}),
|
|
1037
|
-
Z?.expiresAt != null && Z.expiresAt <= Date.now() && /* @__PURE__ */
|
|
1037
|
+
Z?.expiresAt != null && Z.expiresAt <= Date.now() && /* @__PURE__ */ A("p", {
|
|
1038
1038
|
className: "tl-connection-expired",
|
|
1039
1039
|
role: "status",
|
|
1040
1040
|
children: "La validez indicada para las credenciales terminó. Introduce una configuración nueva si necesitas reconectar."
|
|
1041
1041
|
}),
|
|
1042
|
-
/* @__PURE__ */
|
|
1042
|
+
/* @__PURE__ */ j("div", {
|
|
1043
1043
|
className: "tl-connection-actions",
|
|
1044
|
-
children: [/* @__PURE__ */
|
|
1044
|
+
children: [/* @__PURE__ */ j("button", {
|
|
1045
1045
|
type: "button",
|
|
1046
1046
|
className: Q ? "tl-button-primary" : "",
|
|
1047
|
-
onClick: () =>
|
|
1048
|
-
children: [/* @__PURE__ */
|
|
1047
|
+
onClick: () => R(!0),
|
|
1048
|
+
children: [/* @__PURE__ */ A(P, {
|
|
1049
1049
|
size: 15,
|
|
1050
1050
|
"aria-hidden": "true"
|
|
1051
1051
|
}), "Configurar conexión alternativa"]
|
|
1052
|
-
}), !V && /* @__PURE__ */
|
|
1052
|
+
}), !V && /* @__PURE__ */ j("button", {
|
|
1053
1053
|
type: "button",
|
|
1054
1054
|
disabled: he,
|
|
1055
1055
|
onClick: () => u.current?.reconnect(),
|
|
1056
|
-
children: [/* @__PURE__ */
|
|
1056
|
+
children: [/* @__PURE__ */ A(N, {
|
|
1057
1057
|
size: 15,
|
|
1058
1058
|
"aria-hidden": "true"
|
|
1059
1059
|
}), "Reintentar conexión"]
|
|
@@ -1061,20 +1061,20 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
1061
1061
|
})
|
|
1062
1062
|
]
|
|
1063
1063
|
}),
|
|
1064
|
-
/* @__PURE__ */
|
|
1065
|
-
open:
|
|
1066
|
-
onClose: () =>
|
|
1064
|
+
/* @__PURE__ */ A(_, {
|
|
1065
|
+
open: L && H && !Y,
|
|
1066
|
+
onClose: () => R(!1),
|
|
1067
1067
|
onApply: je,
|
|
1068
1068
|
manualTurn: Z
|
|
1069
1069
|
}),
|
|
1070
|
-
(H || p) && /* @__PURE__ */
|
|
1071
|
-
/* @__PURE__ */
|
|
1070
|
+
(H || p) && /* @__PURE__ */ j(k, { children: [
|
|
1071
|
+
/* @__PURE__ */ j("div", {
|
|
1072
1072
|
className: "tl-hud",
|
|
1073
1073
|
children: [
|
|
1074
|
-
(p?.tanks || []).map((e) => /* @__PURE__ */
|
|
1074
|
+
(p?.tanks || []).map((e) => /* @__PURE__ */ j("span", { children: [
|
|
1075
1075
|
e.self ? "Tú" : "Rival",
|
|
1076
1076
|
" ",
|
|
1077
|
-
/* @__PURE__ */
|
|
1077
|
+
/* @__PURE__ */ A("meter", {
|
|
1078
1078
|
min: "0",
|
|
1079
1079
|
max: "100",
|
|
1080
1080
|
value: e.hp,
|
|
@@ -1083,18 +1083,18 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
1083
1083
|
" ",
|
|
1084
1084
|
e.hp,
|
|
1085
1085
|
" HP",
|
|
1086
|
-
Se && /* @__PURE__ */
|
|
1086
|
+
Se && /* @__PURE__ */ A($, {
|
|
1087
1087
|
lives: ge(p, e),
|
|
1088
1088
|
max: xe,
|
|
1089
1089
|
label: e.self ? "Tus vidas" : "Vidas del rival"
|
|
1090
1090
|
}),
|
|
1091
|
-
_e(p, e) > 0 && e.alive !== !1 && /* @__PURE__ */
|
|
1091
|
+
_e(p, e) > 0 && e.alive !== !1 && /* @__PURE__ */ A("span", {
|
|
1092
1092
|
className: "tl-shield-badge",
|
|
1093
1093
|
title: "Escudo activo",
|
|
1094
1094
|
children: "🛡️"
|
|
1095
1095
|
})
|
|
1096
1096
|
] }, e.id)),
|
|
1097
|
-
be && /* @__PURE__ */
|
|
1097
|
+
be && /* @__PURE__ */ j("span", {
|
|
1098
1098
|
className: "tl-map",
|
|
1099
1099
|
children: [
|
|
1100
1100
|
pe[be.id],
|
|
@@ -1102,17 +1102,17 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
1102
1102
|
J(be)
|
|
1103
1103
|
]
|
|
1104
1104
|
}),
|
|
1105
|
-
/* @__PURE__ */
|
|
1105
|
+
/* @__PURE__ */ j("span", {
|
|
1106
1106
|
role: "status",
|
|
1107
1107
|
children: [
|
|
1108
|
-
V ? Ae || "Conectado" : ke(X,
|
|
1108
|
+
V ? Ae || "Conectado" : ke(X, z >= 12e3),
|
|
1109
1109
|
" ",
|
|
1110
1110
|
Number.isFinite(X?.rtt) ? `· ${Math.round(X.rtt)} ms` : ""
|
|
1111
1111
|
]
|
|
1112
1112
|
})
|
|
1113
1113
|
]
|
|
1114
1114
|
}),
|
|
1115
|
-
we > 0 && !Y && /* @__PURE__ */
|
|
1115
|
+
we > 0 && !Y && /* @__PURE__ */ j("div", {
|
|
1116
1116
|
className: "tl-respawn",
|
|
1117
1117
|
role: "status",
|
|
1118
1118
|
children: [
|
|
@@ -1121,7 +1121,7 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
1121
1121
|
" s…"
|
|
1122
1122
|
]
|
|
1123
1123
|
}),
|
|
1124
|
-
/* @__PURE__ */
|
|
1124
|
+
/* @__PURE__ */ A("div", {
|
|
1125
1125
|
className: "tl-stage",
|
|
1126
1126
|
ref: l,
|
|
1127
1127
|
tabIndex: 0,
|
|
@@ -1140,10 +1140,10 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
1140
1140
|
f.current.fire = !1;
|
|
1141
1141
|
}
|
|
1142
1142
|
}),
|
|
1143
|
-
/* @__PURE__ */
|
|
1143
|
+
/* @__PURE__ */ j("div", {
|
|
1144
1144
|
className: "tl-controls",
|
|
1145
1145
|
children: [
|
|
1146
|
-
/* @__PURE__ */
|
|
1146
|
+
/* @__PURE__ */ A("div", {
|
|
1147
1147
|
className: "tl-joystick",
|
|
1148
1148
|
role: "group",
|
|
1149
1149
|
"aria-label": "Joystick de conducción",
|
|
@@ -1162,44 +1162,44 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
1162
1162
|
onLostPointerCapture: () => Ee(f.current),
|
|
1163
1163
|
children: "✥"
|
|
1164
1164
|
}),
|
|
1165
|
-
/* @__PURE__ */
|
|
1165
|
+
/* @__PURE__ */ j("div", {
|
|
1166
1166
|
className: "tl-drive",
|
|
1167
1167
|
"aria-label": "Controles de conducción",
|
|
1168
1168
|
children: [
|
|
1169
|
-
/* @__PURE__ */
|
|
1169
|
+
/* @__PURE__ */ A("button", {
|
|
1170
1170
|
"aria-label": "Avanzar",
|
|
1171
1171
|
...Ne("throttle", 1),
|
|
1172
1172
|
children: "▲"
|
|
1173
1173
|
}),
|
|
1174
|
-
/* @__PURE__ */
|
|
1174
|
+
/* @__PURE__ */ A("button", {
|
|
1175
1175
|
"aria-label": "Girar izquierda",
|
|
1176
1176
|
...Ne("steer", -1),
|
|
1177
1177
|
children: "◀"
|
|
1178
1178
|
}),
|
|
1179
|
-
/* @__PURE__ */
|
|
1179
|
+
/* @__PURE__ */ A("button", {
|
|
1180
1180
|
"aria-label": "Retroceder",
|
|
1181
1181
|
...Ne("throttle", -1),
|
|
1182
1182
|
children: "▼"
|
|
1183
1183
|
}),
|
|
1184
|
-
/* @__PURE__ */
|
|
1184
|
+
/* @__PURE__ */ A("button", {
|
|
1185
1185
|
"aria-label": "Girar derecha",
|
|
1186
1186
|
...Ne("steer", 1),
|
|
1187
1187
|
children: "▶"
|
|
1188
1188
|
})
|
|
1189
1189
|
]
|
|
1190
1190
|
}),
|
|
1191
|
-
/* @__PURE__ */
|
|
1191
|
+
/* @__PURE__ */ A("button", {
|
|
1192
1192
|
className: "tl-fire",
|
|
1193
1193
|
...Ne("fire", !0),
|
|
1194
1194
|
children: "Disparar"
|
|
1195
1195
|
})
|
|
1196
1196
|
]
|
|
1197
1197
|
}),
|
|
1198
|
-
/* @__PURE__ */
|
|
1198
|
+
/* @__PURE__ */ A("div", {
|
|
1199
1199
|
className: "tl-reload",
|
|
1200
|
-
children: /* @__PURE__ */
|
|
1200
|
+
children: /* @__PURE__ */ j("label", { children: [
|
|
1201
1201
|
"Recarga ",
|
|
1202
|
-
/* @__PURE__ */
|
|
1202
|
+
/* @__PURE__ */ A("progress", {
|
|
1203
1203
|
max: "1",
|
|
1204
1204
|
value: U(p?.tanks)?.reload ?? 1
|
|
1205
1205
|
}),
|
|
@@ -1207,60 +1207,60 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
1207
1207
|
(U(p?.tanks)?.reload ?? 1) >= 1 ? "Listo" : "Recargando…"
|
|
1208
1208
|
] })
|
|
1209
1209
|
}),
|
|
1210
|
-
/* @__PURE__ */
|
|
1211
|
-
/* @__PURE__ */
|
|
1212
|
-
onClick: () =>
|
|
1213
|
-
children:
|
|
1210
|
+
/* @__PURE__ */ A("small", { children: "WASD / flechas · ratón o toca la arena para apuntar · espacio / clic para disparar" }),
|
|
1211
|
+
/* @__PURE__ */ A("button", {
|
|
1212
|
+
onClick: () => ce((e) => !e),
|
|
1213
|
+
children: le === "2d" ? "Probar 3D" : "Vista 2D"
|
|
1214
1214
|
})
|
|
1215
1215
|
] }),
|
|
1216
|
-
Y && /* @__PURE__ */
|
|
1216
|
+
Y && /* @__PURE__ */ j("p", {
|
|
1217
1217
|
role: "status",
|
|
1218
1218
|
children: [
|
|
1219
|
-
String(p?.winner ??
|
|
1219
|
+
String(p?.winner ?? s.winnerId) === String(t) ? "¡Victoria!" : "Fin del combate",
|
|
1220
1220
|
" ",
|
|
1221
|
-
/* @__PURE__ */
|
|
1221
|
+
/* @__PURE__ */ A("button", {
|
|
1222
1222
|
onClick: () => {
|
|
1223
|
-
Promise.resolve(
|
|
1223
|
+
Promise.resolve(o.getState().liveRematch?.(e)).catch(() => {});
|
|
1224
1224
|
},
|
|
1225
1225
|
children: "Revancha"
|
|
1226
1226
|
}),
|
|
1227
|
-
be && /* @__PURE__ */
|
|
1227
|
+
be && /* @__PURE__ */ A("button", {
|
|
1228
1228
|
onClick: () => {
|
|
1229
|
-
Promise.resolve(
|
|
1229
|
+
Promise.resolve(o.getState().liveRematch?.(e, { newMap: !0 })).catch(() => {});
|
|
1230
1230
|
},
|
|
1231
1231
|
children: "Revancha en otro mapa 🎲"
|
|
1232
1232
|
})
|
|
1233
1233
|
]
|
|
1234
1234
|
}),
|
|
1235
|
-
H && /* @__PURE__ */
|
|
1235
|
+
H && /* @__PURE__ */ j("details", {
|
|
1236
1236
|
className: "tl-diagnostics",
|
|
1237
|
-
children: [/* @__PURE__ */
|
|
1237
|
+
children: [/* @__PURE__ */ A("summary", { children: "Diagnóstico de conexión" }), /* @__PURE__ */ A("pre", { children: JSON.stringify(v(p?.net), null, 2) })]
|
|
1238
1238
|
}),
|
|
1239
|
-
H && !Y && /* @__PURE__ */
|
|
1239
|
+
H && !Y && /* @__PURE__ */ A("button", {
|
|
1240
1240
|
onClick: () => u.current?.resign(),
|
|
1241
1241
|
children: "Rendirse"
|
|
1242
1242
|
}),
|
|
1243
|
-
|
|
1243
|
+
s.pending && /* @__PURE__ */ A("p", {
|
|
1244
1244
|
role: "status",
|
|
1245
1245
|
children: "Enviando…"
|
|
1246
1246
|
}),
|
|
1247
|
-
|
|
1247
|
+
s.pendingEvent && s.error && /* @__PURE__ */ A("button", {
|
|
1248
1248
|
onClick: () => {
|
|
1249
|
-
|
|
1249
|
+
o.getState().retry(e).catch(() => {});
|
|
1250
1250
|
},
|
|
1251
1251
|
children: "Reintentar envío"
|
|
1252
1252
|
}),
|
|
1253
|
-
|
|
1253
|
+
y && /* @__PURE__ */ A("p", {
|
|
1254
1254
|
role: "alert",
|
|
1255
|
-
children:
|
|
1255
|
+
children: y
|
|
1256
1256
|
}),
|
|
1257
|
-
|
|
1257
|
+
s.error && /* @__PURE__ */ A("p", {
|
|
1258
1258
|
role: "alert",
|
|
1259
|
-
children:
|
|
1259
|
+
children: s.error
|
|
1260
1260
|
}),
|
|
1261
|
-
!["closed", "declined"].includes(
|
|
1261
|
+
!["closed", "declined"].includes(s.status) && /* @__PURE__ */ A("footer", {
|
|
1262
1262
|
className: "tl-footer",
|
|
1263
|
-
children: /* @__PURE__ */
|
|
1263
|
+
children: /* @__PURE__ */ A("button", {
|
|
1264
1264
|
onClick: () => Te(e, "game_end"),
|
|
1265
1265
|
children: "Cerrar partida"
|
|
1266
1266
|
})
|
|
@@ -1268,7 +1268,7 @@ function Ae({ gameKey: e, currentUserId: t, onMinimize: n, onDismiss: r, suspend
|
|
|
1268
1268
|
]
|
|
1269
1269
|
});
|
|
1270
1270
|
}
|
|
1271
|
-
var je =
|
|
1272
|
-
export { W as a, X as c, V as d, je as default, H as f,
|
|
1271
|
+
var je = w(Ae);
|
|
1272
|
+
export { W as a, X as c, V as d, je as default, H as f, B as i, Y as l, I as n, ue as o, G as p, R as r, me as s, we as t, _e as u };
|
|
1273
1273
|
|
|
1274
|
-
//# sourceMappingURL=TanksLiveGameCard-
|
|
1274
|
+
//# sourceMappingURL=TanksLiveGameCard-DXgd1J2Y.js.map
|