@minicode-dev/chat 0.1.9 → 0.1.10
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/dist/chunks/{BattleshipGameCard-BFqA0cjT.js → BattleshipGameCard-iRk8d4vR.js} +2 -2
- package/dist/chunks/{BattleshipGameCard-BFqA0cjT.js.map → BattleshipGameCard-iRk8d4vR.js.map} +1 -1
- package/dist/chunks/{ChatContext-dty_KPDX.js → ChatContext-DjIEifGY.js} +2 -2
- package/dist/chunks/{ChatContext-dty_KPDX.js.map → ChatContext-DjIEifGY.js.map} +1 -1
- package/dist/chunks/{TanksGameCard-D0n-lzTs.js → TanksGameCard-B47ZQcSr.js} +4 -4
- package/dist/chunks/{TanksGameCard-D0n-lzTs.js.map → TanksGameCard-B47ZQcSr.js.map} +1 -1
- package/dist/chunks/{TanksLiveGameCard-BmNRXP66.js → TanksLiveGameCard-BxQGR8P9.js} +264 -216
- package/dist/chunks/TanksLiveGameCard-BxQGR8P9.js.map +1 -0
- package/dist/chunks/{WebRtcLab-B7xBlJy1.js → WebRtcLab-lijo_Rta.js} +2 -2
- package/dist/chunks/{WebRtcLab-B7xBlJy1.js.map → WebRtcLab-lijo_Rta.js.map} +1 -1
- package/dist/chunks/{connect4Sounds-BN7d_TM2.js → connect4Sounds-Cv0q31VW.js} +527 -517
- package/dist/chunks/connect4Sounds-Cv0q31VW.js.map +1 -0
- package/dist/chunks/{createLiveScene-CtYPcOPo.js → createLiveScene-GkalLsqm.js} +2 -2
- package/dist/chunks/{createLiveScene-CtYPcOPo.js.map → createLiveScene-GkalLsqm.js.map} +1 -1
- package/dist/chunks/{createPeerLink-qei05vpV.js → createPeerLink-CL7VZuHS.js} +5 -3
- package/dist/chunks/createPeerLink-CL7VZuHS.js.map +1 -0
- package/dist/chunks/{tanksSounds-C99OD2xD.js → tanksSounds-CUNDIOal.js} +3 -3
- package/dist/chunks/{tanksSounds-C99OD2xD.js.map → tanksSounds-CUNDIOal.js.map} +1 -1
- package/dist/index.js +1533 -1533
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunks/TanksLiveGameCard-BmNRXP66.js.map +0 -1
- package/dist/chunks/connect4Sounds-BN7d_TM2.js.map +0 -1
- package/dist/chunks/createPeerLink-qei05vpV.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as e, o as t } from "./connect4Sounds-
|
|
2
|
-
import { a as n, n as r, o as i } from "./createPeerLink-
|
|
3
|
-
import { t as a } from "./ChatContext-
|
|
4
|
-
import { a as o, i as s, n as c, r as l, t as u } from "./tanksSounds-
|
|
1
|
+
import { d as e, o as t } from "./connect4Sounds-Cv0q31VW.js";
|
|
2
|
+
import { a as n, n as r, o as i } from "./createPeerLink-CL7VZuHS.js";
|
|
3
|
+
import { t as a } from "./ChatContext-DjIEifGY.js";
|
|
4
|
+
import { a as o, i as s, n as c, r as l, t as u } from "./tanksSounds-CUNDIOal.js";
|
|
5
5
|
import { memo as d, useContext as f, useEffect as p, useRef as m, useState as h } from "react";
|
|
6
6
|
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
7
7
|
// \0rolldown/runtime.js
|
|
@@ -12,7 +12,34 @@ var y = Object.defineProperty, b = (e, t) => {
|
|
|
12
12
|
enumerable: !0
|
|
13
13
|
});
|
|
14
14
|
return t || y(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
|
+
// src/games/tanks-live/net/connectionDiagnostics.js
|
|
17
|
+
function x(e = {}) {
|
|
18
|
+
return {
|
|
19
|
+
phase: e.phase ?? "idle",
|
|
20
|
+
ice: e.ice ?? "new",
|
|
21
|
+
connection: e.connection ?? "new",
|
|
22
|
+
gathering: e.gathering ?? "new",
|
|
23
|
+
signaling: {
|
|
24
|
+
sent: e.signals?.sent ?? 0,
|
|
25
|
+
received: e.signals?.received ?? 0,
|
|
26
|
+
sendFailures: e.signals?.sendFailures ?? 0,
|
|
27
|
+
ignored: e.signals?.ignored ?? 0,
|
|
28
|
+
invalid: e.signals?.invalid ?? 0,
|
|
29
|
+
retransmits: e.signals?.retransmits ?? 0
|
|
30
|
+
},
|
|
31
|
+
turnConfigured: !!e.turnConfigured,
|
|
32
|
+
route: e.route?.label ?? null,
|
|
33
|
+
movesSent: e.move?.sent ?? 0,
|
|
34
|
+
movesReceived: e.move?.received ?? 0,
|
|
35
|
+
error: e.error ? /^[a-z_]+$/.test(e.error) ? e.error : "negotiation_error" : null
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function S(e = {}) {
|
|
39
|
+
return e.phase === "connected" ? "" : e.signals?.sendFailures ? "No se pudieron enviar señales por el chat. Revisa la conexión WebSocket y reintenta." : e.ice === "checking" || e.ice === "failed" ? e.turnConfigured ? "WebRTC aún no encuentra una ruta entre los jugadores. Revisa el servicio TURN y la red." : "WebRTC aún no encuentra una ruta entre los jugadores. Algunas redes necesitan un servidor TURN; esta partida no tiene uno configurado." : e.phase === "listening" ? "Esperando la conexión del rival. Ambos deben mantener abierta la partida y usar la misma versión del chat." : e.phase === "failed" ? "No se pudo conectar. Revisa el diagnóstico de ambos jugadores y reintenta." : "Intercambiando señales de conexión por el chat. El combate empieza cuando conecta WebRTC.";
|
|
40
|
+
}
|
|
41
|
+
// src/games/tanks-live/logic/simulation.js
|
|
42
|
+
var C = Object.freeze({
|
|
16
43
|
speed: 16,
|
|
17
44
|
reverse: 9,
|
|
18
45
|
turn: 1.8,
|
|
@@ -21,8 +48,8 @@ var y = Object.defineProperty, b = (e, t) => {
|
|
|
21
48
|
reloadMs: 1500,
|
|
22
49
|
shellSpeed: 60,
|
|
23
50
|
damage: 25
|
|
24
|
-
}),
|
|
25
|
-
function
|
|
51
|
+
}), w = (e, t, n) => Math.max(t, Math.min(n, e)), T = (e, t) => Math.atan2(Math.sin(t - e), Math.cos(t - e));
|
|
52
|
+
function E() {
|
|
26
53
|
return {
|
|
27
54
|
size: 120,
|
|
28
55
|
bounds: {
|
|
@@ -75,7 +102,7 @@ function w() {
|
|
|
75
102
|
}))
|
|
76
103
|
};
|
|
77
104
|
}
|
|
78
|
-
function
|
|
105
|
+
function D(e, t) {
|
|
79
106
|
return {
|
|
80
107
|
id: String(e),
|
|
81
108
|
x: t ? 102 : 18,
|
|
@@ -88,25 +115,25 @@ function T(e, t) {
|
|
|
88
115
|
color: t ? "#d7463f" : "#54a34a"
|
|
89
116
|
};
|
|
90
117
|
}
|
|
91
|
-
function
|
|
118
|
+
function O(e, t, n, r = C.radius) {
|
|
92
119
|
let i = n.bounds;
|
|
93
120
|
return e >= i.minX + r && e <= i.maxX - r && t >= i.minZ + r && t <= i.maxZ - r && !n.obstacles.some((n) => Math.hypot(e - n.x, t - n.z) < n.r + r);
|
|
94
121
|
}
|
|
95
|
-
function
|
|
122
|
+
function k(e, t, n, r) {
|
|
96
123
|
if (!e.alive) return;
|
|
97
|
-
let i =
|
|
98
|
-
e.speed +=
|
|
124
|
+
let i = w(Number(t.throttle) || 0, -1, 1), a = w(Number(t.steer) || 0, -1, 1), o = i * (i < 0 ? C.reverse : C.speed);
|
|
125
|
+
e.speed += w(o - e.speed, -C.acceleration * n, C.acceleration * n), e.yaw += a * C.turn * n, Number.isFinite(t.turretYaw) && (e.turretYaw = t.turretYaw);
|
|
99
126
|
let s = e.x + Math.cos(e.yaw) * e.speed * n, c = e.z + Math.sin(e.yaw) * e.speed * n;
|
|
100
|
-
|
|
127
|
+
O(s, e.z, r) ? e.x = s : e.speed = 0, O(e.x, c, r) ? e.z = c : e.speed = 0;
|
|
101
128
|
}
|
|
102
|
-
function
|
|
103
|
-
let s = n - e, c = r - t, l = s * s + c * c, u = l ?
|
|
129
|
+
function A(e, t, n, r, i, a, o) {
|
|
130
|
+
let s = n - e, c = r - t, l = s * s + c * c, u = l ? w(((i - e) * s + (a - t) * c) / l, 0, 1) : 0;
|
|
104
131
|
return Math.hypot(e + s * u - i, t + c * u - a) <= o ? u : null;
|
|
105
132
|
}
|
|
106
|
-
function
|
|
107
|
-
let i = e.x + Math.cos(e.yaw) *
|
|
133
|
+
function ee(e, t, n, r) {
|
|
134
|
+
let i = e.x + Math.cos(e.yaw) * C.shellSpeed * t, a = e.z + Math.sin(e.yaw) * C.shellSpeed * t, o = null;
|
|
108
135
|
for (let t of n.obstacles) {
|
|
109
|
-
let n =
|
|
136
|
+
let n = A(e.x, e.z, i, a, t.x, t.z, t.r);
|
|
110
137
|
n !== null && (!o || n < o.t) && (o = {
|
|
111
138
|
t: n,
|
|
112
139
|
kind: "obstacle"
|
|
@@ -114,77 +141,77 @@ function k(e, t, n, r) {
|
|
|
114
141
|
}
|
|
115
142
|
for (let t of r) {
|
|
116
143
|
if (!t.alive || t.id === e.owner) continue;
|
|
117
|
-
let n =
|
|
144
|
+
let n = A(e.x, e.z, i, a, t.x, t.z, C.radius);
|
|
118
145
|
n !== null && (!o || n < o.t) && (o = {
|
|
119
146
|
t: n,
|
|
120
147
|
kind: "tank",
|
|
121
148
|
target: t.id
|
|
122
149
|
});
|
|
123
150
|
}
|
|
124
|
-
return o ? (e.x += (i - e.x) * o.t, e.z += (a - e.z) * o.t, o) : (e.x = i, e.z = a, e.age += t, !
|
|
151
|
+
return o ? (e.x += (i - e.x) * o.t, e.z += (a - e.z) * o.t, o) : (e.x = i, e.z = a, e.age += t, !O(i, a, {
|
|
125
152
|
...n,
|
|
126
153
|
obstacles: []
|
|
127
154
|
}, 0) || e.age > 3 ? { kind: "terrain" } : null);
|
|
128
155
|
}
|
|
129
|
-
function
|
|
130
|
-
let r =
|
|
156
|
+
function te(e, t, n) {
|
|
157
|
+
let r = w(n, 0, 1);
|
|
131
158
|
return {
|
|
132
159
|
...t,
|
|
133
160
|
x: e.x + (t.x - e.x) * r,
|
|
134
161
|
z: e.z + (t.z - e.z) * r,
|
|
135
|
-
yaw: e.yaw +
|
|
136
|
-
turretYaw: e.turretYaw +
|
|
162
|
+
yaw: e.yaw + T(e.yaw, t.yaw) * r,
|
|
163
|
+
turretYaw: e.turretYaw + T(e.turretYaw, t.turretYaw) * r
|
|
137
164
|
};
|
|
138
165
|
}
|
|
139
166
|
// src/games/tanks-live/net/createLiveMatch.js
|
|
140
|
-
var
|
|
141
|
-
function
|
|
167
|
+
var j = (e) => typeof e == "number" && Number.isFinite(e), M = (e) => typeof e == "string" && e.length > 0 && e.length < 160;
|
|
168
|
+
function N({ game: e, selfId: t, isHost: a = String(t) === String(e.hostId), signaling: o, onChange: s = () => {}, peerFactory: c = r, iceServers: l, iceTransportPolicy: u, RTCPeerConnectionImpl: d } = {}) {
|
|
142
169
|
t = String(t);
|
|
143
170
|
let f = [String(e.hostId), String(e.guestId)];
|
|
144
171
|
if (!f.includes(t) || f[0] === f[1]) throw Error("Invalid live match players");
|
|
145
|
-
let p = f.find((e) => e !== t),
|
|
172
|
+
let p = (l || []).some((e) => [e.urls].flat().some((e) => /^turns?:/i.test(String(e)))), m = f.find((e) => e !== t), h = E(), g = f.map(D), _ = [], v = [], y = {}, b = 0, x = 0, S = 0, w = 0, T = "connecting", A = null, N = !1, P = {
|
|
146
173
|
phase: "idle",
|
|
147
174
|
rtt: null,
|
|
148
175
|
route: null
|
|
149
|
-
}, F = !1, I = !1, L = null, R = [], z = null, B = null, V = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Set(), U = /* @__PURE__ */ new Set(), W = () =>
|
|
176
|
+
}, F = !1, I = !1, L = null, R = [], z = null, B = null, V = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Set(), U = /* @__PURE__ */ new Set(), W = () => g.find((e) => e.id === t), ne = () => g.find((e) => e.id === m), G = () => {
|
|
150
177
|
N || s({
|
|
151
|
-
status:
|
|
152
|
-
winner:
|
|
178
|
+
status: T,
|
|
179
|
+
winner: A,
|
|
153
180
|
net: P
|
|
154
181
|
});
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
},
|
|
182
|
+
}, K = (e) => {
|
|
183
|
+
v.push(e), v.length > 200 && v.shift();
|
|
184
|
+
}, q = (t) => $.sendEvent({
|
|
158
185
|
...t,
|
|
159
186
|
g: e.gameId,
|
|
160
187
|
r: S
|
|
161
|
-
}),
|
|
188
|
+
}), J = (e) => {
|
|
162
189
|
H.add(e), H.size > 2048 && H.delete(H.values().next().value);
|
|
163
|
-
},
|
|
190
|
+
}, Y = () => ({
|
|
164
191
|
k: "snapshot",
|
|
165
|
-
hp:
|
|
166
|
-
status:
|
|
167
|
-
winner:
|
|
192
|
+
hp: g.map((e) => e.hp),
|
|
193
|
+
status: T,
|
|
194
|
+
winner: A,
|
|
168
195
|
reason: L
|
|
169
196
|
});
|
|
170
|
-
function
|
|
171
|
-
|
|
197
|
+
function X() {
|
|
198
|
+
g = f.map(D), _ = [], R = [], z = null, B = null, V.clear(), H.clear(), U.clear(), I = !1, L = null, A = null, T = P.phase === "connected" ? "playing" : "connecting", K({ k: "rematch" }), G();
|
|
172
199
|
}
|
|
173
|
-
function
|
|
174
|
-
(
|
|
200
|
+
function Z(e, t = !1) {
|
|
201
|
+
(T !== "over" || t && A !== e) && (T = "over", A = e, _ = [], K({
|
|
175
202
|
k: "over",
|
|
176
|
-
winner:
|
|
177
|
-
}),
|
|
203
|
+
winner: A
|
|
204
|
+
}), G());
|
|
178
205
|
}
|
|
179
|
-
function
|
|
180
|
-
if (
|
|
181
|
-
let r =
|
|
182
|
-
if (!r?.alive ||
|
|
206
|
+
function Q(e, t, n) {
|
|
207
|
+
if (T !== "playing" || !M(t.id) || H.has(t.id)) return !1;
|
|
208
|
+
let r = g.find((t) => t.id === e);
|
|
209
|
+
if (!r?.alive || b - (V.get(e) ?? -Infinity) < C.reloadMs - 20 || ![
|
|
183
210
|
t.x,
|
|
184
211
|
t.z,
|
|
185
212
|
t.yaw
|
|
186
|
-
].every(
|
|
187
|
-
|
|
213
|
+
].every(j) || Math.hypot(t.x - (e === m && B ? B.x : r.x), t.z - (e === m && B ? B.z : r.z)) > 6) return !1;
|
|
214
|
+
J(t.id), V.set(e, b);
|
|
188
215
|
let i = {
|
|
189
216
|
...t,
|
|
190
217
|
k: "fire",
|
|
@@ -194,44 +221,44 @@ function M({ game: e, selfId: t, isHost: a = String(t) === String(e.hostId), sig
|
|
|
194
221
|
y: 1.4,
|
|
195
222
|
age: 0
|
|
196
223
|
};
|
|
197
|
-
return
|
|
224
|
+
return _.push(i), K(i), n && q({
|
|
198
225
|
...t,
|
|
199
226
|
k: "fire"
|
|
200
227
|
}), !0;
|
|
201
228
|
}
|
|
202
|
-
function
|
|
203
|
-
if (N ||
|
|
229
|
+
function re(t) {
|
|
230
|
+
if (N || T !== "playing" || t?.g !== e.gameId || t.r !== S || !Array.isArray(t.p) || t.p.length !== 5 || !t.p.every(j)) return;
|
|
204
231
|
let [n, r, i, a, o] = t.p;
|
|
205
|
-
if (!
|
|
206
|
-
let s = z === null ? .1 : Math.max(0, (
|
|
207
|
-
if (Math.hypot(n - c.x, r - c.z) >
|
|
232
|
+
if (!O(n, r, h) || Math.abs(o) > C.speed + .1 || Math.abs(i) > 1e6 || Math.abs(a) > 1e6) return;
|
|
233
|
+
let s = z === null ? .1 : Math.max(0, (b - z) / 1e3), c = B || ne();
|
|
234
|
+
if (Math.hypot(n - c.x, r - c.z) > C.speed * s + 3) return;
|
|
208
235
|
let l = {
|
|
209
|
-
...
|
|
236
|
+
...ne(),
|
|
210
237
|
x: n,
|
|
211
238
|
z: r,
|
|
212
239
|
yaw: i,
|
|
213
240
|
turretYaw: a,
|
|
214
241
|
speed: o
|
|
215
242
|
};
|
|
216
|
-
B = l, z =
|
|
217
|
-
time:
|
|
243
|
+
B = l, z = b, R.push({
|
|
244
|
+
time: b,
|
|
218
245
|
pose: l
|
|
219
246
|
}), R.length > 30 && R.shift();
|
|
220
247
|
}
|
|
221
|
-
function
|
|
248
|
+
function ie(n) {
|
|
222
249
|
if (!N && n && n.g === e.gameId && Number.isInteger(n.r)) {
|
|
223
|
-
if (n.k === "round" && !a &&
|
|
250
|
+
if (n.k === "round" && !a && T === "over" && U.has(t) && n.r === S + 1) S = n.r, X();
|
|
224
251
|
else if (n.r === S) {
|
|
225
|
-
if (n.k === "sync" && a)
|
|
252
|
+
if (n.k === "sync" && a) q(Y());
|
|
226
253
|
else if (n.k === "snapshot" && !a && Array.isArray(n.hp) && n.hp.length === 2 && n.hp.every((e) => Number.isInteger(e) && e >= 0 && e <= 100)) {
|
|
227
254
|
let e = n.status === "playing" && n.winner === null && n.hp.every((e) => e > 0), t = n.status === "over" && f.includes(n.winner) && (n.hp[1 - f.indexOf(n.winner)] === 0 || n.reason === "resigned");
|
|
228
255
|
if (!e && !t) return;
|
|
229
|
-
|
|
256
|
+
g.forEach((e, t) => {
|
|
230
257
|
e.hp = n.hp[t], e.alive = e.hp > 0;
|
|
231
|
-
}), t && (I = !1, L = n.reason,
|
|
232
|
-
} else n.k === "resign" ? (L = "resigned",
|
|
258
|
+
}), t && (I = !1, L = n.reason, Z(n.winner, !0));
|
|
259
|
+
} else n.k === "resign" ? (L = "resigned", Z(t, a), a && q(Y())) : n.k === "rematch" && T === "over" ? (U.add(m), ae()) : T === "playing" && (n.k === "fire" && Q(m, n, !1), !a && n.k === "hit" && M(n.id) && !H.has(`hit:${n.id}`) && f.includes(n.target) && Array.isArray(n.hp) && n.hp.length === 2 && n.hp.every((e, t) => Number.isInteger(e) && e >= 0 && e <= g[t].hp) && [n.x, n.z].every(j) && (J(`hit:${n.id}`), g.forEach((e, t) => {
|
|
233
260
|
e.hp = n.hp[t], e.alive = e.hp > 0;
|
|
234
|
-
}),
|
|
261
|
+
}), _ = _.filter((e) => e.id !== n.id), K(n)), !a && n.k === "destroyed" && f.includes(n.target) && !H.has(`destroyed:${n.target}`) && g.find((e) => e.id === n.target).hp === 0 && (J(`destroyed:${n.target}`), K(n)), !a && n.k === "over" && f.includes(n.winner) && g.find((e) => e.id !== n.winner).hp === 0 && Z(n.winner));
|
|
235
262
|
}
|
|
236
263
|
}
|
|
237
264
|
}
|
|
@@ -253,58 +280,58 @@ function M({ game: e, selfId: t, isHost: a = String(t) === String(e.hostId), sig
|
|
|
253
280
|
}
|
|
254
281
|
},
|
|
255
282
|
selfId: t,
|
|
256
|
-
peerId:
|
|
283
|
+
peerId: m,
|
|
257
284
|
roomId: e.roomId,
|
|
258
285
|
iceServers: l,
|
|
259
286
|
iceTransportPolicy: u,
|
|
260
287
|
RTCPeerConnectionImpl: d,
|
|
261
|
-
onMove:
|
|
262
|
-
onEvent:
|
|
288
|
+
onMove: re,
|
|
289
|
+
onEvent: ie,
|
|
263
290
|
onChange(e) {
|
|
264
291
|
let t = P.phase;
|
|
265
292
|
if (P = e, e.phase === "connected") {
|
|
266
293
|
let e = F;
|
|
267
|
-
F = !0,
|
|
268
|
-
N || (I &&
|
|
294
|
+
F = !0, T !== "over" && (T = "playing"), t !== "connected" && queueMicrotask(() => {
|
|
295
|
+
N || (I && q({ k: "resign" }), a && e ? q(Y()) : a || q({ k: "sync" }));
|
|
269
296
|
});
|
|
270
|
-
} else
|
|
271
|
-
|
|
297
|
+
} else T !== "over" && (T = F ? "disconnected" : "connecting");
|
|
298
|
+
G();
|
|
272
299
|
}
|
|
273
300
|
});
|
|
274
|
-
function
|
|
275
|
-
a && U.size === 2 && (S++,
|
|
301
|
+
function ae() {
|
|
302
|
+
a && U.size === 2 && (S++, q({ k: "round" }), X());
|
|
276
303
|
}
|
|
277
304
|
return a ? $.connect() : $.setListening(!0), {
|
|
278
305
|
setInput(e) {
|
|
279
|
-
|
|
306
|
+
y = { ...e };
|
|
280
307
|
},
|
|
281
308
|
step(n) {
|
|
282
309
|
if (N) return;
|
|
283
310
|
let r = Math.max(0, Math.min(Number(n) || 0, 100));
|
|
284
|
-
if (
|
|
285
|
-
let i = r / 1e3, o =
|
|
311
|
+
if (b += r, T !== "playing") return;
|
|
312
|
+
let i = r / 1e3, o = b - 100;
|
|
286
313
|
for (; R.length > 1 && R[1].time <= o;) R.shift();
|
|
287
314
|
if (R.length) {
|
|
288
|
-
let e = R[0], t = R[1] || e, n =
|
|
315
|
+
let e = R[0], t = R[1] || e, n = te(e.pose, t.pose, t.time === e.time ? 1 : (o - e.time) / (t.time - e.time));
|
|
289
316
|
for (let e of [
|
|
290
317
|
"x",
|
|
291
318
|
"z",
|
|
292
319
|
"yaw",
|
|
293
320
|
"turretYaw",
|
|
294
321
|
"speed"
|
|
295
|
-
])
|
|
322
|
+
]) ne()[e] = n[e];
|
|
296
323
|
}
|
|
297
|
-
for (let e = i; e > 0; e -= .016)
|
|
298
|
-
|
|
299
|
-
id: `${t}:${S}:${++
|
|
324
|
+
for (let e = i; e > 0; e -= .016) k(W(), y, Math.min(e, .016), h);
|
|
325
|
+
y.fire && Q(t, {
|
|
326
|
+
id: `${t}:${S}:${++w}`,
|
|
300
327
|
x: W().x,
|
|
301
328
|
z: W().z,
|
|
302
329
|
yaw: W().turretYaw,
|
|
303
|
-
t:
|
|
330
|
+
t: b
|
|
304
331
|
}, !0);
|
|
305
332
|
let s = P.rtt > 250 || P.move?.lossPct > 15 ? 10 : P.rtt > 100 ? 15 : 20;
|
|
306
|
-
if (
|
|
307
|
-
|
|
333
|
+
if (b >= x) {
|
|
334
|
+
x = b + 1e3 / s;
|
|
308
335
|
let t = W();
|
|
309
336
|
$.sendMove({
|
|
310
337
|
g: e.gameId,
|
|
@@ -316,35 +343,35 @@ function M({ game: e, selfId: t, isHost: a = String(t) === String(e.hostId), sig
|
|
|
316
343
|
t.turretYaw,
|
|
317
344
|
t.speed
|
|
318
345
|
],
|
|
319
|
-
t:
|
|
346
|
+
t: b
|
|
320
347
|
});
|
|
321
348
|
}
|
|
322
|
-
|
|
323
|
-
let t =
|
|
349
|
+
_ = _.filter((e) => {
|
|
350
|
+
let t = ee(e, i, h, g);
|
|
324
351
|
if (!t) return !0;
|
|
325
|
-
if (a && t.target &&
|
|
326
|
-
let n =
|
|
327
|
-
n.hp = Math.max(0, n.hp -
|
|
352
|
+
if (a && t.target && T === "playing") {
|
|
353
|
+
let n = g.find((e) => e.id === t.target);
|
|
354
|
+
n.hp = Math.max(0, n.hp - C.damage), n.alive = n.hp > 0;
|
|
328
355
|
let r = {
|
|
329
356
|
k: "hit",
|
|
330
357
|
id: e.id,
|
|
331
358
|
target: n.id,
|
|
332
|
-
dmg:
|
|
333
|
-
hp:
|
|
359
|
+
dmg: C.damage,
|
|
360
|
+
hp: g.map((e) => e.hp),
|
|
334
361
|
x: e.x,
|
|
335
362
|
z: e.z
|
|
336
363
|
};
|
|
337
|
-
if (
|
|
364
|
+
if (q(r), K(r), !n.alive) {
|
|
338
365
|
let t = {
|
|
339
366
|
k: "destroyed",
|
|
340
367
|
target: n.id
|
|
341
368
|
};
|
|
342
|
-
|
|
369
|
+
q(t), K(t), q({
|
|
343
370
|
k: "over",
|
|
344
371
|
winner: e.owner
|
|
345
|
-
}),
|
|
372
|
+
}), Z(e.owner);
|
|
346
373
|
}
|
|
347
|
-
} else
|
|
374
|
+
} else K({
|
|
348
375
|
k: "impact",
|
|
349
376
|
kind: t.kind,
|
|
350
377
|
x: e.x,
|
|
@@ -355,42 +382,48 @@ function M({ game: e, selfId: t, isHost: a = String(t) === String(e.hostId), sig
|
|
|
355
382
|
},
|
|
356
383
|
getRender() {
|
|
357
384
|
let e = {
|
|
358
|
-
arena:
|
|
359
|
-
tanks:
|
|
385
|
+
arena: h,
|
|
386
|
+
tanks: g.map((e) => ({
|
|
360
387
|
...e,
|
|
361
388
|
self: e.id === t,
|
|
362
|
-
reload: Math.min(1, (
|
|
389
|
+
reload: Math.min(1, (b - (V.get(e.id) ?? -Infinity)) / C.reloadMs)
|
|
363
390
|
})),
|
|
364
|
-
shells:
|
|
365
|
-
events:
|
|
366
|
-
status:
|
|
367
|
-
winner:
|
|
368
|
-
net:
|
|
391
|
+
shells: _.map((e) => ({ ...e })),
|
|
392
|
+
events: v,
|
|
393
|
+
status: T,
|
|
394
|
+
winner: A,
|
|
395
|
+
net: {
|
|
396
|
+
...P,
|
|
397
|
+
turnConfigured: p
|
|
398
|
+
}
|
|
369
399
|
};
|
|
370
|
-
return
|
|
400
|
+
return v = [], e;
|
|
401
|
+
},
|
|
402
|
+
reconnect() {
|
|
403
|
+
!N && T !== "over" && $.connect();
|
|
371
404
|
},
|
|
372
405
|
rematch() {
|
|
373
|
-
!N &&
|
|
406
|
+
!N && T === "over" && (U.add(t), q({ k: "rematch" }), ae());
|
|
374
407
|
},
|
|
375
408
|
resign() {
|
|
376
|
-
!N &&
|
|
409
|
+
!N && T !== "over" && (I = !0, L = "resigned", q({ k: "resign" }), Z(m));
|
|
377
410
|
},
|
|
378
411
|
destroy() {
|
|
379
|
-
N || (N = !0, $.destroy(),
|
|
412
|
+
N || (N = !0, $.destroy(), _ = [], R = [], v = []);
|
|
380
413
|
}
|
|
381
414
|
};
|
|
382
415
|
}
|
|
383
|
-
var
|
|
384
|
-
function
|
|
416
|
+
var P = 180 / Math.PI, F = (e, t) => Number.isFinite(e) ? e : t;
|
|
417
|
+
function I(e) {
|
|
385
418
|
let t = e || {}, n = t.bounds || t;
|
|
386
|
-
if (Number.isFinite(n.minX) && Number.isFinite(n.maxX) && Number.isFinite(n.minZ) && Number.isFinite(n.maxZ)) return
|
|
419
|
+
if (Number.isFinite(n.minX) && Number.isFinite(n.maxX) && Number.isFinite(n.minZ) && Number.isFinite(n.maxZ)) return L({
|
|
387
420
|
minX: n.minX,
|
|
388
421
|
minZ: n.minZ,
|
|
389
422
|
maxX: n.maxX,
|
|
390
423
|
maxZ: n.maxZ
|
|
391
424
|
});
|
|
392
|
-
let r =
|
|
393
|
-
return
|
|
425
|
+
let r = F(t.width, F(t.size, 120)), i = F(t.depth, F(t.height, F(t.size, r)));
|
|
426
|
+
return L(t.centered === !0 || t.origin === "center" ? {
|
|
394
427
|
minX: -r / 2,
|
|
395
428
|
minZ: -i / 2,
|
|
396
429
|
maxX: r / 2,
|
|
@@ -402,7 +435,7 @@ function F(e) {
|
|
|
402
435
|
maxZ: i
|
|
403
436
|
});
|
|
404
437
|
}
|
|
405
|
-
function
|
|
438
|
+
function L(e) {
|
|
406
439
|
return {
|
|
407
440
|
...e,
|
|
408
441
|
width: e.maxX - e.minX,
|
|
@@ -411,16 +444,16 @@ function I(e) {
|
|
|
411
444
|
cz: (e.minZ + e.maxZ) / 2
|
|
412
445
|
};
|
|
413
446
|
}
|
|
414
|
-
function
|
|
447
|
+
function R(e) {
|
|
415
448
|
return (e?.obstacles || []).filter((e) => Number.isFinite(e?.x) && Number.isFinite(e?.z)).map((e) => ({
|
|
416
449
|
x: e.x,
|
|
417
450
|
z: e.z,
|
|
418
|
-
r:
|
|
451
|
+
r: F(e.r, F(e.radius, 1.5)),
|
|
419
452
|
kind: e.kind === "tree" ? "tree" : "rock"
|
|
420
453
|
}));
|
|
421
454
|
}
|
|
422
|
-
var
|
|
423
|
-
function
|
|
455
|
+
var z = (e) => e ? e.k ?? e.type ?? null : null;
|
|
456
|
+
function B(e, t) {
|
|
424
457
|
let n = t || [], r = e?.tank ?? e?.by ?? e?.owner ?? e?.from;
|
|
425
458
|
if (r != null) {
|
|
426
459
|
let e = n.find((e) => String(e.id) === String(r));
|
|
@@ -434,11 +467,11 @@ function z(e, t) {
|
|
|
434
467
|
}
|
|
435
468
|
return i;
|
|
436
469
|
}
|
|
437
|
-
var
|
|
470
|
+
var V = (e, t) => t == null ? null : (e || []).find((e) => String(e.id) === String(t)) || null, H = (e) => (e || []).find((e) => e.self) || null, U = (e, t = !0) => !t || e <= 25 ? 2 : +(e <= 50), W = (e) => {
|
|
438
471
|
let t = e % (Math.PI * 2);
|
|
439
472
|
return t > Math.PI && (t -= Math.PI * 2), t < -Math.PI && (t += Math.PI * 2), t;
|
|
440
473
|
};
|
|
441
|
-
function
|
|
474
|
+
function ne({ moveSpeed: e = .6, turnSpeed: t = .35, holdMs: n = 160 } = {}) {
|
|
442
475
|
let r = null, i = !1, a = !1, o = 0, s = 0;
|
|
443
476
|
return {
|
|
444
477
|
update(c, l) {
|
|
@@ -446,7 +479,7 @@ function W({ moveSpeed: e = .6, turnSpeed: t = .35, holdMs: n = 160 } = {}) {
|
|
|
446
479
|
if (!c || c.alive === !1) return i && u.push({ type: "move_end" }), a && u.push({ type: "turret_end" }), i = a = !1, r = null, u;
|
|
447
480
|
let d = Math.max(1, l) / 1e3;
|
|
448
481
|
if (r) {
|
|
449
|
-
let f = Math.hypot(c.x - r.x, c.z - r.z) / d, p = Math.abs(
|
|
482
|
+
let f = Math.hypot(c.x - r.x, c.z - r.z) / d, p = Math.abs(W((c.yaw ?? 0) - r.yaw)) / d, m = Math.abs(W((c.turretYaw ?? 0) - (c.yaw ?? 0) - r.rel)) / d, h = f > e || p > t;
|
|
450
483
|
o = h ? 0 : o + l, h && !i ? (i = !0, u.push({ type: "move_start" })) : !h && i && o >= n && (i = !1, u.push({ type: "move_end" }));
|
|
451
484
|
let g = m > t;
|
|
452
485
|
s = g ? 0 : s + l, g && !a ? (a = !0, u.push({ type: "turret_start" })) : !g && a && s >= n && (a = !1, u.push({ type: "turret_end" }));
|
|
@@ -455,7 +488,7 @@ function W({ moveSpeed: e = .6, turnSpeed: t = .35, holdMs: n = 160 } = {}) {
|
|
|
455
488
|
x: c.x,
|
|
456
489
|
z: c.z,
|
|
457
490
|
yaw: c.yaw ?? 0,
|
|
458
|
-
rel:
|
|
491
|
+
rel: W((c.turretYaw ?? 0) - (c.yaw ?? 0))
|
|
459
492
|
}, u;
|
|
460
493
|
},
|
|
461
494
|
reset() {
|
|
@@ -470,7 +503,7 @@ function W({ moveSpeed: e = .6, turnSpeed: t = .35, holdMs: n = 160 } = {}) {
|
|
|
470
503
|
};
|
|
471
504
|
}
|
|
472
505
|
function G(e) {
|
|
473
|
-
switch (
|
|
506
|
+
switch (z(e)) {
|
|
474
507
|
case "fire": return [{ type: "fire" }, { type: "projectile_start" }];
|
|
475
508
|
case "impact": return [{
|
|
476
509
|
type: "impact",
|
|
@@ -483,7 +516,7 @@ function G(e) {
|
|
|
483
516
|
}
|
|
484
517
|
function K(e) {
|
|
485
518
|
if (!e || e.status !== "over") return null;
|
|
486
|
-
let t =
|
|
519
|
+
let t = H(e.tanks);
|
|
487
520
|
return !t || e.winner == null ? null : String(e.winner) === String(t.id) ? "victory" : "defeat";
|
|
488
521
|
}
|
|
489
522
|
// src/games/tanks-live/scene/createLiveScene2d.js
|
|
@@ -492,7 +525,7 @@ function q(e, { arena: t } = {}) {
|
|
|
492
525
|
n.style.cssText = "width:100%;height:100%;display:block", e.appendChild(n);
|
|
493
526
|
let r = n.getContext("2d");
|
|
494
527
|
if (!r) throw n.remove(), Error("Canvas 2D unavailable");
|
|
495
|
-
let i =
|
|
528
|
+
let i = I(t), a = 1, o = 1, s = 1, c = 0, l = 0;
|
|
496
529
|
function u() {
|
|
497
530
|
a = Math.max(1, e.clientWidth), o = Math.max(1, e.clientHeight);
|
|
498
531
|
let t = Math.min(window.devicePixelRatio || 1, 2);
|
|
@@ -511,7 +544,7 @@ function q(e, { arena: t } = {}) {
|
|
|
511
544
|
},
|
|
512
545
|
render(e) {
|
|
513
546
|
r.fillStyle = "#152519", r.fillRect(0, 0, a, o), r.save(), r.translate(c, l), r.scale(s, s), r.translate(-i.minX, -i.minZ), r.fillStyle = "#526348", r.fillRect(i.minX, i.minZ, i.width, i.depth);
|
|
514
|
-
for (let e of
|
|
547
|
+
for (let e of R(t)) r.fillStyle = e.kind === "tree" ? "#24472d" : "#929285", r.beginPath(), r.arc(e.x, e.z, e.r, 0, Math.PI * 2), r.fill();
|
|
515
548
|
for (let t of e.tanks || []) r.save(), r.translate(t.x, t.z), r.rotate(t.yaw), r.fillStyle = t.alive === !1 ? "#333" : t.color || "#73ce68", r.fillRect(-3, -1.8, 6, 3.6), r.restore(), r.save(), r.translate(t.x, t.z), r.rotate(t.turretYaw), r.strokeStyle = "#dce8cf", r.lineWidth = .8, r.beginPath(), r.moveTo(0, 0), r.lineTo(5, 0), r.stroke(), r.restore(), t.self && (r.strokeStyle = "#fff", r.lineWidth = .3, r.beginPath(), r.arc(t.x, t.z, 4, 0, Math.PI * 2), r.stroke());
|
|
516
549
|
r.fillStyle = "#ffe097";
|
|
517
550
|
for (let t of e.shells || []) r.beginPath(), r.arc(t.x, t.z, .7, 0, Math.PI * 2), r.fill();
|
|
@@ -529,64 +562,64 @@ var J = /* @__PURE__ */ b({ default: () => Q }), Y = (t, n) => {
|
|
|
529
562
|
e.throttle = 0, e.steer = 0, e.fire = !1;
|
|
530
563
|
};
|
|
531
564
|
function Z({ gameKey: n, currentUserId: r, onMinimize: i, onDismiss: d, suspended: y = !1 }) {
|
|
532
|
-
let b = f(a)?.config?.webrtc,
|
|
533
|
-
|
|
534
|
-
let
|
|
565
|
+
let b = f(a)?.config?.webrtc, C = e((e) => e.games[n]), w = m(y);
|
|
566
|
+
w.current = y;
|
|
567
|
+
let T = m(null), E = m(null), D = m(null), O = m({
|
|
535
568
|
throttle: 0,
|
|
536
569
|
steer: 0,
|
|
537
570
|
fire: !1
|
|
538
|
-
}), [
|
|
571
|
+
}), [k, A] = h(null), [ee, te] = h(""), [j, M] = h(!1), [P, F] = h("loading");
|
|
539
572
|
p(() => {
|
|
540
|
-
y ? (X(
|
|
573
|
+
y ? (X(O.current), o()) : D.current?.resize();
|
|
541
574
|
}, [y]);
|
|
542
|
-
let
|
|
575
|
+
let I = ["active", "won"].includes(C?.status), [L, R] = h(null);
|
|
543
576
|
if (p(() => {
|
|
544
|
-
if (!
|
|
577
|
+
if (!I || !L || !T.current) return;
|
|
545
578
|
let e = !1, t = null, n = {
|
|
546
|
-
arena:
|
|
579
|
+
arena: L,
|
|
547
580
|
lowPower: matchMedia("(pointer: coarse)").matches,
|
|
548
581
|
reducedMotion: matchMedia("(prefers-reduced-motion: reduce)").matches,
|
|
549
582
|
onEvent: (e) => {
|
|
550
|
-
e.type === "context_lost" &&
|
|
583
|
+
e.type === "context_lost" && M(!0);
|
|
551
584
|
}
|
|
552
585
|
}, r = () => {
|
|
553
|
-
e || (t = q(
|
|
586
|
+
e || (t = q(T.current, n), D.current = t, F("2d"));
|
|
554
587
|
};
|
|
555
|
-
return
|
|
588
|
+
return j ? r() : import("./createLiveScene-GkalLsqm.js").then(({ createLiveScene: i }) => {
|
|
556
589
|
if (!e) try {
|
|
557
|
-
t = i(
|
|
590
|
+
t = i(T.current, n), D.current = t, F("3d");
|
|
558
591
|
} catch {
|
|
559
592
|
r();
|
|
560
593
|
}
|
|
561
594
|
}).catch(r), () => {
|
|
562
|
-
e = !0, t?.dispose(),
|
|
595
|
+
e = !0, t?.dispose(), D.current === t && (D.current = null);
|
|
563
596
|
};
|
|
564
597
|
}, [
|
|
565
|
-
F,
|
|
566
598
|
I,
|
|
567
|
-
|
|
599
|
+
L,
|
|
600
|
+
j
|
|
568
601
|
]), p(() => {
|
|
569
|
-
if (!
|
|
570
|
-
let t = !1, i = 0, a = performance.now(), u = 0, d = null, f =
|
|
602
|
+
if (!I || C.status !== "active" || !T.current) return;
|
|
603
|
+
let t = !1, i = 0, a = performance.now(), u = 0, d = null, f = ne(), p = /* @__PURE__ */ new Set();
|
|
571
604
|
s();
|
|
572
605
|
let m;
|
|
573
606
|
try {
|
|
574
607
|
let t = e.getState().createLiveSignaling(n);
|
|
575
|
-
m =
|
|
608
|
+
m = N({
|
|
576
609
|
iceServers: b?.iceServers,
|
|
577
610
|
iceTransportPolicy: b?.iceTransportPolicy,
|
|
578
|
-
game:
|
|
611
|
+
game: C,
|
|
579
612
|
selfId: String(r),
|
|
580
|
-
isHost: String(
|
|
613
|
+
isHost: String(C.hostId) === String(r),
|
|
581
614
|
signaling: t
|
|
582
|
-
}),
|
|
615
|
+
}), E.current = m;
|
|
583
616
|
} catch (e) {
|
|
584
|
-
|
|
617
|
+
te(e.message || "No se pudo iniciar WebRTC");
|
|
585
618
|
return;
|
|
586
619
|
}
|
|
587
|
-
|
|
620
|
+
R(m.getRender().arena);
|
|
588
621
|
function h() {
|
|
589
|
-
p.clear(), X(
|
|
622
|
+
p.clear(), X(O.current), o();
|
|
590
623
|
}
|
|
591
624
|
function g(e, t) {
|
|
592
625
|
/^(INPUT|TEXTAREA|SELECT)$/.test(e.target?.tagName) || [
|
|
@@ -599,57 +632,57 @@ function Z({ gameKey: n, currentUserId: r, onMinimize: i, onDismiss: d, suspende
|
|
|
599
632
|
"ArrowLeft",
|
|
600
633
|
"ArrowRight",
|
|
601
634
|
"Space"
|
|
602
|
-
].includes(e.code) && (e.preventDefault(), t ? p.add(e.code) : p.delete(e.code),
|
|
635
|
+
].includes(e.code) && (e.preventDefault(), t ? p.add(e.code) : p.delete(e.code), O.current.throttle = Number(p.has("KeyW") || p.has("ArrowUp")) - Number(p.has("KeyS") || p.has("ArrowDown")), O.current.steer = Number(p.has("KeyD") || p.has("ArrowRight")) - Number(p.has("KeyA") || p.has("ArrowLeft")), O.current.fire = p.has("Space"));
|
|
603
636
|
}
|
|
604
|
-
let _ = (e) => g(e, !0), v = (e) => g(e, !1), y =
|
|
637
|
+
let _ = (e) => g(e, !0), v = (e) => g(e, !1), y = T.current;
|
|
605
638
|
y.addEventListener("keydown", _), y.addEventListener("keyup", v), y.addEventListener("blur", h);
|
|
606
|
-
let
|
|
639
|
+
let x = () => {
|
|
607
640
|
document.hidden && h();
|
|
608
641
|
};
|
|
609
|
-
document.addEventListener("visibilitychange",
|
|
610
|
-
function
|
|
642
|
+
document.addEventListener("visibilitychange", x), c({ type: "engine_start" }, n);
|
|
643
|
+
function S(r) {
|
|
611
644
|
if (t) return;
|
|
612
645
|
let s = Math.min(80, r - a);
|
|
613
646
|
a = r;
|
|
614
|
-
let h =
|
|
647
|
+
let h = w.current || document.hidden;
|
|
615
648
|
m.setInput(h ? {
|
|
616
649
|
throttle: 0,
|
|
617
650
|
steer: 0,
|
|
618
651
|
fire: !1
|
|
619
|
-
} :
|
|
652
|
+
} : O.current), m.step(s);
|
|
620
653
|
let g = m.getRender();
|
|
621
|
-
if (h ||
|
|
622
|
-
if (!h) for (let e of f.update(
|
|
654
|
+
if (h || D.current?.render(g, s), h && (p.clear(), f.reset(), o()), !h) for (let e of g.events || []) for (let t of G(e)) c(t, e.id);
|
|
655
|
+
if (!h) for (let e of f.update(H(g.tanks), s)) c(e);
|
|
623
656
|
let _ = K(g);
|
|
624
|
-
_ && !d && (
|
|
657
|
+
_ && !d && (A(g), d = _, h || l(d, n), e.getState().liveFinish?.(n, g.winner)), r - u > 100 && (u = r, A(g)), i = requestAnimationFrame(S);
|
|
625
658
|
}
|
|
626
|
-
return i = requestAnimationFrame(
|
|
627
|
-
t = !0, cancelAnimationFrame(i), h(), m.destroy(),
|
|
659
|
+
return i = requestAnimationFrame(S), () => {
|
|
660
|
+
t = !0, cancelAnimationFrame(i), h(), m.destroy(), E.current = null, y.removeEventListener("keydown", _), y.removeEventListener("keyup", v), y.removeEventListener("blur", h), document.removeEventListener("visibilitychange", x);
|
|
628
661
|
};
|
|
629
662
|
}, [
|
|
630
|
-
|
|
663
|
+
I,
|
|
631
664
|
n,
|
|
632
665
|
r
|
|
633
|
-
]), !
|
|
634
|
-
let
|
|
635
|
-
function
|
|
636
|
-
let t =
|
|
666
|
+
]), !C) return null;
|
|
667
|
+
let z = String(r) === String(C.guestId), B = k?.status === "over" || C.status === "won";
|
|
668
|
+
function V(e) {
|
|
669
|
+
let t = T.current?.getBoundingClientRect(), n = H(k?.tanks);
|
|
637
670
|
if (!t || !n) return;
|
|
638
|
-
let r =
|
|
639
|
-
r && (
|
|
671
|
+
let r = D.current?.screenToGround((e.clientX - t.left) / t.width * 2 - 1, 1 - (e.clientY - t.top) / t.height * 2);
|
|
672
|
+
r && (O.current.turretYaw = Math.atan2(r.z - n.z, r.x - n.x));
|
|
640
673
|
}
|
|
641
|
-
let
|
|
674
|
+
let U = (e, t) => ({
|
|
642
675
|
onPointerDown: (n) => {
|
|
643
|
-
n.preventDefault(), n.currentTarget.setPointerCapture(n.pointerId),
|
|
676
|
+
n.preventDefault(), n.currentTarget.setPointerCapture(n.pointerId), O.current[e] = t;
|
|
644
677
|
},
|
|
645
678
|
onPointerUp: () => {
|
|
646
|
-
|
|
679
|
+
O.current[e] = e !== "fire" && 0;
|
|
647
680
|
},
|
|
648
681
|
onPointerCancel: () => {
|
|
649
|
-
|
|
682
|
+
O.current[e] = e !== "fire" && 0;
|
|
650
683
|
},
|
|
651
684
|
onLostPointerCapture: () => {
|
|
652
|
-
|
|
685
|
+
O.current[e] = e !== "fire" && 0;
|
|
653
686
|
}
|
|
654
687
|
});
|
|
655
688
|
return /* @__PURE__ */ v("section", {
|
|
@@ -673,9 +706,9 @@ function Z({ gameKey: n, currentUserId: r, onMinimize: i, onDismiss: d, suspende
|
|
|
673
706
|
})
|
|
674
707
|
]
|
|
675
708
|
}),
|
|
676
|
-
|
|
709
|
+
C.status === "invited" && /* @__PURE__ */ v("div", {
|
|
677
710
|
className: "tl-invite",
|
|
678
|
-
children: [/* @__PURE__ */ _("p", { children:
|
|
711
|
+
children: [/* @__PURE__ */ _("p", { children: z ? "Te invitaron a un combate en tiempo real." : "Esperando que el rival acepte…" }), z && /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _("button", {
|
|
679
712
|
onClick: () => Y(n, "game_accept"),
|
|
680
713
|
children: "Aceptar"
|
|
681
714
|
}), /* @__PURE__ */ _("button", {
|
|
@@ -683,10 +716,10 @@ function Z({ gameKey: n, currentUserId: r, onMinimize: i, onDismiss: d, suspende
|
|
|
683
716
|
children: "Rechazar"
|
|
684
717
|
})] })]
|
|
685
718
|
}),
|
|
686
|
-
(
|
|
719
|
+
(I || k) && /* @__PURE__ */ v(g, { children: [
|
|
687
720
|
/* @__PURE__ */ v("div", {
|
|
688
721
|
className: "tl-hud",
|
|
689
|
-
children: [(
|
|
722
|
+
children: [(k?.tanks || []).map((e) => /* @__PURE__ */ v("span", { children: [
|
|
690
723
|
e.self ? "Tú" : "Rival",
|
|
691
724
|
" ",
|
|
692
725
|
/* @__PURE__ */ _("meter", {
|
|
@@ -701,31 +734,31 @@ function Z({ gameKey: n, currentUserId: r, onMinimize: i, onDismiss: d, suspende
|
|
|
701
734
|
] }, e.id)), /* @__PURE__ */ v("span", {
|
|
702
735
|
role: "status",
|
|
703
736
|
children: [
|
|
704
|
-
|
|
737
|
+
k?.net?.phase || "Conectando WebRTC…",
|
|
705
738
|
" ",
|
|
706
|
-
|
|
739
|
+
k?.net?.route?.label || (typeof k?.net?.route == "string" ? k.net.route : ""),
|
|
707
740
|
" ",
|
|
708
|
-
Number.isFinite(
|
|
741
|
+
Number.isFinite(k?.net?.rtt) ? `${Math.round(k.net.rtt)} ms` : ""
|
|
709
742
|
]
|
|
710
743
|
})]
|
|
711
744
|
}),
|
|
712
745
|
/* @__PURE__ */ _("div", {
|
|
713
746
|
className: "tl-stage",
|
|
714
|
-
ref:
|
|
747
|
+
ref: T,
|
|
715
748
|
tabIndex: 0,
|
|
716
749
|
"aria-label": "Arena. WASD o flechas para conducir, ratón para apuntar, clic o espacio para disparar",
|
|
717
|
-
onPointerMove:
|
|
750
|
+
onPointerMove: V,
|
|
718
751
|
onPointerDown: (e) => {
|
|
719
|
-
|
|
752
|
+
V(e), e.pointerType === "mouse" && (e.currentTarget.focus(), e.currentTarget.setPointerCapture(e.pointerId), V(e), O.current.fire = !0);
|
|
720
753
|
},
|
|
721
754
|
onPointerUp: () => {
|
|
722
|
-
|
|
755
|
+
O.current.fire = !1;
|
|
723
756
|
},
|
|
724
757
|
onPointerCancel: () => {
|
|
725
|
-
X(
|
|
758
|
+
X(O.current);
|
|
726
759
|
},
|
|
727
760
|
onLostPointerCapture: () => {
|
|
728
|
-
|
|
761
|
+
O.current.fire = !1;
|
|
729
762
|
}
|
|
730
763
|
}),
|
|
731
764
|
/* @__PURE__ */ v("div", {
|
|
@@ -738,16 +771,16 @@ function Z({ gameKey: n, currentUserId: r, onMinimize: i, onDismiss: d, suspende
|
|
|
738
771
|
onPointerDown: (e) => {
|
|
739
772
|
e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId);
|
|
740
773
|
let t = e.currentTarget.getBoundingClientRect();
|
|
741
|
-
|
|
774
|
+
O.current.steer = Math.max(-1, Math.min(1, (e.clientX - t.left - t.width / 2) / (t.width / 2))), O.current.throttle = Math.max(-1, Math.min(1, -(e.clientY - t.top - t.height / 2) / (t.height / 2)));
|
|
742
775
|
},
|
|
743
776
|
onPointerMove: (e) => {
|
|
744
777
|
if (!e.currentTarget.hasPointerCapture(e.pointerId)) return;
|
|
745
778
|
let t = e.currentTarget.getBoundingClientRect();
|
|
746
|
-
|
|
779
|
+
O.current.steer = Math.max(-1, Math.min(1, (e.clientX - t.left - t.width / 2) / (t.width / 2))), O.current.throttle = Math.max(-1, Math.min(1, -(e.clientY - t.top - t.height / 2) / (t.height / 2)));
|
|
747
780
|
},
|
|
748
|
-
onPointerUp: () => X(
|
|
749
|
-
onPointerCancel: () => X(
|
|
750
|
-
onLostPointerCapture: () => X(
|
|
781
|
+
onPointerUp: () => X(O.current),
|
|
782
|
+
onPointerCancel: () => X(O.current),
|
|
783
|
+
onLostPointerCapture: () => X(O.current),
|
|
751
784
|
children: "✥"
|
|
752
785
|
}),
|
|
753
786
|
/* @__PURE__ */ v("div", {
|
|
@@ -756,29 +789,29 @@ function Z({ gameKey: n, currentUserId: r, onMinimize: i, onDismiss: d, suspende
|
|
|
756
789
|
children: [
|
|
757
790
|
/* @__PURE__ */ _("button", {
|
|
758
791
|
"aria-label": "Avanzar",
|
|
759
|
-
...
|
|
792
|
+
...U("throttle", 1),
|
|
760
793
|
children: "▲"
|
|
761
794
|
}),
|
|
762
795
|
/* @__PURE__ */ _("button", {
|
|
763
796
|
"aria-label": "Girar izquierda",
|
|
764
|
-
...
|
|
797
|
+
...U("steer", -1),
|
|
765
798
|
children: "◀"
|
|
766
799
|
}),
|
|
767
800
|
/* @__PURE__ */ _("button", {
|
|
768
801
|
"aria-label": "Retroceder",
|
|
769
|
-
...
|
|
802
|
+
...U("throttle", -1),
|
|
770
803
|
children: "▼"
|
|
771
804
|
}),
|
|
772
805
|
/* @__PURE__ */ _("button", {
|
|
773
806
|
"aria-label": "Girar derecha",
|
|
774
|
-
...
|
|
807
|
+
...U("steer", 1),
|
|
775
808
|
children: "▶"
|
|
776
809
|
})
|
|
777
810
|
]
|
|
778
811
|
}),
|
|
779
812
|
/* @__PURE__ */ _("button", {
|
|
780
813
|
className: "tl-fire",
|
|
781
|
-
...
|
|
814
|
+
...U("fire", !0),
|
|
782
815
|
children: "Disparar"
|
|
783
816
|
})
|
|
784
817
|
]
|
|
@@ -789,22 +822,22 @@ function Z({ gameKey: n, currentUserId: r, onMinimize: i, onDismiss: d, suspende
|
|
|
789
822
|
"Recarga ",
|
|
790
823
|
/* @__PURE__ */ _("progress", {
|
|
791
824
|
max: "1",
|
|
792
|
-
value:
|
|
825
|
+
value: H(k?.tanks)?.reload ?? 1
|
|
793
826
|
}),
|
|
794
827
|
" ",
|
|
795
|
-
(
|
|
828
|
+
(H(k?.tanks)?.reload ?? 1) >= 1 ? "Listo" : "Recargando…"
|
|
796
829
|
] })
|
|
797
830
|
}),
|
|
798
831
|
/* @__PURE__ */ _("small", { children: "WASD / flechas · ratón o toca la arena para apuntar · espacio / clic para disparar" }),
|
|
799
832
|
/* @__PURE__ */ _("button", {
|
|
800
|
-
onClick: () =>
|
|
801
|
-
children:
|
|
833
|
+
onClick: () => M((e) => !e),
|
|
834
|
+
children: P === "2d" ? "Probar 3D" : "Vista 2D"
|
|
802
835
|
})
|
|
803
836
|
] }),
|
|
804
|
-
|
|
837
|
+
B && /* @__PURE__ */ v("p", {
|
|
805
838
|
role: "status",
|
|
806
839
|
children: [
|
|
807
|
-
String(
|
|
840
|
+
String(k?.winner ?? C.winnerId) === String(r) ? "¡Victoria!" : "Fin del combate",
|
|
808
841
|
" ",
|
|
809
842
|
/* @__PURE__ */ _("button", {
|
|
810
843
|
onClick: () => {
|
|
@@ -814,29 +847,44 @@ function Z({ gameKey: n, currentUserId: r, onMinimize: i, onDismiss: d, suspende
|
|
|
814
847
|
})
|
|
815
848
|
]
|
|
816
849
|
}),
|
|
817
|
-
|
|
818
|
-
|
|
850
|
+
I && !B && k?.net?.phase !== "connected" && /* @__PURE__ */ v("div", {
|
|
851
|
+
className: "tl-connection",
|
|
852
|
+
children: [/* @__PURE__ */ _("p", {
|
|
853
|
+
role: "status",
|
|
854
|
+
children: S(k?.net)
|
|
855
|
+
}), /* @__PURE__ */ _("button", {
|
|
856
|
+
type: "button",
|
|
857
|
+
onClick: () => E.current?.reconnect(),
|
|
858
|
+
children: "Reintentar conexión"
|
|
859
|
+
})]
|
|
860
|
+
}),
|
|
861
|
+
I && /* @__PURE__ */ v("details", {
|
|
862
|
+
className: "tl-diagnostics",
|
|
863
|
+
children: [/* @__PURE__ */ _("summary", { children: "Diagnóstico de conexión" }), /* @__PURE__ */ _("pre", { children: JSON.stringify(x(k?.net), null, 2) })]
|
|
864
|
+
}),
|
|
865
|
+
I && !B && /* @__PURE__ */ _("button", {
|
|
866
|
+
onClick: () => E.current?.resign(),
|
|
819
867
|
children: "Rendirse"
|
|
820
868
|
}),
|
|
821
|
-
|
|
869
|
+
C.pending && /* @__PURE__ */ _("p", {
|
|
822
870
|
role: "status",
|
|
823
871
|
children: "Enviando…"
|
|
824
872
|
}),
|
|
825
|
-
|
|
873
|
+
C.pendingEvent && C.error && /* @__PURE__ */ _("button", {
|
|
826
874
|
onClick: () => {
|
|
827
875
|
e.getState().retry(n).catch(() => {});
|
|
828
876
|
},
|
|
829
877
|
children: "Reintentar envío"
|
|
830
878
|
}),
|
|
831
|
-
|
|
879
|
+
ee && /* @__PURE__ */ _("p", {
|
|
832
880
|
role: "alert",
|
|
833
|
-
children:
|
|
881
|
+
children: ee
|
|
834
882
|
}),
|
|
835
|
-
|
|
883
|
+
C.error && /* @__PURE__ */ _("p", {
|
|
836
884
|
role: "alert",
|
|
837
|
-
children:
|
|
885
|
+
children: C.error
|
|
838
886
|
}),
|
|
839
|
-
!["closed", "declined"].includes(
|
|
887
|
+
!["closed", "declined"].includes(C.status) && /* @__PURE__ */ _("button", {
|
|
840
888
|
onClick: () => Y(n, "game_end"),
|
|
841
889
|
children: "Cerrar partida"
|
|
842
890
|
})
|
|
@@ -844,6 +892,6 @@ function Z({ gameKey: n, currentUserId: r, onMinimize: i, onDismiss: d, suspende
|
|
|
844
892
|
});
|
|
845
893
|
}
|
|
846
894
|
var Q = d(Z);
|
|
847
|
-
export {
|
|
895
|
+
export { U as a, V as c, Q as default, R as i, W as l, P as n, z as o, I as r, B as s, J as t };
|
|
848
896
|
|
|
849
|
-
//# sourceMappingURL=TanksLiveGameCard-
|
|
897
|
+
//# sourceMappingURL=TanksLiveGameCard-BxQGR8P9.js.map
|