@minicode-dev/chat 0.1.14 → 0.1.16
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 +10 -0
- package/dist/chunks/{BattleshipGameCard-B-B4r7lK.js → BattleshipGameCard-DwNzgH5G.js} +199 -199
- package/dist/chunks/{BattleshipGameCard-B-B4r7lK.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-DQtKsR6Z.js → ChatContext-D5rqvt5D.js} +2 -2
- package/dist/chunks/{ChatContext-DQtKsR6Z.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-CvTaF7tu.js → TanksGameCard-B-gtDYYg.js} +144 -144
- package/dist/chunks/{TanksGameCard-CvTaF7tu.js.map → TanksGameCard-B-gtDYYg.js.map} +1 -1
- package/dist/chunks/TanksLiveGameCard-DXgd1J2Y.js +1274 -0
- package/dist/chunks/TanksLiveGameCard-DXgd1J2Y.js.map +1 -0
- package/dist/chunks/{avalancheScene3d-Z5QyZIid.js → avalancheScene3d-CNbQyGUd.js} +51 -50
- package/dist/chunks/{avalancheScene3d-Z5QyZIid.js.map → avalancheScene3d-CNbQyGUd.js.map} +1 -1
- package/dist/chunks/cars-D1PM7mVD.js +340 -0
- package/dist/chunks/cars-D1PM7mVD.js.map +1 -0
- package/dist/chunks/{connect4Sounds-DmD-E9kX.js → connect4Sounds-3a6h7gUC.js} +8 -8
- package/dist/chunks/{connect4Sounds-DmD-E9kX.js.map → connect4Sounds-3a6h7gUC.js.map} +1 -1
- package/dist/chunks/createLiveScene-jrzyQogh.js +756 -0
- package/dist/chunks/createLiveScene-jrzyQogh.js.map +1 -0
- 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/fx-DhXerGyt.js +248 -0
- package/dist/chunks/fx-DhXerGyt.js.map +1 -0
- package/dist/chunks/{games-BvYTWgaR.js → games-D_9SiSBT.js} +1261 -677
- 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-DwjfSp3W.js → tanksSounds-tYPzje61.js} +5 -5
- package/dist/chunks/{tanksSounds-DwjfSp3W.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 +4244 -4028
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunks/RacingLiveGameCard-c1G7uoDI.js +0 -1654
- package/dist/chunks/RacingLiveGameCard-c1G7uoDI.js.map +0 -1
- package/dist/chunks/TanksLiveGameCard-COr9Oay5.js +0 -1011
- package/dist/chunks/TanksLiveGameCard-COr9Oay5.js.map +0 -1
- package/dist/chunks/createLiveScene-CWBunxPi.js +0 -367
- package/dist/chunks/createLiveScene-CWBunxPi.js.map +0 -1
- package/dist/chunks/createRaceScene-C7Rw89kj.js +0 -305
- package/dist/chunks/createRaceScene-C7Rw89kj.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/fx-UZwhOmdl.js +0 -584
- package/dist/chunks/fx-UZwhOmdl.js.map +0 -1
- package/dist/chunks/games-BvYTWgaR.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,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import { createStore as
|
|
4
|
-
import { useStore as
|
|
1
|
+
import { c as e, f as t, l as n, s as r, t as i, u as a } from "./track-C1TWWT19.js";
|
|
2
|
+
import { a as o, c as s, i as c, n as l, r as u, s as d, t as f } from "./board-DXKuIZ1I.js";
|
|
3
|
+
import { createStore as p } from "zustand/vanilla";
|
|
4
|
+
import { useStore as m } from "zustand";
|
|
5
5
|
// src/core/ids/randomUuid.js
|
|
6
|
-
function
|
|
6
|
+
function h(e = globalThis.crypto) {
|
|
7
7
|
if (typeof e?.randomUUID == "function") return e.randomUUID();
|
|
8
8
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
9
9
|
if (typeof e?.getRandomValues == "function") e.getRandomValues(t);
|
|
@@ -12,25 +12,577 @@ function p(e = globalThis.crypto) {
|
|
|
12
12
|
let n = Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
13
13
|
return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
|
|
14
14
|
}
|
|
15
|
+
// src/games/tanks-live/logic/simulation.js
|
|
16
|
+
var g = Object.freeze({
|
|
17
|
+
speed: 16,
|
|
18
|
+
reverse: 9,
|
|
19
|
+
turn: 1.8,
|
|
20
|
+
acceleration: 28,
|
|
21
|
+
radius: 2,
|
|
22
|
+
reloadMs: 1500,
|
|
23
|
+
shellSpeed: 60,
|
|
24
|
+
damage: 25
|
|
25
|
+
}), _ = (e, t, n) => Math.max(t, Math.min(n, e)), v = (e, t) => Math.atan2(Math.sin(t - e), Math.cos(t - e));
|
|
26
|
+
function y() {
|
|
27
|
+
return {
|
|
28
|
+
size: 120,
|
|
29
|
+
bounds: {
|
|
30
|
+
minX: 0,
|
|
31
|
+
maxX: 120,
|
|
32
|
+
minZ: 0,
|
|
33
|
+
maxZ: 120
|
|
34
|
+
},
|
|
35
|
+
obstacles: [
|
|
36
|
+
[
|
|
37
|
+
42,
|
|
38
|
+
35,
|
|
39
|
+
4
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
78,
|
|
43
|
+
85,
|
|
44
|
+
4
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
60,
|
|
48
|
+
30,
|
|
49
|
+
3
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
60,
|
|
53
|
+
90,
|
|
54
|
+
3
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
35,
|
|
58
|
+
65,
|
|
59
|
+
3
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
85,
|
|
63
|
+
55,
|
|
64
|
+
3
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
60,
|
|
68
|
+
60,
|
|
69
|
+
5
|
|
70
|
+
]
|
|
71
|
+
].map(([e, t, n], r) => ({
|
|
72
|
+
x: e,
|
|
73
|
+
z: t,
|
|
74
|
+
r: n,
|
|
75
|
+
kind: r % 2 ? "tree" : "rock"
|
|
76
|
+
}))
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function b(e, t) {
|
|
80
|
+
return {
|
|
81
|
+
id: String(e),
|
|
82
|
+
x: t ? 102 : 18,
|
|
83
|
+
z: 60,
|
|
84
|
+
yaw: t ? Math.PI : 0,
|
|
85
|
+
turretYaw: t ? Math.PI : 0,
|
|
86
|
+
speed: 0,
|
|
87
|
+
hp: 100,
|
|
88
|
+
alive: !0,
|
|
89
|
+
color: t ? "#d7463f" : "#54a34a"
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
var x = Object.freeze({
|
|
93
|
+
radius: 6,
|
|
94
|
+
damage: 20
|
|
95
|
+
}), S = (e) => !!e && e.alive !== !1 && (e.hp === void 0 || e.hp > 0);
|
|
96
|
+
function ee(e, t, n) {
|
|
97
|
+
let r = t - e.x, i = n - e.z, a = Math.cos(e.rot || 0), o = Math.sin(e.rot || 0);
|
|
98
|
+
return [r * a + i * o, -r * o + i * a];
|
|
99
|
+
}
|
|
100
|
+
function te(e, t, n, r) {
|
|
101
|
+
if (r.shape !== "rect") return Math.hypot(e - r.x, t - r.z) < r.r + n;
|
|
102
|
+
let [i, a] = ee(r, e, t), o = r.w / 2, s = r.d / 2;
|
|
103
|
+
return Math.hypot(i - _(i, -o, o), a - _(a, -s, s)) < n || Math.abs(i) <= o && Math.abs(a) <= s;
|
|
104
|
+
}
|
|
105
|
+
function ne(e, t, n, r = g.radius) {
|
|
106
|
+
let i = n.bounds;
|
|
107
|
+
return e >= i.minX + r && e <= i.maxX - r && t >= i.minZ + r && t <= i.maxZ - r && !n.obstacles.some((n) => te(e, t, r, n)) && !(n.destructibles || []).some((n) => S(n) && te(e, t, r, n));
|
|
108
|
+
}
|
|
109
|
+
function re(e, t, n, r) {
|
|
110
|
+
if (!e.alive) return;
|
|
111
|
+
let i = _(Number(t.throttle) || 0, -1, 1), a = _(Number(t.steer) || 0, -1, 1), o = i * (i < 0 ? g.reverse : g.speed);
|
|
112
|
+
e.speed += _(o - e.speed, -g.acceleration * n, g.acceleration * n), e.yaw += a * g.turn * n, Number.isFinite(t.turretYaw) && (e.turretYaw = t.turretYaw);
|
|
113
|
+
let s = e.x + Math.cos(e.yaw) * e.speed * n, c = e.z + Math.sin(e.yaw) * e.speed * n;
|
|
114
|
+
ne(s, e.z, r) ? e.x = s : e.speed = 0, ne(e.x, c, r) ? e.z = c : e.speed = 0;
|
|
115
|
+
}
|
|
116
|
+
function ie(e, t, n, r, i, a, o) {
|
|
117
|
+
let s = n - e, c = r - t, l = s * s + c * c, u = l ? _(((i - e) * s + (a - t) * c) / l, 0, 1) : 0;
|
|
118
|
+
return Math.hypot(e + s * u - i, t + c * u - a) <= o ? u : null;
|
|
119
|
+
}
|
|
120
|
+
function ae(e, t, n, r, i) {
|
|
121
|
+
let [a, o] = ee(i, e, t), [s, c] = ee(i, n, r), l = [s - a, c - o], u = [a, o], d = [i.w / 2, i.d / 2], f = 0, p = 1;
|
|
122
|
+
for (let e = 0; e < 2; e++) {
|
|
123
|
+
if (Math.abs(l[e]) < 1e-12) {
|
|
124
|
+
if (Math.abs(u[e]) > d[e]) return null;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
let t = (-d[e] - u[e]) / l[e], n = (d[e] - u[e]) / l[e];
|
|
128
|
+
if (t > n && ([t, n] = [n, t]), f = Math.max(f, t), p = Math.min(p, n), f > p) return null;
|
|
129
|
+
}
|
|
130
|
+
return f;
|
|
131
|
+
}
|
|
132
|
+
var oe = (e, t, n, r, i) => i.shape === "rect" ? ae(e, t, n, r, i) : ie(e, t, n, r, i.x, i.z, i.r);
|
|
133
|
+
function se(e, t, n, r) {
|
|
134
|
+
let i = e.x + Math.cos(e.yaw) * g.shellSpeed * t, a = e.z + Math.sin(e.yaw) * g.shellSpeed * t, o = null;
|
|
135
|
+
for (let t of n.obstacles) {
|
|
136
|
+
let n = oe(e.x, e.z, i, a, t);
|
|
137
|
+
n !== null && (!o || n < o.t) && (o = t.shape === "rect" ? {
|
|
138
|
+
t: n,
|
|
139
|
+
kind: "obstacle",
|
|
140
|
+
shape: "rect",
|
|
141
|
+
id: t.id,
|
|
142
|
+
obstacleKind: t.kind
|
|
143
|
+
} : {
|
|
144
|
+
t: n,
|
|
145
|
+
kind: "obstacle"
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
for (let t of n.destructibles || []) {
|
|
149
|
+
if (!S(t)) continue;
|
|
150
|
+
let n = oe(e.x, e.z, i, a, t);
|
|
151
|
+
n !== null && (!o || n < o.t) && (o = {
|
|
152
|
+
t: n,
|
|
153
|
+
kind: "destructible",
|
|
154
|
+
id: t.id,
|
|
155
|
+
destructibleKind: t.kind
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
for (let t of r) {
|
|
159
|
+
if (!t.alive || t.id === e.owner) continue;
|
|
160
|
+
let n = ie(e.x, e.z, i, a, t.x, t.z, g.radius);
|
|
161
|
+
n !== null && (!o || n < o.t) && (o = {
|
|
162
|
+
t: n,
|
|
163
|
+
kind: "tank",
|
|
164
|
+
target: t.id
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
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, !ne(i, a, {
|
|
168
|
+
...n,
|
|
169
|
+
obstacles: [],
|
|
170
|
+
destructibles: []
|
|
171
|
+
}, 0) || e.age > 3 ? { kind: "terrain" } : null);
|
|
172
|
+
}
|
|
173
|
+
function ce(e, t, n = 1) {
|
|
174
|
+
let r = (e?.destructibles || []).find((e) => e.id === t);
|
|
175
|
+
return S(r) ? (r.hp = Math.max(0, (r.hp ?? 1) - Math.max(0, Number(n) || 0)), r.hp === 0 && (r.alive = !1), {
|
|
176
|
+
destroyed: r.hp === 0,
|
|
177
|
+
kind: r.kind,
|
|
178
|
+
hp: r.hp
|
|
179
|
+
}) : {
|
|
180
|
+
destroyed: !1,
|
|
181
|
+
kind: r?.kind ?? null,
|
|
182
|
+
hp: 0
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function le(e, t, n, r = x.radius, i = x.damage) {
|
|
186
|
+
return e.filter((e) => e.alive !== !1 && Math.hypot(e.x - t, e.z - n) <= r).map((e) => ({
|
|
187
|
+
id: e.id,
|
|
188
|
+
dmg: i
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
function ue(e, t, n) {
|
|
192
|
+
let r = (e?.destructibles || []).find((e) => e.id === t);
|
|
193
|
+
if (!r) return {
|
|
194
|
+
hits: [],
|
|
195
|
+
chained: null
|
|
196
|
+
};
|
|
197
|
+
let i = [r], a = (e.destructibles || []).filter((e) => e !== r && e.kind === "barrel" && S(e) && Math.hypot(e.x - r.x, e.z - r.z) <= x.radius).sort((e, t) => Math.hypot(e.x - r.x, e.z - r.z) - Math.hypot(t.x - r.x, t.z - r.z))[0];
|
|
198
|
+
a && (a.hp = 0, a.alive = !1, i.push(a));
|
|
199
|
+
let o = /* @__PURE__ */ new Map();
|
|
200
|
+
for (let e of i) for (let t of le(n, e.x, e.z)) o.set(t.id, (o.get(t.id) || 0) + t.dmg);
|
|
201
|
+
return {
|
|
202
|
+
hits: [...o].map(([e, t]) => ({
|
|
203
|
+
id: e,
|
|
204
|
+
dmg: t
|
|
205
|
+
})),
|
|
206
|
+
chained: a ? {
|
|
207
|
+
id: a.id,
|
|
208
|
+
x: a.x,
|
|
209
|
+
z: a.z
|
|
210
|
+
} : null
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function de(e, t, n) {
|
|
214
|
+
let r = _(n, 0, 1);
|
|
215
|
+
return {
|
|
216
|
+
...t,
|
|
217
|
+
x: e.x + (t.x - e.x) * r,
|
|
218
|
+
z: e.z + (t.z - e.z) * r,
|
|
219
|
+
yaw: e.yaw + v(e.yaw, t.yaw) * r,
|
|
220
|
+
turretYaw: e.turretYaw + v(e.turretYaw, t.turretYaw) * r
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
// src/games/tanks-live/logic/maps.js
|
|
224
|
+
var fe = Object.freeze([
|
|
225
|
+
"meadow",
|
|
226
|
+
"forest",
|
|
227
|
+
"desert",
|
|
228
|
+
"ruins",
|
|
229
|
+
"arctic",
|
|
230
|
+
"random"
|
|
231
|
+
]), pe = [
|
|
232
|
+
"forest",
|
|
233
|
+
"desert",
|
|
234
|
+
"ruins",
|
|
235
|
+
"arctic"
|
|
236
|
+
], C = 120, me = C / 2, he = 4, ge = 12, _e = 1.5, ve = 2, ye = () => [{
|
|
237
|
+
x: 18,
|
|
238
|
+
z: 60,
|
|
239
|
+
yaw: 0
|
|
240
|
+
}, {
|
|
241
|
+
x: 102,
|
|
242
|
+
z: 60,
|
|
243
|
+
yaw: Math.PI
|
|
244
|
+
}], be = {
|
|
245
|
+
crate: {
|
|
246
|
+
r: 1.2,
|
|
247
|
+
hp: 2
|
|
248
|
+
},
|
|
249
|
+
barrel: {
|
|
250
|
+
r: .9,
|
|
251
|
+
hp: 1
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
function xe(e) {
|
|
255
|
+
let t = e >>> 0;
|
|
256
|
+
return () => {
|
|
257
|
+
t = t + 1831565813 >>> 0;
|
|
258
|
+
let e = t;
|
|
259
|
+
return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
var w = (e) => Math.round(e * 10) / 10, T = (e, t, n) => t + e() * (n - t), Se = (e, t) => t[Math.floor(e() * t.length) % t.length];
|
|
263
|
+
function Ce(e, t) {
|
|
264
|
+
let n = e() * t.reduce((e, t) => e + t.w, 0);
|
|
265
|
+
for (let e of t) if (n -= e.w, n < 0) return e;
|
|
266
|
+
return t[t.length - 1];
|
|
267
|
+
}
|
|
268
|
+
var E = (e, t, n) => ({
|
|
269
|
+
kind: e,
|
|
270
|
+
make: (r) => ({
|
|
271
|
+
shape: "circle",
|
|
272
|
+
kind: e,
|
|
273
|
+
r: w(T(r, t, n))
|
|
274
|
+
})
|
|
275
|
+
}), D = (e, t, n, r) => ({
|
|
276
|
+
kind: e,
|
|
277
|
+
make: (i) => ({
|
|
278
|
+
shape: "rect",
|
|
279
|
+
kind: e,
|
|
280
|
+
w: w(T(i, ...t)),
|
|
281
|
+
d: w(T(i, ...n)),
|
|
282
|
+
rot: r ? Se(i, r) : w(T(i, 0, Math.PI))
|
|
283
|
+
})
|
|
284
|
+
}), we = [0, Math.PI / 2], Te = {
|
|
285
|
+
forest: {
|
|
286
|
+
count: [18, 25],
|
|
287
|
+
destructibles: [2, 4],
|
|
288
|
+
decor: [
|
|
289
|
+
"grass",
|
|
290
|
+
"flower",
|
|
291
|
+
"bush",
|
|
292
|
+
"pebble"
|
|
293
|
+
],
|
|
294
|
+
items: [
|
|
295
|
+
{
|
|
296
|
+
w: 6,
|
|
297
|
+
...E("tree", 2, 3.2)
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
w: 2,
|
|
301
|
+
...E("log", 1.6, 2.2)
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
w: 1,
|
|
305
|
+
...E("rock", 2, 3)
|
|
306
|
+
}
|
|
307
|
+
]
|
|
308
|
+
},
|
|
309
|
+
desert: {
|
|
310
|
+
count: [12, 15],
|
|
311
|
+
destructibles: [2, 4],
|
|
312
|
+
decor: [
|
|
313
|
+
"pebble",
|
|
314
|
+
"dry_grass",
|
|
315
|
+
"cactus",
|
|
316
|
+
"bones"
|
|
317
|
+
],
|
|
318
|
+
items: [{
|
|
319
|
+
w: 3,
|
|
320
|
+
...E("rock", 5, 7)
|
|
321
|
+
}, {
|
|
322
|
+
w: 2,
|
|
323
|
+
...D("low", [8, 12], [1.8, 2.4])
|
|
324
|
+
}]
|
|
325
|
+
},
|
|
326
|
+
ruins: {
|
|
327
|
+
count: [16, 22],
|
|
328
|
+
destructibles: [4, 6],
|
|
329
|
+
decor: [
|
|
330
|
+
"rubble",
|
|
331
|
+
"pebble",
|
|
332
|
+
"weed"
|
|
333
|
+
],
|
|
334
|
+
items: [
|
|
335
|
+
{
|
|
336
|
+
w: 4,
|
|
337
|
+
...D("wall", [8, 14], [1.1, 1.4], we)
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
w: 2,
|
|
341
|
+
...D("house", [7, 9], [6, 8], we)
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
w: 2,
|
|
345
|
+
...D("car", [4.2, 4.6], [2, 2.3])
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
w: 1,
|
|
349
|
+
...E("rock", 2, 3)
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
},
|
|
353
|
+
arctic: {
|
|
354
|
+
count: [14, 20],
|
|
355
|
+
destructibles: [2, 4],
|
|
356
|
+
decor: [
|
|
357
|
+
"snow",
|
|
358
|
+
"ice_shard",
|
|
359
|
+
"pebble"
|
|
360
|
+
],
|
|
361
|
+
items: [
|
|
362
|
+
{
|
|
363
|
+
w: 3,
|
|
364
|
+
...D("ice_block", [3, 5], [3, 5])
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
w: 2,
|
|
368
|
+
...E("ice", 2.5, 4)
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
w: 2,
|
|
372
|
+
...E("tree", 2, 3)
|
|
373
|
+
}
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
}, Ee = (e) => e.shape === "rect" ? Math.hypot(e.w, e.d) / 2 : e.r, De = (e) => ({
|
|
377
|
+
...e,
|
|
378
|
+
x: w(C - e.x),
|
|
379
|
+
z: w(C - e.z)
|
|
380
|
+
}), Oe = (e) => e.shape !== "rect" || e.kind !== "low";
|
|
381
|
+
function ke(e) {
|
|
382
|
+
let t = Ee(e);
|
|
383
|
+
return e.x - t >= he && e.x + t <= 116 && e.z - t >= he && e.z + t <= 116;
|
|
384
|
+
}
|
|
385
|
+
function Ae(e, t, n) {
|
|
386
|
+
let r = Ee(e);
|
|
387
|
+
return !ke(e) || n.some((t) => Math.hypot(e.x - t.x, e.z - t.z) - r < ge) ? !1 : t.every((t) => Math.hypot(e.x - t.x, e.z - t.z) >= r + Ee(t) + _e);
|
|
388
|
+
}
|
|
389
|
+
function je(e, t, n) {
|
|
390
|
+
if (n.shape !== "rect") return Math.hypot(e - n.x, t - n.z) - n.r;
|
|
391
|
+
let r = Math.cos(-n.rot), i = Math.sin(-n.rot), a = e - n.x, o = t - n.z, s = Math.abs(a * r - o * i) - n.w / 2, c = Math.abs(a * i + o * r) - n.d / 2;
|
|
392
|
+
return Math.hypot(Math.max(s, 0), Math.max(c, 0)) + Math.min(Math.max(s, c), 0);
|
|
393
|
+
}
|
|
394
|
+
function Me(e, t, n, r = ve) {
|
|
395
|
+
let i = [...e.filter(Oe), ...t], a = (e, t) => e >= r && e <= C - r && t >= r && t <= C - r && i.every((n) => je(e, t, n) >= r), o = /* @__PURE__ */ new Uint8Array(14641), [s, c] = n.map((e) => [Math.round(e.x), Math.round(e.z)]), l = [s];
|
|
396
|
+
o[s[0] * 121 + s[1]] = 1;
|
|
397
|
+
for (let e = 0; e < l.length; e++) {
|
|
398
|
+
let [t, n] = l[e];
|
|
399
|
+
if (t === c[0] && n === c[1]) return !0;
|
|
400
|
+
for (let [e, r] of [
|
|
401
|
+
[1, 0],
|
|
402
|
+
[-1, 0],
|
|
403
|
+
[0, 1],
|
|
404
|
+
[0, -1]
|
|
405
|
+
]) {
|
|
406
|
+
let i = t + e, s = n + r;
|
|
407
|
+
i < 0 || s < 0 || i >= 121 || s >= 121 || o[i * 121 + s] || !a(i, s) || (o[i * 121 + s] = 1, l.push([i, s]));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return !1;
|
|
411
|
+
}
|
|
412
|
+
function Ne(e, t, n, r, i, a = 1500) {
|
|
413
|
+
let o = [];
|
|
414
|
+
for (let s = 0; o.length < n && s < a; s++) {
|
|
415
|
+
let n = t(), a = Ee(n);
|
|
416
|
+
n.x = w(T(e, he + a, 116 - a)), n.z = w(T(e, he + a, 116 - a));
|
|
417
|
+
let s = De(n);
|
|
418
|
+
if (Math.hypot(n.x - s.x, n.z - s.z) < 2 * a + _e) continue;
|
|
419
|
+
let c = [...r, ...o];
|
|
420
|
+
Ae(n, c, i) && Ae(s, [...c, n], i) && o.push(n, s);
|
|
421
|
+
}
|
|
422
|
+
return o;
|
|
423
|
+
}
|
|
424
|
+
function Pe(e, t, n) {
|
|
425
|
+
let [r, i] = e.count, a = r + Math.floor(t() * (i - r + 1)), o = [];
|
|
426
|
+
if (a % 2) {
|
|
427
|
+
let r = Ce(t, e.items).make(t);
|
|
428
|
+
r.x = me, r.z = me, Ae(r, [], n) && o.push(r);
|
|
429
|
+
}
|
|
430
|
+
o.push(...Ne(t, () => Ce(t, e.items).make(t), a - o.length, o, n));
|
|
431
|
+
let [s, c] = e.destructibles, l = Ne(t, () => {
|
|
432
|
+
let e = t() < .5 ? "crate" : "barrel";
|
|
433
|
+
return {
|
|
434
|
+
shape: "circle",
|
|
435
|
+
kind: e,
|
|
436
|
+
...be[e]
|
|
437
|
+
};
|
|
438
|
+
}, 2 * (s / 2 + Math.floor(t() * ((c - s) / 2 + 1))), o, n);
|
|
439
|
+
for (; !Me(o, l, n);) if (l.length > 2) l.splice(-2);
|
|
440
|
+
else if (o.length > r) o.splice(-2);
|
|
441
|
+
else return null;
|
|
442
|
+
return o.length < r || o.length > 25 || l.length < 2 || l.length > 6 ? null : {
|
|
443
|
+
obstacles: o,
|
|
444
|
+
destructibles: l
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
function Fe(e, t, n) {
|
|
448
|
+
return Array.from({ length: n }, (n, r) => ({
|
|
449
|
+
id: `c${r}`,
|
|
450
|
+
kind: Se(e, t),
|
|
451
|
+
x: w(T(e, 2, 118)),
|
|
452
|
+
z: w(T(e, 2, 118)),
|
|
453
|
+
s: w(T(e, .5, 1.5)),
|
|
454
|
+
rot: w(T(e, 0, Math.PI * 2))
|
|
455
|
+
}));
|
|
456
|
+
}
|
|
457
|
+
var O = (e) => (Math.round(e * 100) / 100).toFixed(2);
|
|
458
|
+
function Ie(e) {
|
|
459
|
+
let t = [e.id, e.size];
|
|
460
|
+
for (let n of [...e.obstacles || [], ...e.destructibles || []]) t.push(n.shape === "rect" ? `${n.id}:R:${n.kind}:${O(n.x)}:${O(n.z)}:${O(n.w)}:${O(n.d)}:${O(n.rot)}` : `${n.id}:C:${n.kind}:${O(n.x)}:${O(n.z)}:${O(n.r)}${n.hp == null ? "" : `:${n.hp}`}`);
|
|
461
|
+
for (let n of e.spawns || []) t.push(`S:${O(n.x)}:${O(n.z)}:${O(n.yaw)}`);
|
|
462
|
+
let n = t.join("|"), r = 2166136261;
|
|
463
|
+
for (let e = 0; e < n.length; e++) r ^= n.charCodeAt(e), r = Math.imul(r, 16777619) >>> 0;
|
|
464
|
+
return r.toString(16).padStart(8, "0");
|
|
465
|
+
}
|
|
466
|
+
function Le(e = "meadow", t = 0) {
|
|
467
|
+
t = Number(t) >>> 0;
|
|
468
|
+
let n = fe.includes(e) ? e : "meadow";
|
|
469
|
+
n === "random" && (n = pe[Math.floor(xe(t ^ 2654435769)() * pe.length)]);
|
|
470
|
+
let r = ye(), i = {
|
|
471
|
+
id: n,
|
|
472
|
+
seed: t,
|
|
473
|
+
size: C,
|
|
474
|
+
bounds: {
|
|
475
|
+
minX: 0,
|
|
476
|
+
maxX: C,
|
|
477
|
+
minZ: 0,
|
|
478
|
+
maxZ: C
|
|
479
|
+
},
|
|
480
|
+
spawns: r
|
|
481
|
+
}, a;
|
|
482
|
+
if (n === "meadow") {
|
|
483
|
+
let e = y();
|
|
484
|
+
a = {
|
|
485
|
+
...i,
|
|
486
|
+
obstacles: e.obstacles.map((e, t) => ({
|
|
487
|
+
id: `o${t}`,
|
|
488
|
+
shape: "circle",
|
|
489
|
+
...e
|
|
490
|
+
})),
|
|
491
|
+
destructibles: [],
|
|
492
|
+
decor: Fe(xe(t ^ 57024), [
|
|
493
|
+
"grass",
|
|
494
|
+
"flower",
|
|
495
|
+
"pebble"
|
|
496
|
+
], 40)
|
|
497
|
+
};
|
|
498
|
+
} else {
|
|
499
|
+
let e = Te[n], o = xe(t), s = null;
|
|
500
|
+
for (let t = 0; !s && t < 20; t++) s = Pe(e, o, r);
|
|
501
|
+
s || (s = {
|
|
502
|
+
obstacles: [],
|
|
503
|
+
destructibles: []
|
|
504
|
+
}), a = {
|
|
505
|
+
...i,
|
|
506
|
+
obstacles: s.obstacles.map((e, t) => ({
|
|
507
|
+
id: `o${t}`,
|
|
508
|
+
...e
|
|
509
|
+
})),
|
|
510
|
+
destructibles: s.destructibles.map((e, t) => ({
|
|
511
|
+
id: `d${t}`,
|
|
512
|
+
...e
|
|
513
|
+
})),
|
|
514
|
+
decor: Fe(xe(t ^ 57024), e.decor, 50)
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
return a.hash = Ie(a), a;
|
|
518
|
+
}
|
|
15
519
|
// src/games/tanks-live/session.js
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
520
|
+
var Re = (e) => typeof e == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e), ze = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, Be = (e) => typeof e == "object" && !!e && !Array.isArray(e), Ve = (e, t) => Object.keys(e).every((e) => t.includes(e)), He = (e) => Number.isInteger(e) && e >= 0 && e <= 4294967295, Ue = (e) => typeof e == "string" && /^[0-9a-f]{8}$/.test(e), We = Object.freeze([
|
|
521
|
+
1,
|
|
522
|
+
3,
|
|
523
|
+
5
|
|
524
|
+
]), Ge = Object.freeze(fe.filter((e) => e !== "random")), k = /* @__PURE__ */ new Map();
|
|
525
|
+
function Ke(e, t) {
|
|
526
|
+
let n = `${e}:${t}`;
|
|
527
|
+
return k.has(n) || (k.set(n, Le(e, t).hash), k.size > 32 && k.delete(k.keys().next().value)), k.get(n);
|
|
528
|
+
}
|
|
529
|
+
var qe = [
|
|
530
|
+
"map_id",
|
|
531
|
+
"seed",
|
|
532
|
+
"map_hash",
|
|
533
|
+
"lives"
|
|
534
|
+
];
|
|
535
|
+
function Je(e) {
|
|
536
|
+
let t = e?.data;
|
|
537
|
+
if (!Be(t)) return !1;
|
|
19
538
|
switch (e.type) {
|
|
20
|
-
case "game_invite": return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
539
|
+
case "game_invite": return !Ve(t, [
|
|
540
|
+
"opponent_id",
|
|
541
|
+
"rules_version",
|
|
542
|
+
"rematch_of",
|
|
543
|
+
...qe
|
|
544
|
+
]) || !ze(t.opponent_id) || t.rematch_of !== void 0 && !Re(t.rematch_of) ? !1 : t.rules_version === 1 ? qe.every((e) => t[e] === void 0) : t.rules_version === 2 && Ge.includes(t.map_id) && He(t.seed) && We.includes(t.lives) && Ue(t.map_hash) && t.map_hash === Ke(t.map_id, t.seed);
|
|
545
|
+
case "game_accept": return Ve(t, ["invite_event_id", "map_hash"]) && Re(t.invite_event_id) && (t.map_hash === void 0 || Ue(t.map_hash));
|
|
546
|
+
case "game_decline": return Ve(t, ["invite_event_id"]) && Re(t.invite_event_id);
|
|
547
|
+
case "game_end": return Ve(t, ["reason"]) && t.reason === "closed";
|
|
24
548
|
default: return !1;
|
|
25
549
|
}
|
|
26
550
|
}
|
|
27
|
-
|
|
551
|
+
var Ye = () => globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0];
|
|
552
|
+
function Xe({ opponentId: e, mapId: t = "random", lives: n = 3, seed: r = Ye(), rematchOf: i } = {}) {
|
|
553
|
+
let a = t === null;
|
|
554
|
+
if (!ze(e) || i !== void 0 && !Re(i) || !a && (!fe.includes(t) || !He(r) || !We.includes(n))) throw TypeError("Configuración de invitación de Tanques LIVE inválida");
|
|
555
|
+
let o = i === void 0 ? {} : { rematch_of: i };
|
|
556
|
+
if (a) return {
|
|
557
|
+
opponent_id: e,
|
|
558
|
+
rules_version: 1,
|
|
559
|
+
...o
|
|
560
|
+
};
|
|
561
|
+
let s = Le(t, r);
|
|
562
|
+
return {
|
|
563
|
+
opponent_id: e,
|
|
564
|
+
rules_version: 2,
|
|
565
|
+
map_id: s.id,
|
|
566
|
+
seed: r,
|
|
567
|
+
map_hash: s.hash,
|
|
568
|
+
lives: n,
|
|
569
|
+
...o
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function Ze(e, t) {
|
|
573
|
+
let n = t.rules_version === 2 ? {
|
|
574
|
+
mapId: t.map_id,
|
|
575
|
+
seed: t.seed,
|
|
576
|
+
mapHash: t.map_hash,
|
|
577
|
+
lives: t.lives
|
|
578
|
+
} : null;
|
|
28
579
|
return {
|
|
29
580
|
...e,
|
|
30
581
|
game: "tanks_live",
|
|
31
582
|
status: "invited",
|
|
32
583
|
turnId: null,
|
|
33
584
|
winnerId: null,
|
|
585
|
+
liveConfig: n,
|
|
34
586
|
rematchOf: t.rematch_of ?? null,
|
|
35
587
|
pending: !1,
|
|
36
588
|
pendingEvent: null,
|
|
@@ -38,7 +590,7 @@ function _(e, t) {
|
|
|
38
590
|
acceptEventId: null
|
|
39
591
|
};
|
|
40
592
|
}
|
|
41
|
-
function
|
|
593
|
+
function Qe(e, t, n) {
|
|
42
594
|
return [e.hostId, e.guestId].includes(n) ? t.type === "game_end" ? ["closed", "declined"].includes(e.status) ? e : {
|
|
43
595
|
...e,
|
|
44
596
|
status: "closed",
|
|
@@ -48,7 +600,7 @@ function v(e, t, n) {
|
|
|
48
600
|
...e,
|
|
49
601
|
status: "declined",
|
|
50
602
|
lastEventId: t.event_id
|
|
51
|
-
} : t.type === "game_accept" ? {
|
|
603
|
+
} : t.type === "game_accept" && t.data.map_hash === (e.liveConfig?.mapHash ?? void 0) ? {
|
|
52
604
|
...e,
|
|
53
605
|
status: "active",
|
|
54
606
|
acceptEventId: t.event_id,
|
|
@@ -56,45 +608,54 @@ function v(e, t, n) {
|
|
|
56
608
|
} : e : e;
|
|
57
609
|
}
|
|
58
610
|
// src/games/racing-live/session.js
|
|
59
|
-
var
|
|
60
|
-
function
|
|
61
|
-
let
|
|
62
|
-
if (!
|
|
63
|
-
switch (
|
|
64
|
-
case "game_invite": return
|
|
611
|
+
var $e = (e) => typeof e == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e), et = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, tt = (e) => typeof e == "object" && !!e && !Array.isArray(e), nt = (e, t) => Object.keys(e).every((e) => t.includes(e)), rt = (e) => typeof e == "string" && /^racing-v1-[0-9a-f]{8}$/.test(e), it = (e) => Number.isInteger(e) && e >= 0 && e <= 4294967295;
|
|
612
|
+
function at(e) {
|
|
613
|
+
let n = e?.data;
|
|
614
|
+
if (!tt(n)) return !1;
|
|
615
|
+
switch (e.type) {
|
|
616
|
+
case "game_invite": return nt(n, [
|
|
65
617
|
"opponent_id",
|
|
66
618
|
"rules_version",
|
|
67
619
|
"mode",
|
|
68
620
|
"map_id",
|
|
69
621
|
"seed",
|
|
70
622
|
"track_hash",
|
|
623
|
+
"track_id",
|
|
71
624
|
"laps",
|
|
72
625
|
"speed_class",
|
|
73
626
|
"rematch_of"
|
|
74
|
-
]) &&
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
627
|
+
]) && et(n.opponent_id) && n.rules_version === 1 && n.mode === "classic" && n.map_id === "neon_city" && it(n.seed) && (n.speed_class === void 0 || t(n.speed_class) !== null) && (n.track_id === void 0 || r(n.track_id)) && n.laps === (t(n.speed_class)?.laps ?? a.laps) && rt(n.track_hash) && (n.rematch_of === void 0 || $e(n.rematch_of)) && n.track_hash === i(n.map_id, n.seed, {
|
|
628
|
+
speedClass: n.speed_class,
|
|
629
|
+
trackId: n.track_id
|
|
630
|
+
}).trackHash;
|
|
631
|
+
case "game_accept": return nt(n, ["invite_event_id", "track_hash"]) && $e(n.invite_event_id) && rt(n.track_hash);
|
|
632
|
+
case "game_decline": return nt(n, ["invite_event_id"]) && $e(n.invite_event_id);
|
|
633
|
+
case "game_end": return nt(n, ["reason"]) && n.reason === "closed";
|
|
78
634
|
default: return !1;
|
|
79
635
|
}
|
|
80
636
|
}
|
|
81
|
-
function
|
|
82
|
-
let
|
|
83
|
-
if (!
|
|
637
|
+
function ot({ opponentId: r, seed: o = 0, rematchOf: s, speedClass: c = n, trackId: l } = {}) {
|
|
638
|
+
let u = t(c);
|
|
639
|
+
if (!et(r) || !it(o) || s !== void 0 && !$e(s) || c !== null && !u) throw TypeError("Configuración de invitación de carrera inválida");
|
|
640
|
+
let d = e(l, o);
|
|
84
641
|
return {
|
|
85
|
-
opponent_id:
|
|
642
|
+
opponent_id: r,
|
|
86
643
|
rules_version: 1,
|
|
87
644
|
mode: "classic",
|
|
88
645
|
map_id: "neon_city",
|
|
89
|
-
seed:
|
|
90
|
-
track_hash:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
646
|
+
seed: o,
|
|
647
|
+
track_hash: i("neon_city", o, {
|
|
648
|
+
speedClass: u?.id,
|
|
649
|
+
trackId: d
|
|
650
|
+
}).trackHash,
|
|
651
|
+
laps: u?.laps ?? a.laps,
|
|
652
|
+
...d === "oval" ? {} : { track_id: d },
|
|
653
|
+
...u ? { speed_class: u.id } : {},
|
|
654
|
+
...s === void 0 ? {} : { rematch_of: s }
|
|
94
655
|
};
|
|
95
656
|
}
|
|
96
|
-
function
|
|
97
|
-
if (!
|
|
657
|
+
function st(e, t) {
|
|
658
|
+
if (!at({
|
|
98
659
|
type: "game_invite",
|
|
99
660
|
data: t
|
|
100
661
|
})) throw TypeError("Configuración de carrera inválida");
|
|
@@ -111,7 +672,8 @@ function ie(e, t) {
|
|
|
111
672
|
trackHash: t.track_hash,
|
|
112
673
|
laps: t.laps,
|
|
113
674
|
rulesVersion: t.rules_version,
|
|
114
|
-
speedClass: t.speed_class ?? null
|
|
675
|
+
speedClass: t.speed_class ?? null,
|
|
676
|
+
...t.track_id === void 0 ? {} : { trackId: t.track_id }
|
|
115
677
|
},
|
|
116
678
|
rematchOf: t.rematch_of ?? null,
|
|
117
679
|
pending: !1,
|
|
@@ -120,8 +682,8 @@ function ie(e, t) {
|
|
|
120
682
|
acceptEventId: null
|
|
121
683
|
};
|
|
122
684
|
}
|
|
123
|
-
function
|
|
124
|
-
return !e || t?.game !== "racing_live" || t.game_id !== e.gameId || ![e.hostId, e.guestId].includes(n) || !
|
|
685
|
+
function ct(e, t, n) {
|
|
686
|
+
return !e || t?.game !== "racing_live" || t.game_id !== e.gameId || ![e.hostId, e.guestId].includes(n) || !at(t) ? e : t.type === "game_end" ? ["closed", "declined"].includes(e.status) ? e : {
|
|
125
687
|
...e,
|
|
126
688
|
status: "closed",
|
|
127
689
|
closedBy: n,
|
|
@@ -139,29 +701,29 @@ function ae(e, t, n) {
|
|
|
139
701
|
} : e;
|
|
140
702
|
}
|
|
141
703
|
// src/net/webrtc/rtcSignals.js
|
|
142
|
-
var
|
|
704
|
+
var lt = /* @__PURE__ */ new Set(), ut = {
|
|
143
705
|
emit(e) {
|
|
144
|
-
|
|
706
|
+
lt.forEach((t) => {
|
|
145
707
|
try {
|
|
146
708
|
t(e);
|
|
147
709
|
} catch {}
|
|
148
710
|
});
|
|
149
711
|
},
|
|
150
712
|
subscribe(e) {
|
|
151
|
-
return
|
|
713
|
+
return lt.add(e), () => lt.delete(e);
|
|
152
714
|
}
|
|
153
|
-
},
|
|
715
|
+
}, dt = ({ send: e, roomId: t }) => ({
|
|
154
716
|
send: (n) => e(t, n),
|
|
155
|
-
subscribe: (e) =>
|
|
717
|
+
subscribe: (e) => ut.subscribe((n) => {
|
|
156
718
|
String(n.roomId) === String(t) && e(n);
|
|
157
719
|
})
|
|
158
|
-
}),
|
|
720
|
+
}), ft = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, pt = /^[0-9a-f]{16}$/, mt = /^[0-9a-f]{32}$/, ht = /^[0-9a-f]{64}$/, gt = (e) => typeof e == "object" && !!e && !Array.isArray(e), _t = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, A = (e) => typeof e == "string" && ft.test(e), j = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, vt = Object.freeze([
|
|
159
721
|
"standard",
|
|
160
722
|
"heavy",
|
|
161
723
|
"cluster"
|
|
162
|
-
]),
|
|
163
|
-
function
|
|
164
|
-
return Array.isArray(e) ? e[0] === 1 ? e.length === 6 &&
|
|
724
|
+
]), yt = (e) => j(e, 1, 120), bt = (e) => j(e.move, -16, 16) && j(e.yaw, 0, 359) && j(e.pitch, 5, 80) && j(e.power, 0, 100) && j(e.ammo, 0, vt.length - 1);
|
|
725
|
+
function xt(e) {
|
|
726
|
+
return Array.isArray(e) ? e[0] === 1 ? e.length === 6 && bt({
|
|
165
727
|
move: e[1],
|
|
166
728
|
yaw: e[2],
|
|
167
729
|
pitch: e[3],
|
|
@@ -169,93 +731,93 @@ function ve(e) {
|
|
|
169
731
|
ammo: e[5]
|
|
170
732
|
}) : e[0] === 2 ? e.length === 1 : e[0] === 3 && e.length === 2 && (e[1] === 0 || e[1] === 1) : !1;
|
|
171
733
|
}
|
|
172
|
-
var
|
|
173
|
-
function
|
|
734
|
+
var St = (e) => Array.isArray(e.log) && e.log.length <= 120 && e.log.every(xt) && A(e.head) && (e.accept_event_id === void 0 ? e.log.length === 0 && e.seed_b === void 0 && e.seed_a === void 0 : A(e.accept_event_id) && typeof e.seed_b == "string" && mt.test(e.seed_b)) && (e.seed_a === void 0 ? e.log.length === 0 : mt.test(e.seed_a) && A(e.seed_event_id));
|
|
735
|
+
function Ct(e) {
|
|
174
736
|
let t = e.data;
|
|
175
737
|
switch (e.type) {
|
|
176
|
-
case "game_invite": return
|
|
177
|
-
case "game_accept": return
|
|
178
|
-
case "game_decline": return
|
|
738
|
+
case "game_invite": return _t(t.opponent_id) && t.rules_version === 1 && typeof t.seed_commit == "string" && ht.test(t.seed_commit) && (t.first_player_id === void 0 || _t(t.first_player_id)) && (t.rematch_of === void 0 || A(t.rematch_of));
|
|
739
|
+
case "game_accept": return A(t.invite_event_id) && typeof t.seed_b == "string" && mt.test(t.seed_b);
|
|
740
|
+
case "game_decline": return A(t.invite_event_id);
|
|
179
741
|
case "game_end": return t.reason === "closed";
|
|
180
|
-
case "tk_seed": return typeof t.seed_a == "string" &&
|
|
181
|
-
case "tk_turn": return
|
|
742
|
+
case "tk_seed": return typeof t.seed_a == "string" && mt.test(t.seed_a);
|
|
743
|
+
case "tk_turn": return yt(t.ply) && A(t.prev_event_id) && bt(t) && typeof t.hash == "string" && pt.test(t.hash);
|
|
182
744
|
case "tk_skip":
|
|
183
|
-
case "tk_resign": return
|
|
184
|
-
case "tk_sync_request": return
|
|
185
|
-
case "tk_sync_state": return
|
|
745
|
+
case "tk_resign": return yt(t.ply) && A(t.prev_event_id);
|
|
746
|
+
case "tk_sync_request": return gt(t) && St(t);
|
|
747
|
+
case "tk_sync_state": return gt(t) && St(t) && A(t.request_event_id);
|
|
186
748
|
default: return !1;
|
|
187
749
|
}
|
|
188
750
|
}
|
|
189
751
|
// src/games/shared/protocol.js
|
|
190
|
-
var
|
|
752
|
+
var wt = "LIRA_GAME_V1:", Tt = 4096, Et = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, Dt = (e) => typeof e == "object" && !!e && !Array.isArray(e), M = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, N = (e) => typeof e == "string" && Et.test(e), Ot = (e) => Array.isArray(e) && e.length <= 42 && e.every((e) => Array.isArray(e) && e.length === 2 && Number.isInteger(e[0]) && e[0] >= 0 && e[0] < 7 && N(e[1])) && new Set(e.map((e) => e[1])).size === e.length, kt = (e) => Ot(e.moves) && e.rev === e.moves.length && (e.accept_event_id === void 0 ? e.moves.length === 0 : N(e.accept_event_id)), At = [
|
|
191
753
|
"carrier",
|
|
192
754
|
"battleship",
|
|
193
755
|
"cruiser",
|
|
194
756
|
"submarine",
|
|
195
757
|
"destroyer"
|
|
196
|
-
],
|
|
197
|
-
function
|
|
758
|
+
], P = (e) => Number.isInteger(e) && e >= 0 && e < 10, jt = (e) => typeof e == "string" && /^[0-9a-f]{64}$/.test(e), Mt = (e) => Number.isInteger(e) && e >= 1 && e <= 200, Nt = (e) => e === null || Dt(e) && At.includes(e.ship_id) && Array.isArray(e.cells) && e.cells.length >= 2 && e.cells.length <= 5 && e.cells.every((e) => Array.isArray(e) && e.length === 2 && P(e[0]) && P(e[1])), Pt = (e) => Array.isArray(e) && e.length === At.length && e.every((e) => Dt(e) && At.includes(e.ship_id) && P(e.row) && P(e.col) && (e.orientation === "horizontal" || e.orientation === "vertical")) && new Set(e.map((e) => e.ship_id)).size === e.length, Ft = (e, t) => Array.isArray(e) && P(e[0]) && P(e[1]) && (e.length === 2 && t || e.length === 3 && (e[2] === 0 || e[2] === 1) || e.length === 7 && e[2] === 2 && Number.isInteger(e[3]) && e[3] >= 0 && e[3] < At.length && P(e[4]) && P(e[5]) && (e[6] === 0 || e[6] === 1)), It = (e) => Array.isArray(e.commits) && e.commits.length === 2 && e.commits.every((e) => e === null || jt(e)) && Array.isArray(e.log) && e.log.length <= 200 && e.log.every((t, n) => Ft(t, n === e.log.length - 1)) && N(e.head) && (e.accept_event_id === void 0 ? e.commits.every((e) => e === null) && e.log.length === 0 : N(e.accept_event_id)) && (e.log.length === 0 || e.commits.every(Boolean));
|
|
759
|
+
function Lt(e) {
|
|
198
760
|
let t = e.data;
|
|
199
761
|
switch (e.type) {
|
|
200
|
-
case "game_invite": return
|
|
762
|
+
case "game_invite": return M(t.opponent_id) && t.rules_version === 1;
|
|
201
763
|
case "game_accept":
|
|
202
|
-
case "game_decline": return
|
|
203
|
-
case "game_end": return ["closed", "win"].includes(t.reason) && (t.winner_id === void 0 ||
|
|
204
|
-
case "bs_commit": return
|
|
205
|
-
case "bs_fire": return
|
|
206
|
-
case "bs_result": return
|
|
207
|
-
case "bs_reveal": return
|
|
208
|
-
case "bs_sync_request": return
|
|
209
|
-
case "bs_sync_state": return
|
|
764
|
+
case "game_decline": return N(t.invite_event_id);
|
|
765
|
+
case "game_end": return ["closed", "win"].includes(t.reason) && (t.winner_id === void 0 || M(t.winner_id));
|
|
766
|
+
case "bs_commit": return jt(t.commitment);
|
|
767
|
+
case "bs_fire": return Mt(t.ply) && P(t.row) && P(t.col) && N(t.prev_event_id);
|
|
768
|
+
case "bs_result": return Mt(t.ply) && P(t.row) && P(t.col) && ["hit", "miss"].includes(t.result) && Nt(t.sunk) && typeof t.defeated == "boolean" && (t.result === "hit" || t.sunk === null && !t.defeated);
|
|
769
|
+
case "bs_reveal": return Pt(t.fleet) && typeof t.salt == "string" && /^[0-9a-f]{32}$/.test(t.salt);
|
|
770
|
+
case "bs_sync_request": return It(t);
|
|
771
|
+
case "bs_sync_state": return It(t) && N(t.request_event_id);
|
|
210
772
|
default: return !1;
|
|
211
773
|
}
|
|
212
774
|
}
|
|
213
|
-
function
|
|
775
|
+
function Rt(e) {
|
|
214
776
|
return typeof e == "string" && e.startsWith("LIRA_GAME_V1:");
|
|
215
777
|
}
|
|
216
|
-
function
|
|
778
|
+
function zt(e) {
|
|
217
779
|
let t = e.data;
|
|
218
780
|
switch (e.type) {
|
|
219
|
-
case "game_invite": return
|
|
781
|
+
case "game_invite": return M(t.opponent_id) && t.rules_version === 1;
|
|
220
782
|
case "game_accept":
|
|
221
|
-
case "game_decline": return
|
|
222
|
-
case "game_move": return Number.isInteger(t.column) && t.column >= 0 && t.column < 7 && Number.isInteger(t.ply) && t.ply >= 1 && t.ply <= 42 &&
|
|
783
|
+
case "game_decline": return N(t.invite_event_id);
|
|
784
|
+
case "game_move": return Number.isInteger(t.column) && t.column >= 0 && t.column < 7 && Number.isInteger(t.ply) && t.ply >= 1 && t.ply <= 42 && N(t.prev_event_id);
|
|
223
785
|
case "game_end": return [
|
|
224
786
|
"closed",
|
|
225
787
|
"win",
|
|
226
788
|
"draw"
|
|
227
|
-
].includes(t.reason) && (t.winner_id === void 0 ||
|
|
228
|
-
case "game_resync_request": return
|
|
229
|
-
case "game_resync_state": return
|
|
789
|
+
].includes(t.reason) && (t.winner_id === void 0 || M(t.winner_id)) && (t.final_move_event_id === void 0 || N(t.final_move_event_id)) && (t.reason !== "win" || M(t.winner_id) && N(t.final_move_event_id)) && (t.reason !== "draw" || N(t.final_move_event_id));
|
|
790
|
+
case "game_resync_request": return kt(t);
|
|
791
|
+
case "game_resync_state": return kt(t) && N(t.request_event_id);
|
|
230
792
|
default: return !1;
|
|
231
793
|
}
|
|
232
794
|
}
|
|
233
|
-
var
|
|
234
|
-
connect4:
|
|
235
|
-
battleship:
|
|
236
|
-
tanks:
|
|
237
|
-
tanks_live:
|
|
238
|
-
racing_live:
|
|
239
|
-
},
|
|
240
|
-
function
|
|
241
|
-
return !
|
|
242
|
-
}
|
|
243
|
-
function
|
|
244
|
-
if (!
|
|
795
|
+
var Bt = {
|
|
796
|
+
connect4: zt,
|
|
797
|
+
battleship: Lt,
|
|
798
|
+
tanks: Ct,
|
|
799
|
+
tanks_live: Je,
|
|
800
|
+
racing_live: at
|
|
801
|
+
}, Vt = Object.freeze(Object.keys(Bt));
|
|
802
|
+
function Ht(e) {
|
|
803
|
+
return !Dt(e) || e.version !== 1 || !Object.hasOwn(Bt, e.game) || !N(e.game_id) || !N(e.event_id) || !Dt(e.data) ? !1 : Bt[e.game](e);
|
|
804
|
+
}
|
|
805
|
+
function Ut(e) {
|
|
806
|
+
if (!Rt(e) || e.length > Tt) return null;
|
|
245
807
|
try {
|
|
246
808
|
let t = JSON.parse(e.slice(13));
|
|
247
|
-
return
|
|
809
|
+
return Ht(t) ? t : null;
|
|
248
810
|
} catch {
|
|
249
811
|
return null;
|
|
250
812
|
}
|
|
251
813
|
}
|
|
252
|
-
function
|
|
253
|
-
if (!
|
|
254
|
-
let t =
|
|
255
|
-
if (t.length >
|
|
814
|
+
function Wt(e) {
|
|
815
|
+
if (!Ht(e)) throw Error("Evento de juego inválido");
|
|
816
|
+
let t = wt + JSON.stringify(e);
|
|
817
|
+
if (t.length > Tt) throw Error("Evento de juego demasiado grande");
|
|
256
818
|
return t;
|
|
257
819
|
}
|
|
258
|
-
function
|
|
820
|
+
function F(e, { game_id: t, data: n, event_id: r = h(), game: i = "connect4" }) {
|
|
259
821
|
let a = {
|
|
260
822
|
version: 1,
|
|
261
823
|
game: i,
|
|
@@ -264,22 +826,22 @@ function k(e, { game_id: t, data: n, event_id: r = p(), game: i = "connect4" })
|
|
|
264
826
|
type: e,
|
|
265
827
|
data: n
|
|
266
828
|
};
|
|
267
|
-
if (!
|
|
829
|
+
if (!Ht(a)) throw Error("Evento de juego inválido");
|
|
268
830
|
return a;
|
|
269
831
|
}
|
|
270
|
-
function
|
|
832
|
+
function Gt() {
|
|
271
833
|
return Array.from({ length: 6 }, () => Array(7).fill(null));
|
|
272
834
|
}
|
|
273
|
-
var
|
|
835
|
+
var Kt = [
|
|
274
836
|
[0, 1],
|
|
275
837
|
[1, 0],
|
|
276
838
|
[1, 1],
|
|
277
839
|
[1, -1]
|
|
278
840
|
];
|
|
279
|
-
function
|
|
841
|
+
function qt(e) {
|
|
280
842
|
for (let t = 0; t < 6; t += 1) for (let n = 0; n < 7; n += 1) {
|
|
281
843
|
let r = e[t][n];
|
|
282
|
-
if (r != null) for (let [i, a] of
|
|
844
|
+
if (r != null) for (let [i, a] of Kt) {
|
|
283
845
|
let o = [];
|
|
284
846
|
for (let s = 0; s < 4; s += 1) {
|
|
285
847
|
let c = t + i * s, l = n + a * s;
|
|
@@ -291,40 +853,40 @@ function Ue(e) {
|
|
|
291
853
|
}
|
|
292
854
|
return [];
|
|
293
855
|
}
|
|
294
|
-
function
|
|
295
|
-
let t =
|
|
856
|
+
function Jt(e) {
|
|
857
|
+
let t = qt(e);
|
|
296
858
|
return t.length ? e[t[0][0]][t[0][1]] : null;
|
|
297
859
|
}
|
|
298
|
-
function
|
|
860
|
+
function Yt(e) {
|
|
299
861
|
return e[0].every((e) => e !== null);
|
|
300
862
|
}
|
|
301
|
-
function
|
|
302
|
-
if (!Number.isInteger(t) || t < 0 || t >= 7 || n == null ||
|
|
863
|
+
function Xt(e, t, n) {
|
|
864
|
+
if (!Number.isInteger(t) || t < 0 || t >= 7 || n == null || Jt(e) !== null) return null;
|
|
303
865
|
let r = 5;
|
|
304
866
|
for (; r >= 0 && e[r][t] !== null;) --r;
|
|
305
867
|
if (r < 0) return null;
|
|
306
868
|
let i = e.map((e) => e.slice());
|
|
307
869
|
i[r][t] = n;
|
|
308
|
-
let a =
|
|
870
|
+
let a = qt(i), o = a.length ? i[a[0][0]][a[0][1]] : null;
|
|
309
871
|
return {
|
|
310
872
|
board: i,
|
|
311
873
|
row: r,
|
|
312
874
|
column: t,
|
|
313
875
|
winner: o,
|
|
314
|
-
draw: o === null &&
|
|
876
|
+
draw: o === null && Yt(i),
|
|
315
877
|
winningCells: a
|
|
316
878
|
};
|
|
317
879
|
}
|
|
318
880
|
// src/games/battleship/logic/game.js
|
|
319
|
-
var
|
|
320
|
-
function
|
|
321
|
-
if (!
|
|
881
|
+
var Zt = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e;
|
|
882
|
+
function Qt({ gameId: e, players: t, firstPlayerId: n = t?.[0] } = {}) {
|
|
883
|
+
if (!Zt(e) || !Array.isArray(t) || t.length !== 2 || !t.every(Zt) || t[0] === t[1] || !t.includes(n)) throw TypeError("Supply a gameId, two distinct player IDs and a valid firstPlayerId.");
|
|
322
884
|
return {
|
|
323
885
|
game: "battleship",
|
|
324
886
|
rulesVersion: 1,
|
|
325
887
|
gameId: e,
|
|
326
888
|
players: t.slice(),
|
|
327
|
-
boards: [
|
|
889
|
+
boards: [l(), l()],
|
|
328
890
|
ready: [!1, !1],
|
|
329
891
|
phase: "placement",
|
|
330
892
|
turnId: null,
|
|
@@ -335,7 +897,7 @@ function Je({ gameId: e, players: t, firstPlayerId: n = t?.[0] } = {}) {
|
|
|
335
897
|
revision: 0
|
|
336
898
|
};
|
|
337
899
|
}
|
|
338
|
-
function
|
|
900
|
+
function $t(e, t) {
|
|
339
901
|
if (!e || !t || typeof t != "object" || e.phase === "finished" || t.gameId !== void 0 && t.gameId !== e.gameId || t.expectedRevision !== void 0 && t.expectedRevision !== e.revision) return e;
|
|
340
902
|
let n = e.players.indexOf(t.playerId);
|
|
341
903
|
if (n < 0) return e;
|
|
@@ -343,16 +905,16 @@ function Ye(e, t) {
|
|
|
343
905
|
if (e.phase === "placement") {
|
|
344
906
|
if (e.ready[n]) return e;
|
|
345
907
|
if (t.type === "place_ship" || t.type === "remove_ship") {
|
|
346
|
-
let i = t.type === "place_ship" ?
|
|
908
|
+
let i = t.type === "place_ship" ? d(r, t) : s(r, t.shipId);
|
|
347
909
|
if (!i.ok) return e;
|
|
348
|
-
let
|
|
349
|
-
return
|
|
910
|
+
let a = e.boards.slice();
|
|
911
|
+
return a[n] = i.board, {
|
|
350
912
|
...e,
|
|
351
|
-
boards:
|
|
913
|
+
boards: a,
|
|
352
914
|
revision: e.revision + 1
|
|
353
915
|
};
|
|
354
916
|
}
|
|
355
|
-
if (t.type === "ready" &&
|
|
917
|
+
if (t.type === "ready" && o(r)) {
|
|
356
918
|
let t = e.ready.slice();
|
|
357
919
|
t[n] = !0;
|
|
358
920
|
let r = t.every(Boolean);
|
|
@@ -367,40 +929,40 @@ function Ye(e, t) {
|
|
|
367
929
|
return e;
|
|
368
930
|
}
|
|
369
931
|
if (e.phase !== "playing" || t.type !== "fire" || t.playerId !== e.turnId) return e;
|
|
370
|
-
let
|
|
371
|
-
if (!
|
|
372
|
-
let
|
|
373
|
-
return
|
|
932
|
+
let i = 1 - n, a = u(e.boards[i], t);
|
|
933
|
+
if (!a.ok) return e;
|
|
934
|
+
let c = e.boards.slice();
|
|
935
|
+
return c[i] = a.board, {
|
|
374
936
|
...e,
|
|
375
|
-
boards:
|
|
937
|
+
boards: c,
|
|
376
938
|
revision: e.revision + 1,
|
|
377
939
|
shotCount: e.shotCount + 1,
|
|
378
|
-
phase:
|
|
379
|
-
turnId:
|
|
380
|
-
winnerId:
|
|
940
|
+
phase: a.defeated ? "finished" : "playing",
|
|
941
|
+
turnId: a.defeated ? null : e.players[i],
|
|
942
|
+
winnerId: a.defeated ? t.playerId : null,
|
|
381
943
|
lastShot: {
|
|
382
944
|
playerId: t.playerId,
|
|
383
|
-
targetId: e.players[
|
|
945
|
+
targetId: e.players[i],
|
|
384
946
|
row: t.row,
|
|
385
947
|
col: t.col,
|
|
386
|
-
result:
|
|
387
|
-
shipId:
|
|
388
|
-
sunk:
|
|
389
|
-
defeated:
|
|
948
|
+
result: a.result,
|
|
949
|
+
shipId: a.shipId,
|
|
950
|
+
sunk: a.sunk,
|
|
951
|
+
defeated: a.defeated
|
|
390
952
|
}
|
|
391
953
|
};
|
|
392
954
|
}
|
|
393
955
|
// src/games/battleship/net/session.js
|
|
394
|
-
var
|
|
956
|
+
var en = f.reduce((e, t) => e + t.size, 0), tn = /^[0-9a-f]{32}$/, nn = [
|
|
395
957
|
"won",
|
|
396
958
|
"closed",
|
|
397
959
|
"declined"
|
|
398
|
-
],
|
|
960
|
+
], I = "La partida perdió sincronización. Se intentará resincronizar.", rn = "Falta la aceptación de la partida. Ciérrala y vuelve a invitar.", an = "El rival envió un resultado imposible para ese disparo.", on = "Tu flota no está disponible en este dispositivo; no se pueden responder disparos.", sn = () => Array.from({ length: 10 }, () => Array(10).fill(null)), cn = (e, t, n, r) => e.map((e, i) => i === t ? e.map((e, t) => t === n ? r : e) : e), ln = (e) => e.reduce((e, t) => e + t.filter((e) => e === "hit").length, 0), un = (e) => e.reduce((e, t) => e + t.filter((e) => e !== null).length, 0), dn = (e, t) => t % 2 == 1 ? e.hostId : e.guestId, fn = (e, t) => t === e.hostId ? e.guestId : e.hostId, pn = (e, t) => t === e.hostId ? "hostCommitment" : "guestCommitment", L = (e, t) => ({
|
|
399
961
|
...e,
|
|
400
962
|
status: "conflict",
|
|
401
963
|
error: t
|
|
402
|
-
}),
|
|
403
|
-
function
|
|
964
|
+
}), mn = (e) => `${e.row},${e.col}`, hn = (e, t) => e.row - t.row || e.col - t.col, gn = (e, t) => e.length === t.length && e.map(mn).sort().join("|") === t.map(mn).sort().join("|");
|
|
965
|
+
function _n(e) {
|
|
404
966
|
return {
|
|
405
967
|
...e,
|
|
406
968
|
game: "battleship",
|
|
@@ -409,8 +971,8 @@ function ft(e) {
|
|
|
409
971
|
myFleet: [],
|
|
410
972
|
myReady: !1,
|
|
411
973
|
opponentReady: !1,
|
|
412
|
-
incomingShots:
|
|
413
|
-
targetShots:
|
|
974
|
+
incomingShots: sn(),
|
|
975
|
+
targetShots: sn(),
|
|
414
976
|
sunkEnemyShips: [],
|
|
415
977
|
pendingShot: null,
|
|
416
978
|
lastShot: null,
|
|
@@ -432,7 +994,7 @@ function ft(e) {
|
|
|
432
994
|
sync: e.sync ?? null
|
|
433
995
|
};
|
|
434
996
|
}
|
|
435
|
-
var
|
|
997
|
+
var vn = (e) => e?.game === "battleship" && ["invited", "placement"].includes(e.status) && !e.myReady, yn = (e) => e?.status === "active" && e.turnId === e.ownId && !e.pendingShot, bn = (e) => ({
|
|
436
998
|
id: e.id,
|
|
437
999
|
size: e.size,
|
|
438
1000
|
orientation: e.orientation,
|
|
@@ -440,33 +1002,33 @@ var pt = (e) => e?.game === "battleship" && ["invited", "placement"].includes(e.
|
|
|
440
1002
|
row: e.row,
|
|
441
1003
|
col: e.col
|
|
442
1004
|
}))
|
|
443
|
-
}),
|
|
1005
|
+
}), xn = (e) => ({
|
|
444
1006
|
shipId: e.id,
|
|
445
1007
|
row: e.cells[0].row,
|
|
446
1008
|
col: e.cells[0].col,
|
|
447
1009
|
orientation: e.orientation
|
|
448
1010
|
});
|
|
449
|
-
function
|
|
1011
|
+
function Sn(e) {
|
|
450
1012
|
return !e || typeof e != "object" ? null : typeof e.ship_id == "string" ? {
|
|
451
1013
|
shipId: e.ship_id,
|
|
452
1014
|
row: e.row,
|
|
453
1015
|
col: e.col,
|
|
454
1016
|
orientation: e.orientation
|
|
455
|
-
} : typeof e.id == "string" && Array.isArray(e.cells) && e.cells.length ?
|
|
1017
|
+
} : typeof e.id == "string" && Array.isArray(e.cells) && e.cells.length ? xn(e) : null;
|
|
456
1018
|
}
|
|
457
|
-
function
|
|
1019
|
+
function Cn(e) {
|
|
458
1020
|
if (!Array.isArray(e)) return null;
|
|
459
|
-
let t =
|
|
1021
|
+
let t = l();
|
|
460
1022
|
for (let n of e) {
|
|
461
|
-
let e =
|
|
1023
|
+
let e = Sn(n), r = e && d(t, e);
|
|
462
1024
|
if (!r?.ok) return null;
|
|
463
1025
|
t = r.board;
|
|
464
1026
|
}
|
|
465
1027
|
return t;
|
|
466
1028
|
}
|
|
467
|
-
function
|
|
1029
|
+
function wn(e) {
|
|
468
1030
|
if (!Array.isArray(e)) return null;
|
|
469
|
-
let t = e.map(
|
|
1031
|
+
let t = e.map(Sn);
|
|
470
1032
|
return t.some((e) => !e) ? null : t.map(({ shipId: e, row: t, col: n, orientation: r }) => ({
|
|
471
1033
|
ship_id: e,
|
|
472
1034
|
row: t,
|
|
@@ -474,21 +1036,21 @@ function M(e) {
|
|
|
474
1036
|
orientation: r
|
|
475
1037
|
})).sort((e, t) => e.ship_id < t.ship_id ? -1 : +(e.ship_id > t.ship_id));
|
|
476
1038
|
}
|
|
477
|
-
function
|
|
478
|
-
let t =
|
|
479
|
-
return t &&
|
|
1039
|
+
function Tn(e) {
|
|
1040
|
+
let t = Cn(e);
|
|
1041
|
+
return t && o(t) ? t.ships.map(bn) : null;
|
|
480
1042
|
}
|
|
481
|
-
var
|
|
482
|
-
function
|
|
483
|
-
let t =
|
|
484
|
-
return t &&
|
|
1043
|
+
var En = (e) => !!Tn(e);
|
|
1044
|
+
function Dn(e) {
|
|
1045
|
+
let t = Cn(e?.myFleet);
|
|
1046
|
+
return t && o(t) ? {
|
|
485
1047
|
...t,
|
|
486
1048
|
shots: e.incomingShots.map((e) => e.slice())
|
|
487
1049
|
} : null;
|
|
488
1050
|
}
|
|
489
|
-
function
|
|
490
|
-
if (!
|
|
491
|
-
let a =
|
|
1051
|
+
function On(e, { shipId: t, row: n, col: r, orientation: i } = {}) {
|
|
1052
|
+
if (!vn(e)) return e;
|
|
1053
|
+
let a = Cn(e.myFleet.filter((e) => e.id !== t)), o = a && d(a, {
|
|
492
1054
|
shipId: t,
|
|
493
1055
|
row: n,
|
|
494
1056
|
col: r,
|
|
@@ -496,27 +1058,27 @@ function St(e, { shipId: t, row: n, col: r, orientation: i } = {}) {
|
|
|
496
1058
|
});
|
|
497
1059
|
return o?.ok ? {
|
|
498
1060
|
...e,
|
|
499
|
-
myFleet: o.board.ships.map(
|
|
1061
|
+
myFleet: o.board.ships.map(bn)
|
|
500
1062
|
} : e;
|
|
501
1063
|
}
|
|
502
|
-
function
|
|
503
|
-
return !
|
|
1064
|
+
function kn(e, t) {
|
|
1065
|
+
return !vn(e) || !e.myFleet.some((e) => e.id === t) ? e : {
|
|
504
1066
|
...e,
|
|
505
1067
|
myFleet: e.myFleet.filter((e) => e.id !== t)
|
|
506
1068
|
};
|
|
507
1069
|
}
|
|
508
|
-
function
|
|
1070
|
+
function An(e) {
|
|
509
1071
|
let t = Math.floor(4294967296 / e) * e, n = /* @__PURE__ */ new Uint32Array(1);
|
|
510
1072
|
do
|
|
511
1073
|
globalThis.crypto.getRandomValues(n);
|
|
512
1074
|
while (n[0] >= t);
|
|
513
1075
|
return n[0] % e;
|
|
514
1076
|
}
|
|
515
|
-
function
|
|
1077
|
+
function jn(e = An) {
|
|
516
1078
|
for (let t = 0; t < 50; t += 1) {
|
|
517
|
-
let t =
|
|
518
|
-
for (let n of
|
|
519
|
-
let r =
|
|
1079
|
+
let t = l();
|
|
1080
|
+
for (let n of f) for (let r = 0; r < 300; r += 1) {
|
|
1081
|
+
let r = d(t, {
|
|
520
1082
|
shipId: n.id,
|
|
521
1083
|
row: e(10),
|
|
522
1084
|
col: e(10),
|
|
@@ -527,33 +1089,33 @@ function Tt(e = wt) {
|
|
|
527
1089
|
break;
|
|
528
1090
|
}
|
|
529
1091
|
}
|
|
530
|
-
if (
|
|
1092
|
+
if (o(t)) return t.ships.map(bn);
|
|
531
1093
|
}
|
|
532
1094
|
throw Error("No se pudo generar una flota aleatoria.");
|
|
533
1095
|
}
|
|
534
|
-
var
|
|
1096
|
+
var Mn = (e, t) => vn(e) ? {
|
|
535
1097
|
...e,
|
|
536
|
-
myFleet:
|
|
537
|
-
} : e,
|
|
538
|
-
function
|
|
1098
|
+
myFleet: jn(t)
|
|
1099
|
+
} : e, Nn = (e) => Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1100
|
+
function Pn() {
|
|
539
1101
|
let e = /* @__PURE__ */ new Uint8Array(16);
|
|
540
|
-
return globalThis.crypto.getRandomValues(e),
|
|
1102
|
+
return globalThis.crypto.getRandomValues(e), Nn(e);
|
|
541
1103
|
}
|
|
542
|
-
function
|
|
543
|
-
let n =
|
|
1104
|
+
function Fn(e, t) {
|
|
1105
|
+
let n = wn(e);
|
|
544
1106
|
if (!n || typeof t != "string") throw TypeError("Flota inválida");
|
|
545
1107
|
return JSON.stringify({
|
|
546
1108
|
fleet: n,
|
|
547
1109
|
salt: t
|
|
548
1110
|
});
|
|
549
1111
|
}
|
|
550
|
-
async function
|
|
551
|
-
let n = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(
|
|
552
|
-
return
|
|
1112
|
+
async function In(e, t) {
|
|
1113
|
+
let n = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(Fn(e, t)));
|
|
1114
|
+
return Nn(new Uint8Array(n));
|
|
553
1115
|
}
|
|
554
|
-
function
|
|
1116
|
+
function Ln(e, t) {
|
|
555
1117
|
if (!e || !t) return null;
|
|
556
|
-
let n =
|
|
1118
|
+
let n = u(e, {
|
|
557
1119
|
row: t.row,
|
|
558
1120
|
col: t.col
|
|
559
1121
|
});
|
|
@@ -571,15 +1133,15 @@ function jt(e, t) {
|
|
|
571
1133
|
defeated: n.defeated
|
|
572
1134
|
};
|
|
573
1135
|
}
|
|
574
|
-
function
|
|
575
|
-
let t =
|
|
1136
|
+
function Rn(e) {
|
|
1137
|
+
let t = f.find((t) => t.id === e?.ship_id);
|
|
576
1138
|
if (!t || !Array.isArray(e.cells) || e.cells.length !== t.size) return null;
|
|
577
1139
|
let n = e.cells.map((e) => Array.isArray(e) ? {
|
|
578
1140
|
row: e[0],
|
|
579
1141
|
col: e[1]
|
|
580
1142
|
} : null);
|
|
581
|
-
if (n.some((e) => !
|
|
582
|
-
n.sort(
|
|
1143
|
+
if (n.some((e) => !c(e))) return null;
|
|
1144
|
+
n.sort(hn);
|
|
583
1145
|
let r = n.every((e, t) => e.row === n[0].row && e.col === n[0].col + t), i = n.every((e, t) => e.col === n[0].col && e.row === n[0].row + t);
|
|
584
1146
|
return !r && !i ? null : {
|
|
585
1147
|
id: t.id,
|
|
@@ -589,43 +1151,43 @@ function Mt(e) {
|
|
|
589
1151
|
sunk: !0
|
|
590
1152
|
};
|
|
591
1153
|
}
|
|
592
|
-
function
|
|
1154
|
+
function zn(e, t) {
|
|
593
1155
|
let { row: n, col: r, result: i, sunk: a } = t, o = !!t.defeated;
|
|
594
1156
|
if (i !== "hit" && i !== "miss" || e.targetShots[n][r] !== null) return null;
|
|
595
|
-
let s =
|
|
1157
|
+
let s = cn(e.targetShots, n, r, i), c = ln(s), l = null;
|
|
596
1158
|
if (a) {
|
|
597
|
-
if (l = i === "hit" ?
|
|
598
|
-
let t = new Set(e.sunkEnemyShips.flatMap((e) => e.cells.map(
|
|
599
|
-
if (!l.cells.some((e) => e.row === n && e.col === r) || l.cells.some((e) => s[e.row][e.col] !== "hit" || t.has(
|
|
1159
|
+
if (l = i === "hit" ? Rn(a) : null, !l || e.sunkEnemyShips.some((e) => e.id === l.id)) return null;
|
|
1160
|
+
let t = new Set(e.sunkEnemyShips.flatMap((e) => e.cells.map(mn)));
|
|
1161
|
+
if (!l.cells.some((e) => e.row === n && e.col === r) || l.cells.some((e) => s[e.row][e.col] !== "hit" || t.has(mn(e)))) return null;
|
|
600
1162
|
}
|
|
601
|
-
let
|
|
602
|
-
return c >
|
|
1163
|
+
let u = e.sunkEnemyShips.length + +!!l;
|
|
1164
|
+
return c > en || o !== (c === en) || o !== (u === f.length) || !o && en - c > 100 - un(s) ? null : {
|
|
603
1165
|
shots: s,
|
|
604
1166
|
ship: l
|
|
605
1167
|
};
|
|
606
1168
|
}
|
|
607
|
-
function
|
|
608
|
-
let n =
|
|
1169
|
+
function Bn(e, t) {
|
|
1170
|
+
let n = Ln(Dn(e), t);
|
|
609
1171
|
if (!n || n.result !== t.result || n.defeated !== !!t.defeated || !!n.sunk != !!t.sunk) return null;
|
|
610
|
-
let r = n.sunk ?
|
|
611
|
-
return r && (t.sunk.ship_id !== r.id || !
|
|
1172
|
+
let r = n.sunk ? Rn(n.sunk) : null;
|
|
1173
|
+
return r && (t.sunk.ship_id !== r.id || !gn(r.cells, t.sunk.cells.map(([e, t]) => ({
|
|
612
1174
|
row: e,
|
|
613
1175
|
col: t
|
|
614
1176
|
})))) ? null : {
|
|
615
|
-
shots:
|
|
1177
|
+
shots: cn(e.incomingShots, t.row, t.col, t.result),
|
|
616
1178
|
ship: r
|
|
617
1179
|
};
|
|
618
1180
|
}
|
|
619
|
-
function
|
|
620
|
-
let i =
|
|
1181
|
+
function Vn(e, t, n, r) {
|
|
1182
|
+
let i = pn(e, t);
|
|
621
1183
|
if (e[i]) return e[i] === n ? e : null;
|
|
622
1184
|
let a = {
|
|
623
1185
|
...e,
|
|
624
1186
|
[i]: n
|
|
625
1187
|
};
|
|
626
1188
|
if (t === e.ownId) {
|
|
627
|
-
let t = r?.commitment === n ?
|
|
628
|
-
t &&
|
|
1189
|
+
let t = r?.commitment === n ? Tn(r.fleet) : null;
|
|
1190
|
+
t && tn.test(r.salt ?? "") ? a = {
|
|
629
1191
|
...a,
|
|
630
1192
|
myFleet: t,
|
|
631
1193
|
mySalt: r.salt,
|
|
@@ -635,7 +1197,7 @@ function Ft(e, t, n, r) {
|
|
|
635
1197
|
myFleet: [],
|
|
636
1198
|
mySalt: null,
|
|
637
1199
|
myCommitment: n,
|
|
638
|
-
error:
|
|
1200
|
+
error: on
|
|
639
1201
|
}), a.myReady = !0;
|
|
640
1202
|
} else a.opponentReady = !0;
|
|
641
1203
|
return a.hostCommitment && a.guestCommitment && (a = {
|
|
@@ -646,12 +1208,12 @@ function Ft(e, t, n, r) {
|
|
|
646
1208
|
pendingShot: null
|
|
647
1209
|
}), a;
|
|
648
1210
|
}
|
|
649
|
-
function
|
|
650
|
-
let
|
|
651
|
-
return !
|
|
1211
|
+
function Hn(e, t, { row: n, col: r, ply: i }, a) {
|
|
1212
|
+
let o = t === e.ownId ? e.targetShots : e.incomingShots;
|
|
1213
|
+
return !c({
|
|
652
1214
|
row: n,
|
|
653
1215
|
col: r
|
|
654
|
-
}) ||
|
|
1216
|
+
}) || o[n][r] !== null ? null : {
|
|
655
1217
|
...e,
|
|
656
1218
|
pendingShot: {
|
|
657
1219
|
row: n,
|
|
@@ -662,8 +1224,8 @@ function It(e, t, { row: n, col: r, ply: i }, a) {
|
|
|
662
1224
|
lastEventId: a ?? e.lastEventId
|
|
663
1225
|
};
|
|
664
1226
|
}
|
|
665
|
-
function
|
|
666
|
-
let i = e.pendingShot, a = t === e.ownId, o = a ?
|
|
1227
|
+
function Un(e, t, n, r) {
|
|
1228
|
+
let i = e.pendingShot, a = t === e.ownId, o = a ? Bn(e, n) : zn(e, n);
|
|
667
1229
|
if (!o) return null;
|
|
668
1230
|
let s = !!n.defeated, c = {
|
|
669
1231
|
ply: i.ply,
|
|
@@ -693,21 +1255,21 @@ function Lt(e, t, n, r) {
|
|
|
693
1255
|
verification: s ? "pending" : e.verification
|
|
694
1256
|
};
|
|
695
1257
|
}
|
|
696
|
-
function
|
|
1258
|
+
function Wn(e, t, n) {
|
|
697
1259
|
let { ply: r, row: i, col: a, prev_event_id: o } = t.data;
|
|
698
|
-
return n ===
|
|
1260
|
+
return n === dn(e, r) ? e.status === "active" ? r <= e.ply ? e : e.pendingShot ? r === e.pendingShot.ply ? e : L(e, I) : r > e.ply + 1 ? L(e, I) : n === e.turnId ? o === e.lastEventId ? Hn(e, n, {
|
|
699
1261
|
row: i,
|
|
700
1262
|
col: a,
|
|
701
1263
|
ply: r
|
|
702
|
-
}, t.event_id) ?? e :
|
|
1264
|
+
}, t.event_id) ?? e : L(e, I) : e : L(e, e.status === "invited" ? rn : I) : e;
|
|
703
1265
|
}
|
|
704
|
-
function
|
|
1266
|
+
function Gn(e, t, n) {
|
|
705
1267
|
let { ply: r, row: i, col: a } = t.data;
|
|
706
|
-
if (e.status !== "active") return e.status === "placement" ?
|
|
1268
|
+
if (e.status !== "active") return e.status === "placement" ? L(e, I) : e;
|
|
707
1269
|
let o = e.pendingShot;
|
|
708
|
-
return o ? r === o.ply ? n === o.by ? e : i !== o.row || a !== o.col ? n === e.ownId ? e :
|
|
1270
|
+
return o ? r === o.ply ? n === o.by ? e : i !== o.row || a !== o.col ? n === e.ownId ? e : L(e, "El rival respondió a un disparo distinto.") : Un(e, n, t.data, t.event_id) || (n === e.ownId ? e : L(e, an)) : r < o.ply ? e : L(e, I) : r <= e.ply ? e : L(e, I);
|
|
709
1271
|
}
|
|
710
|
-
function
|
|
1272
|
+
function Kn(e, t, n) {
|
|
711
1273
|
return !e.winnerId || !["won", "closed"].includes(e.status) ? e : n === e.ownId ? e.myRevealSent ? e : {
|
|
712
1274
|
...e,
|
|
713
1275
|
myRevealSent: !0
|
|
@@ -720,7 +1282,7 @@ function Bt(e, t, n) {
|
|
|
720
1282
|
verification: "pending"
|
|
721
1283
|
};
|
|
722
1284
|
}
|
|
723
|
-
function
|
|
1285
|
+
function qn(e, t, n, r = {}) {
|
|
724
1286
|
if (!e || e.game !== "battleship" || t?.game !== "battleship" || t.game_id !== e.gameId || n !== e.hostId && n !== e.guestId) return e;
|
|
725
1287
|
let i = t.data;
|
|
726
1288
|
if (t.type === "game_end") return i.reason !== "closed" || [
|
|
@@ -733,8 +1295,8 @@ function Vt(e, t, n, r = {}) {
|
|
|
733
1295
|
closedBy: n,
|
|
734
1296
|
error: ""
|
|
735
1297
|
};
|
|
736
|
-
if (t.type === "bs_reveal") return
|
|
737
|
-
if (
|
|
1298
|
+
if (t.type === "bs_reveal") return Kn(e, i, n);
|
|
1299
|
+
if (nn.includes(e.status) || e.status === "conflict") return e;
|
|
738
1300
|
switch (t.type) {
|
|
739
1301
|
case "game_accept":
|
|
740
1302
|
case "game_decline": return n !== e.guestId || e.status !== "invited" || i.invite_event_id !== e.inviteEventId ? e : t.type === "game_accept" ? {
|
|
@@ -747,32 +1309,32 @@ function Vt(e, t, n, r = {}) {
|
|
|
747
1309
|
status: "declined",
|
|
748
1310
|
lastEventId: t.event_id
|
|
749
1311
|
};
|
|
750
|
-
case "bs_commit": return e.status === "invited" ?
|
|
751
|
-
case "bs_fire": return
|
|
752
|
-
case "bs_result": return
|
|
1312
|
+
case "bs_commit": return e.status === "invited" ? L(e, rn) : e.status === "placement" ? Vn(e, n, i.commitment, r.stored) ?? e : e;
|
|
1313
|
+
case "bs_fire": return Wn(e, t, n);
|
|
1314
|
+
case "bs_result": return Gn(e, t, n);
|
|
753
1315
|
default: return e;
|
|
754
1316
|
}
|
|
755
1317
|
}
|
|
756
|
-
function
|
|
757
|
-
let n =
|
|
1318
|
+
function Jn(e, t) {
|
|
1319
|
+
let n = Qt({
|
|
758
1320
|
gameId: String(e.gameId),
|
|
759
1321
|
players: [e.hostId, e.guestId],
|
|
760
1322
|
firstPlayerId: e.hostId
|
|
761
1323
|
});
|
|
762
1324
|
for (let e of n.players) {
|
|
763
|
-
for (let r of t[e]) n =
|
|
1325
|
+
for (let r of t[e]) n = $t(n, {
|
|
764
1326
|
type: "place_ship",
|
|
765
1327
|
playerId: e,
|
|
766
|
-
...
|
|
1328
|
+
...xn(r)
|
|
767
1329
|
});
|
|
768
|
-
n =
|
|
1330
|
+
n = $t(n, {
|
|
769
1331
|
type: "ready",
|
|
770
1332
|
playerId: e
|
|
771
1333
|
});
|
|
772
1334
|
}
|
|
773
1335
|
if (n.phase !== "playing") return !1;
|
|
774
1336
|
for (let t of e.shots) {
|
|
775
|
-
let e =
|
|
1337
|
+
let e = $t(n, {
|
|
776
1338
|
type: "fire",
|
|
777
1339
|
playerId: t.by,
|
|
778
1340
|
row: t.row,
|
|
@@ -783,30 +1345,30 @@ function Ht(e, t) {
|
|
|
783
1345
|
if (r.result !== t.result || r.defeated !== t.defeated || r.sunk !== !!t.sunk) return !1;
|
|
784
1346
|
if (t.sunk) {
|
|
785
1347
|
let n = e.boards[e.players.indexOf(r.targetId)].ships.find((e) => e.id === r.shipId);
|
|
786
|
-
if (t.sunk.id !== r.shipId || !
|
|
1348
|
+
if (t.sunk.id !== r.shipId || !gn(n.cells, t.sunk.cells)) return !1;
|
|
787
1349
|
}
|
|
788
1350
|
n = e;
|
|
789
1351
|
}
|
|
790
1352
|
return !e.winnerId || n.winnerId === e.winnerId;
|
|
791
1353
|
}
|
|
792
|
-
async function
|
|
1354
|
+
async function Yn(e, t = e?.opponentReveal) {
|
|
793
1355
|
if (!e || !t) return "pending";
|
|
794
|
-
let n =
|
|
795
|
-
if (!r || !i || typeof t.salt != "string" || !
|
|
1356
|
+
let n = fn(e, e.ownId), r = e[pn(e, n)], i = Tn(t.fleet);
|
|
1357
|
+
if (!r || !i || typeof t.salt != "string" || !tn.test(t.salt)) return "mismatch";
|
|
796
1358
|
let a;
|
|
797
1359
|
try {
|
|
798
|
-
a = await
|
|
1360
|
+
a = await In(t.fleet, t.salt);
|
|
799
1361
|
} catch {
|
|
800
1362
|
return "mismatch";
|
|
801
1363
|
}
|
|
802
1364
|
if (a !== r) return "mismatch";
|
|
803
|
-
let o =
|
|
804
|
-
return o ?
|
|
1365
|
+
let o = Tn(e.myFleet);
|
|
1366
|
+
return o ? Jn(e, {
|
|
805
1367
|
[e.ownId]: o,
|
|
806
1368
|
[n]: i
|
|
807
1369
|
}) ? "ok" : "mismatch" : "pending";
|
|
808
1370
|
}
|
|
809
|
-
var
|
|
1371
|
+
var Xn = (e) => {
|
|
810
1372
|
if (e.result === "miss") return [
|
|
811
1373
|
e.row,
|
|
812
1374
|
e.col,
|
|
@@ -822,19 +1384,19 @@ var Wt = (e) => {
|
|
|
822
1384
|
e.row,
|
|
823
1385
|
e.col,
|
|
824
1386
|
2,
|
|
825
|
-
|
|
1387
|
+
f.findIndex((t) => t.id === e.sunk.id),
|
|
826
1388
|
t.row,
|
|
827
1389
|
t.col,
|
|
828
1390
|
+(e.sunk.orientation === "vertical")
|
|
829
1391
|
];
|
|
830
1392
|
};
|
|
831
|
-
function
|
|
1393
|
+
function Zn(e) {
|
|
832
1394
|
if (!e.acceptEventId) return {
|
|
833
1395
|
commits: [null, null],
|
|
834
1396
|
log: [],
|
|
835
1397
|
head: e.inviteEventId
|
|
836
1398
|
};
|
|
837
|
-
let t = e.shots.map(
|
|
1399
|
+
let t = e.shots.map(Xn);
|
|
838
1400
|
return e.pendingShot && t.push([e.pendingShot.row, e.pendingShot.col]), {
|
|
839
1401
|
accept_event_id: e.acceptEventId,
|
|
840
1402
|
commits: [e.hostCommitment ?? null, e.guestCommitment ?? null],
|
|
@@ -842,7 +1404,7 @@ function Gt(e) {
|
|
|
842
1404
|
head: e.lastEventId
|
|
843
1405
|
};
|
|
844
1406
|
}
|
|
845
|
-
function
|
|
1407
|
+
function Qn(e, t) {
|
|
846
1408
|
let n = e.accept_event_id ?? null, r = t.accept_event_id ?? null;
|
|
847
1409
|
if (n && r && n !== r) return "diverged";
|
|
848
1410
|
let i = /* @__PURE__ */ new Set();
|
|
@@ -862,7 +1424,7 @@ function Kt(e, t) {
|
|
|
862
1424
|
}
|
|
863
1425
|
return a.length !== o.length && i.add(a.length < o.length ? "behind" : "ahead"), i.size === 2 ? "mixed" : i.size === 1 ? [...i][0] : a.length && e.head !== t.head ? "diverged" : "equal";
|
|
864
1426
|
}
|
|
865
|
-
function
|
|
1427
|
+
function $n(e, t) {
|
|
866
1428
|
if ((e.log ?? []).length || (t.log ?? []).length) return null;
|
|
867
1429
|
let n = e.accept_event_id ?? t.accept_event_id;
|
|
868
1430
|
return n ? {
|
|
@@ -872,15 +1434,15 @@ function qt(e, t) {
|
|
|
872
1434
|
head: n
|
|
873
1435
|
} : null;
|
|
874
1436
|
}
|
|
875
|
-
function
|
|
1437
|
+
function er(e, t, n = {}) {
|
|
876
1438
|
let r = {
|
|
877
1439
|
...e,
|
|
878
1440
|
status: "invited",
|
|
879
1441
|
turnId: null,
|
|
880
1442
|
myReady: !1,
|
|
881
1443
|
opponentReady: !1,
|
|
882
|
-
incomingShots:
|
|
883
|
-
targetShots:
|
|
1444
|
+
incomingShots: sn(),
|
|
1445
|
+
targetShots: sn(),
|
|
884
1446
|
sunkEnemyShips: [],
|
|
885
1447
|
pendingShot: null,
|
|
886
1448
|
lastShot: null,
|
|
@@ -909,11 +1471,11 @@ function Jt(e, t, n = {}) {
|
|
|
909
1471
|
acceptEventId: t.accept_event_id,
|
|
910
1472
|
lastEventId: t.accept_event_id
|
|
911
1473
|
};
|
|
912
|
-
for (let [t, r] of [e.hostId, e.guestId].entries()) if (a[t] && (s =
|
|
1474
|
+
for (let [t, r] of [e.hostId, e.guestId].entries()) if (a[t] && (s = Vn(s, r, a[t], n.stored), !s)) return null;
|
|
913
1475
|
if (i.length && s.status !== "active") return null;
|
|
914
1476
|
for (let e = 0; e < i.length; e += 1) {
|
|
915
1477
|
let t = i[e], n = e + 1;
|
|
916
|
-
if (s =
|
|
1478
|
+
if (s = Hn(s, dn(s, n), {
|
|
917
1479
|
row: t[0],
|
|
918
1480
|
col: t[1],
|
|
919
1481
|
ply: n
|
|
@@ -922,9 +1484,9 @@ function Jt(e, t, n = {}) {
|
|
|
922
1484
|
if (e !== i.length - 1) return null;
|
|
923
1485
|
break;
|
|
924
1486
|
}
|
|
925
|
-
let r =
|
|
1487
|
+
let r = fn(s, s.pendingShot.by), a = null;
|
|
926
1488
|
if (t[2] === 2) {
|
|
927
|
-
let e =
|
|
1489
|
+
let e = f[t[3]];
|
|
928
1490
|
if (!e) return null;
|
|
929
1491
|
let n = t[6] === 1;
|
|
930
1492
|
a = {
|
|
@@ -932,14 +1494,14 @@ function Jt(e, t, n = {}) {
|
|
|
932
1494
|
cells: Array.from({ length: e.size }, (e, r) => [t[4] + (n ? r : 0), t[5] + (n ? 0 : r)])
|
|
933
1495
|
};
|
|
934
1496
|
}
|
|
935
|
-
let o =
|
|
936
|
-
if (s =
|
|
1497
|
+
let o = ln(r === s.ownId ? s.incomingShots : s.targetShots) + (t[2] === 0 ? 0 : 1);
|
|
1498
|
+
if (s = Un(s, r, {
|
|
937
1499
|
ply: n,
|
|
938
1500
|
row: t[0],
|
|
939
1501
|
col: t[1],
|
|
940
1502
|
result: t[2] === 0 ? "miss" : "hit",
|
|
941
1503
|
sunk: a,
|
|
942
|
-
defeated: o ===
|
|
1504
|
+
defeated: o === en
|
|
943
1505
|
}, null), !s || s.status === "won" && e !== i.length - 1) return null;
|
|
944
1506
|
}
|
|
945
1507
|
return !i.length && t.head !== t.accept_event_id ? null : (s = {
|
|
@@ -952,7 +1514,7 @@ function Jt(e, t, n = {}) {
|
|
|
952
1514
|
verification: e.verification
|
|
953
1515
|
}), s);
|
|
954
1516
|
}
|
|
955
|
-
function
|
|
1517
|
+
function tr(e, t) {
|
|
956
1518
|
if (!e || !t) return !1;
|
|
957
1519
|
let n = e.log?.[(t.data?.ply ?? 0) - 1];
|
|
958
1520
|
switch (t.type) {
|
|
@@ -963,37 +1525,37 @@ function Yt(e, t) {
|
|
|
963
1525
|
default: return !1;
|
|
964
1526
|
}
|
|
965
1527
|
}
|
|
966
|
-
function
|
|
1528
|
+
function nr(e, t) {
|
|
967
1529
|
let n = { ...e };
|
|
968
1530
|
return t.acceptEventId && (n[t.acceptEventId] = !0), t.lastEventId && (n[t.lastEventId] = !0), n;
|
|
969
1531
|
}
|
|
970
1532
|
// src/games/battleship/net/fleetStorage.js
|
|
971
|
-
var
|
|
1533
|
+
var rr = "lira:bs:", ir = 12096e5, ar = (e, t) => `${rr}${e}:${t}`, or = () => {
|
|
972
1534
|
try {
|
|
973
1535
|
return globalThis.localStorage ?? null;
|
|
974
1536
|
} catch {
|
|
975
1537
|
return null;
|
|
976
1538
|
}
|
|
977
1539
|
};
|
|
978
|
-
function
|
|
1540
|
+
function sr(e) {
|
|
979
1541
|
return typeof e == "object" && !!e && Array.isArray(e.fleet) && e.fleet.length === 5 && typeof e.salt == "string" && /^[0-9a-f]{32}$/.test(e.salt) && typeof e.commitment == "string" && /^[0-9a-f]{64}$/.test(e.commitment);
|
|
980
1542
|
}
|
|
981
|
-
function
|
|
1543
|
+
function cr(e) {
|
|
982
1544
|
let t = Date.now();
|
|
983
1545
|
for (let n = e.length - 1; n >= 0; --n) {
|
|
984
1546
|
let r = e.key(n);
|
|
985
|
-
if (r?.startsWith(
|
|
1547
|
+
if (r?.startsWith(rr)) try {
|
|
986
1548
|
let n = JSON.parse(e.getItem(r));
|
|
987
|
-
|
|
1549
|
+
sr(n) && t - n.savedAt < ir || e.removeItem(r);
|
|
988
1550
|
} catch {
|
|
989
1551
|
e.removeItem(r);
|
|
990
1552
|
}
|
|
991
1553
|
}
|
|
992
1554
|
}
|
|
993
|
-
function
|
|
1555
|
+
function lr(e, t, { fleet: n, salt: r, commitment: i }) {
|
|
994
1556
|
try {
|
|
995
|
-
let a =
|
|
996
|
-
return a ? (
|
|
1557
|
+
let a = or();
|
|
1558
|
+
return a ? (cr(a), a.setItem(ar(e, t), JSON.stringify({
|
|
997
1559
|
fleet: n,
|
|
998
1560
|
salt: r,
|
|
999
1561
|
commitment: i,
|
|
@@ -1003,10 +1565,10 @@ function rn(e, t, { fleet: n, salt: r, commitment: i }) {
|
|
|
1003
1565
|
return !1;
|
|
1004
1566
|
}
|
|
1005
1567
|
}
|
|
1006
|
-
function
|
|
1568
|
+
function ur(e, t) {
|
|
1007
1569
|
try {
|
|
1008
|
-
let n = JSON.parse(
|
|
1009
|
-
return
|
|
1570
|
+
let n = JSON.parse(or()?.getItem(ar(e, t)) ?? "null");
|
|
1571
|
+
return sr(n) ? {
|
|
1010
1572
|
fleet: n.fleet,
|
|
1011
1573
|
salt: n.salt,
|
|
1012
1574
|
commitment: n.commitment
|
|
@@ -1016,20 +1578,20 @@ function an(e, t) {
|
|
|
1016
1578
|
}
|
|
1017
1579
|
}
|
|
1018
1580
|
// src/games/tanks/logic/constants.js
|
|
1019
|
-
var
|
|
1020
|
-
2 *
|
|
1021
|
-
var
|
|
1022
|
-
4 *
|
|
1023
|
-
var
|
|
1581
|
+
var R = 1e5, dr = 160 * R, z = 2 * R, fr = 20 * R;
|
|
1582
|
+
2 * R;
|
|
1583
|
+
var pr = 1 * R;
|
|
1584
|
+
4 * R, 4 * R;
|
|
1585
|
+
var mr = 18e4, hr = 25e4, gr = 5e4, B = 25e3, _r = 60 * R, vr = 4 * R, V = Object.freeze({
|
|
1024
1586
|
move: Object.freeze([-16, 16]),
|
|
1025
1587
|
yaw: Object.freeze([0, 359]),
|
|
1026
1588
|
pitch: Object.freeze([5, 80]),
|
|
1027
1589
|
power: Object.freeze([0, 100])
|
|
1028
|
-
}),
|
|
1590
|
+
}), H = Object.freeze({
|
|
1029
1591
|
standard: Object.freeze({
|
|
1030
1592
|
id: "standard",
|
|
1031
1593
|
cost: 0,
|
|
1032
|
-
radius: 6 *
|
|
1594
|
+
radius: 6 * R,
|
|
1033
1595
|
maxDmg: 40,
|
|
1034
1596
|
depth: 15e4,
|
|
1035
1597
|
speedPct: 100
|
|
@@ -1037,7 +1599,7 @@ var ln = 18e4, un = 25e4, dn = 5e4, F = 25e3, fn = 60 * N, pn = 4 * N, I = Objec
|
|
|
1037
1599
|
heavy: Object.freeze({
|
|
1038
1600
|
id: "heavy",
|
|
1039
1601
|
cost: 1,
|
|
1040
|
-
radius: 8 *
|
|
1602
|
+
radius: 8 * R,
|
|
1041
1603
|
maxDmg: 55,
|
|
1042
1604
|
depth: 25e4,
|
|
1043
1605
|
speedPct: 85
|
|
@@ -1045,16 +1607,16 @@ var ln = 18e4, un = 25e4, dn = 5e4, F = 25e3, fn = 60 * N, pn = 4 * N, I = Objec
|
|
|
1045
1607
|
cluster: Object.freeze({
|
|
1046
1608
|
id: "cluster",
|
|
1047
1609
|
cost: 1,
|
|
1048
|
-
radius: 4 *
|
|
1610
|
+
radius: 4 * R,
|
|
1049
1611
|
maxDmg: 15,
|
|
1050
1612
|
depth: 8e4,
|
|
1051
1613
|
speedPct: 100
|
|
1052
1614
|
})
|
|
1053
|
-
}),
|
|
1054
|
-
radius: 4 *
|
|
1615
|
+
}), yr = Object.freeze({
|
|
1616
|
+
radius: 4 * R,
|
|
1055
1617
|
maxDmg: 15,
|
|
1056
1618
|
depth: 8e4
|
|
1057
|
-
}),
|
|
1619
|
+
}), br = Object.freeze([
|
|
1058
1620
|
Object.freeze([
|
|
1059
1621
|
0,
|
|
1060
1622
|
0,
|
|
@@ -1080,10 +1642,10 @@ var ln = 18e4, un = 25e4, dn = 5e4, F = 25e3, fn = 60 * N, pn = 4 * N, I = Objec
|
|
|
1080
1642
|
0,
|
|
1081
1643
|
-6e3
|
|
1082
1644
|
])
|
|
1083
|
-
]),
|
|
1645
|
+
]), xr = Object.freeze({
|
|
1084
1646
|
heavy: 2,
|
|
1085
1647
|
cluster: 2
|
|
1086
|
-
}),
|
|
1648
|
+
}), Sr = Object.freeze([
|
|
1087
1649
|
0,
|
|
1088
1650
|
17452,
|
|
1089
1651
|
34899,
|
|
@@ -1175,20 +1737,20 @@ var ln = 18e4, un = 25e4, dn = 5e4, F = 25e3, fn = 60 * N, pn = 4 * N, I = Objec
|
|
|
1175
1737
|
999391,
|
|
1176
1738
|
999848,
|
|
1177
1739
|
1e6
|
|
1178
|
-
]),
|
|
1179
|
-
function
|
|
1740
|
+
]), Cr = 1e6;
|
|
1741
|
+
function wr(e) {
|
|
1180
1742
|
let t = (e % 360 + 360) % 360;
|
|
1181
|
-
return t <= 90 ?
|
|
1743
|
+
return t <= 90 ? Sr[t] : t <= 180 ? Sr[180 - t] : t <= 270 ? -Sr[t - 180] : -Sr[360 - t];
|
|
1182
1744
|
}
|
|
1183
|
-
function
|
|
1184
|
-
return
|
|
1745
|
+
function Tr(e) {
|
|
1746
|
+
return wr(e + 90);
|
|
1185
1747
|
}
|
|
1186
|
-
function
|
|
1187
|
-
return Math.trunc(e * t /
|
|
1748
|
+
function U(e, t) {
|
|
1749
|
+
return Math.trunc(e * t / Cr);
|
|
1188
1750
|
}
|
|
1189
1751
|
// src/games/tanks/logic/rng.js
|
|
1190
|
-
var
|
|
1191
|
-
function
|
|
1752
|
+
var Er = (e) => Number.isInteger(e) && e >= 0 && e <= 4294967295;
|
|
1753
|
+
function Dr(e) {
|
|
1192
1754
|
let t = e >>> 0;
|
|
1193
1755
|
return function() {
|
|
1194
1756
|
t = t + 1831565813 >>> 0;
|
|
@@ -1196,48 +1758,48 @@ function Sn(e) {
|
|
|
1196
1758
|
return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), (e ^ e >>> 14) >>> 0;
|
|
1197
1759
|
};
|
|
1198
1760
|
}
|
|
1199
|
-
function
|
|
1761
|
+
function W(e, t, n) {
|
|
1200
1762
|
return t + e() % (n - t + 1);
|
|
1201
1763
|
}
|
|
1202
|
-
function
|
|
1203
|
-
let n =
|
|
1764
|
+
function Or(e, t) {
|
|
1765
|
+
let n = Dr((e ^ Math.imul(t, 2654435761)) >>> 0);
|
|
1204
1766
|
return {
|
|
1205
|
-
x:
|
|
1206
|
-
z:
|
|
1767
|
+
x: W(n, -40, 40),
|
|
1768
|
+
z: W(n, -40, 40)
|
|
1207
1769
|
};
|
|
1208
1770
|
}
|
|
1209
1771
|
// src/games/tanks/logic/terrain.js
|
|
1210
|
-
var
|
|
1211
|
-
function
|
|
1212
|
-
let r =
|
|
1213
|
-
return
|
|
1772
|
+
var G = (e, t, n) => e < t ? t : e > n ? n : e, K = (e, t, n, r) => e + Math.trunc((t - e) * n / r);
|
|
1773
|
+
function q(e, t, n) {
|
|
1774
|
+
let r = G(t, 0, dr), i = G(n, 0, dr), a = Math.min(Math.trunc(r / z), 79), o = Math.min(Math.trunc(i / z), 79), s = r - a * z, c = i - o * z, l = o * 81;
|
|
1775
|
+
return K(K(e[l + a], e[l + a + 1], s, z), K(e[l + 81 + a], e[l + 81 + a + 1], s, z), c, z);
|
|
1214
1776
|
}
|
|
1215
|
-
function
|
|
1777
|
+
function kr(e, t, n, r) {
|
|
1216
1778
|
let i = Math.trunc(80 / t) + 1, a = [];
|
|
1217
|
-
for (let t = 0; t < i * i; t += 1) a.push(
|
|
1779
|
+
for (let t = 0; t < i * i; t += 1) a.push(W(e, n, r) * 1e3);
|
|
1218
1780
|
return {
|
|
1219
1781
|
n: i,
|
|
1220
1782
|
step: t,
|
|
1221
1783
|
values: a
|
|
1222
1784
|
};
|
|
1223
1785
|
}
|
|
1224
|
-
function
|
|
1786
|
+
function Ar({ n: e, step: t, values: n }, r, i) {
|
|
1225
1787
|
let a = Math.min(Math.trunc(r / t), e - 2), o = Math.min(Math.trunc(i / t), e - 2), s = r - a * t, c = i - o * t, l = (t, r) => n[r * e + t];
|
|
1226
|
-
return
|
|
1788
|
+
return K(K(l(a, o), l(a + 1, o), s, t), K(l(a, o + 1), l(a + 1, o + 1), s, t), c, t);
|
|
1227
1789
|
}
|
|
1228
|
-
function
|
|
1790
|
+
function jr(e) {
|
|
1229
1791
|
let t = new Int32Array(e.length);
|
|
1230
1792
|
for (let n = 0; n < 81; n += 1) for (let r = 0; r < 81; r += 1) {
|
|
1231
1793
|
let i = 0;
|
|
1232
|
-
for (let t = -1; t <= 1; t += 1) for (let a = -1; a <= 1; a += 1) i += e[
|
|
1794
|
+
for (let t = -1; t <= 1; t += 1) for (let a = -1; a <= 1; a += 1) i += e[G(n + t, 0, 80) * 81 + G(r + a, 0, 80)];
|
|
1233
1795
|
t[n * 81 + r] = Math.trunc(i / 9);
|
|
1234
1796
|
}
|
|
1235
1797
|
return t;
|
|
1236
1798
|
}
|
|
1237
|
-
function
|
|
1238
|
-
let a =
|
|
1799
|
+
function Mr(e, t, n, r, i) {
|
|
1800
|
+
let a = q(e, t, n), o = r * r, s = i * i;
|
|
1239
1801
|
for (let r = 0; r < 81; r += 1) for (let c = 0; c < 81; c += 1) {
|
|
1240
|
-
let l = c *
|
|
1802
|
+
let l = c * z - t, u = r * z - n;
|
|
1241
1803
|
if (l > i || l < -i || u > i || u < -i) continue;
|
|
1242
1804
|
let d = l * l + u * u;
|
|
1243
1805
|
if (d >= s) continue;
|
|
@@ -1249,44 +1811,44 @@ function Dn(e, t, n, r, i) {
|
|
|
1249
1811
|
}
|
|
1250
1812
|
}
|
|
1251
1813
|
}
|
|
1252
|
-
var
|
|
1814
|
+
var J = (e, t, n) => W(e, t, n) * (R / 2), Nr = (e, t, n, r, i) => {
|
|
1253
1815
|
let a = e - n, o = t - r;
|
|
1254
1816
|
return a > i || a < -i || o > i || o < -i ? !1 : a * a + o * o < i * i;
|
|
1255
|
-
},
|
|
1256
|
-
function
|
|
1257
|
-
let t =
|
|
1817
|
+
}, Pr = (e, t, n, r) => t >= e.x - e.w / 2 - r && t <= e.x + e.w / 2 + r && n >= e.z - e.d / 2 - r && n <= e.z + e.d / 2 + r;
|
|
1818
|
+
function Fr(e) {
|
|
1819
|
+
let t = Dr(e), n = kr(t, 20, 0, 1200), r = kr(t, 10, -250, 250), i = kr(t, 4, -60, 60), a = /* @__PURE__ */ new Int32Array(6561);
|
|
1258
1820
|
for (let e = 0; e < 81; e += 1) for (let t = 0; t < 81; t += 1) {
|
|
1259
|
-
let o = 3 *
|
|
1260
|
-
a[e * 81 + t] =
|
|
1821
|
+
let o = 3 * R + Ar(n, t, e) + Ar(r, t, e) + Ar(i, t, e);
|
|
1822
|
+
a[e * 81 + t] = G(o, 0, fr);
|
|
1261
1823
|
}
|
|
1262
|
-
a =
|
|
1824
|
+
a = jr(jr(a));
|
|
1263
1825
|
let o = [{
|
|
1264
|
-
x: 20 *
|
|
1265
|
-
z: 80 *
|
|
1826
|
+
x: 20 * R + J(t, -4, 4),
|
|
1827
|
+
z: 80 * R + J(t, -40, 40)
|
|
1266
1828
|
}, {
|
|
1267
|
-
x: 140 *
|
|
1268
|
-
z: 80 *
|
|
1829
|
+
x: 140 * R + J(t, -4, 4),
|
|
1830
|
+
z: 80 * R + J(t, -40, 40)
|
|
1269
1831
|
}];
|
|
1270
|
-
for (let e of o)
|
|
1271
|
-
let s = [], c =
|
|
1832
|
+
for (let e of o) Mr(a, e.x, e.z, vr, vr + 3 * R);
|
|
1833
|
+
let s = [], c = W(t, 4, 6);
|
|
1272
1834
|
for (let e = 0; e < 200 && s.length < c; e += 1) {
|
|
1273
|
-
let e = t() % 2 == 0 ? "rock" : "wall", n =
|
|
1274
|
-
e === "wall" && (n >= r ? r = 2 *
|
|
1275
|
-
let i =
|
|
1276
|
-
if (o.some((e) =>
|
|
1835
|
+
let e = t() % 2 == 0 ? "rock" : "wall", n = J(t, 4, 12), r = J(t, 4, 12);
|
|
1836
|
+
e === "wall" && (n >= r ? r = 2 * R : n = 2 * R);
|
|
1837
|
+
let i = J(t, 4, 10), c = J(t, 100, 220), l = J(t, 40, 280), u = 12 * R + (n > r ? n : r);
|
|
1838
|
+
if (o.some((e) => Nr(e.x, e.z, c, l, u))) continue;
|
|
1277
1839
|
let d = {
|
|
1278
1840
|
x: c,
|
|
1279
1841
|
z: l,
|
|
1280
1842
|
w: n,
|
|
1281
1843
|
d: r
|
|
1282
1844
|
};
|
|
1283
|
-
if (s.some((e) =>
|
|
1845
|
+
if (s.some((e) => Pr(e, c, l, (n > r ? n : r) + 4e5))) continue;
|
|
1284
1846
|
let f = [
|
|
1285
1847
|
[-1, -1],
|
|
1286
1848
|
[1, -1],
|
|
1287
1849
|
[-1, 1],
|
|
1288
1850
|
[1, 1]
|
|
1289
|
-
].map(([e, t]) =>
|
|
1851
|
+
].map(([e, t]) => q(a, c + e * n / 2, l + t * r / 2)), p = Math.min(q(a, c, l), ...f);
|
|
1290
1852
|
s.push({
|
|
1291
1853
|
id: s.length,
|
|
1292
1854
|
kind: e,
|
|
@@ -1295,10 +1857,10 @@ function An(e) {
|
|
|
1295
1857
|
y: p
|
|
1296
1858
|
});
|
|
1297
1859
|
}
|
|
1298
|
-
let l = [], u =
|
|
1860
|
+
let l = [], u = W(t, 30, 60);
|
|
1299
1861
|
for (let e = 0; e < u * 10 && l.length < u; e += 1) {
|
|
1300
|
-
let e =
|
|
1301
|
-
o.some((t) =>
|
|
1862
|
+
let e = J(t, 4, 316), n = J(t, 4, 316), r = t() % 3 == 0 ? "rock" : "tree", i = W(t, 80, 140);
|
|
1863
|
+
o.some((t) => Nr(t.x, t.z, e, n, 1e6)) || s.some((t) => Pr(t, e, n, 2e5)) || l.push({
|
|
1302
1864
|
id: l.length,
|
|
1303
1865
|
kind: r,
|
|
1304
1866
|
x: e,
|
|
@@ -1313,10 +1875,10 @@ function An(e) {
|
|
|
1313
1875
|
decor: l
|
|
1314
1876
|
};
|
|
1315
1877
|
}
|
|
1316
|
-
function
|
|
1317
|
-
let a = r * r, o = (e) =>
|
|
1878
|
+
function Ir(e, { x: t, z: n, radius: r, depth: i }) {
|
|
1879
|
+
let a = r * r, o = (e) => G(Math.trunc(e / z) - 1, 0, 80);
|
|
1318
1880
|
for (let s = o(n - r); s <= o(n + r) + 2 && s < 81; s += 1) for (let c = o(t - r); c <= o(t + r) + 2 && c < 81; c += 1) {
|
|
1319
|
-
let o = c *
|
|
1881
|
+
let o = c * z - t, l = s * z - n;
|
|
1320
1882
|
if (o > r || o < -r || l > r || l < -r) continue;
|
|
1321
1883
|
let u = o * o + l * l;
|
|
1322
1884
|
if (u >= a) continue;
|
|
@@ -1325,29 +1887,29 @@ function jn(e, { x: t, z: n, radius: r, depth: i }) {
|
|
|
1325
1887
|
}
|
|
1326
1888
|
return e;
|
|
1327
1889
|
}
|
|
1328
|
-
function
|
|
1329
|
-
return e.filter((e) => !t.some((t) =>
|
|
1890
|
+
function Lr(e, t) {
|
|
1891
|
+
return e.filter((e) => !t.some((t) => Nr(t.x, t.z, e.x, e.z, t.radius)));
|
|
1330
1892
|
}
|
|
1331
1893
|
// src/games/tanks/logic/ballistics.js
|
|
1332
|
-
function
|
|
1333
|
-
return Math.trunc((2e4 + 600 * e) *
|
|
1894
|
+
function Rr(e, t) {
|
|
1895
|
+
return Math.trunc((2e4 + 600 * e) * H[t].speedPct / 100);
|
|
1334
1896
|
}
|
|
1335
|
-
function
|
|
1336
|
-
let a =
|
|
1897
|
+
function zr(e, { yaw: t, pitch: n, power: r, ammo: i }) {
|
|
1898
|
+
let a = Tr(n), o = wr(n), s = Tr(t), c = wr(t), l = U(hr, a), u = Rr(r, i), d = U(u, a);
|
|
1337
1899
|
return {
|
|
1338
|
-
x: e.x +
|
|
1339
|
-
y: e.y +
|
|
1340
|
-
z: e.z +
|
|
1341
|
-
vx:
|
|
1342
|
-
vy:
|
|
1343
|
-
vz:
|
|
1900
|
+
x: e.x + U(l, s),
|
|
1901
|
+
y: e.y + mr + U(hr, o),
|
|
1902
|
+
z: e.z + U(l, c),
|
|
1903
|
+
vx: U(d, s),
|
|
1904
|
+
vy: U(u, o),
|
|
1905
|
+
vz: U(d, c)
|
|
1344
1906
|
};
|
|
1345
1907
|
}
|
|
1346
|
-
function
|
|
1908
|
+
function Br(e, t, n, r, i, a, o) {
|
|
1347
1909
|
let s = e - r, c = t - i, l = n - a;
|
|
1348
1910
|
return s > o || s < -o || c > o || c < -o || l > o || l < -o ? !1 : s * s + c * c + l * l < o * o;
|
|
1349
1911
|
}
|
|
1350
|
-
function
|
|
1912
|
+
function Vr(e, { wind: t, heights: n, tanks: r, obstacles: i, maxTicks: a = 600, split: o = !1 }) {
|
|
1351
1913
|
let { x: s, y: c, z: l, vx: u, vy: d, vz: f } = e, p = [
|
|
1352
1914
|
s,
|
|
1353
1915
|
c,
|
|
@@ -1357,7 +1919,7 @@ function In(e, { wind: t, heights: n, tanks: r, obstacles: i, maxTicks: a = 600,
|
|
|
1357
1919
|
let a = d;
|
|
1358
1920
|
u += t.x, d -= 392, f += t.z, s += u, c += d, l += f;
|
|
1359
1921
|
let m = null;
|
|
1360
|
-
for (let e of r) if (
|
|
1922
|
+
for (let e of r) if (Br(s, c, l, e.x, e.y + 1e5, e.z, 2e5)) {
|
|
1361
1923
|
m = {
|
|
1362
1924
|
x: s,
|
|
1363
1925
|
y: c,
|
|
@@ -1368,7 +1930,7 @@ function In(e, { wind: t, heights: n, tanks: r, obstacles: i, maxTicks: a = 600,
|
|
|
1368
1930
|
break;
|
|
1369
1931
|
}
|
|
1370
1932
|
if (!m) {
|
|
1371
|
-
let e = i.find((e) => c <= e.y + e.h &&
|
|
1933
|
+
let e = i.find((e) => c <= e.y + e.h && Pr(e, s, l, 0));
|
|
1372
1934
|
e && (m = {
|
|
1373
1935
|
x: s,
|
|
1374
1936
|
y: c,
|
|
@@ -1383,7 +1945,7 @@ function In(e, { wind: t, heights: n, tanks: r, obstacles: i, maxTicks: a = 600,
|
|
|
1383
1945
|
z: l,
|
|
1384
1946
|
kind: "out"
|
|
1385
1947
|
}), !m) {
|
|
1386
|
-
let e =
|
|
1948
|
+
let e = q(n, s, l);
|
|
1387
1949
|
c <= e && (m = {
|
|
1388
1950
|
x: s,
|
|
1389
1951
|
y: e,
|
|
@@ -1424,7 +1986,7 @@ function In(e, { wind: t, heights: n, tanks: r, obstacles: i, maxTicks: a = 600,
|
|
|
1424
1986
|
}
|
|
1425
1987
|
};
|
|
1426
1988
|
}
|
|
1427
|
-
var
|
|
1989
|
+
var Hr = (e, t, n, r) => ({
|
|
1428
1990
|
role: e,
|
|
1429
1991
|
startTick: t,
|
|
1430
1992
|
samples: n.samples,
|
|
@@ -1434,17 +1996,17 @@ var Ln = (e, t, n, r) => ({
|
|
|
1434
1996
|
maxDmg: n.impact.kind === "split" ? 0 : r.maxDmg,
|
|
1435
1997
|
depth: n.impact.kind === "split" ? 0 : r.depth
|
|
1436
1998
|
});
|
|
1437
|
-
function
|
|
1438
|
-
let r =
|
|
1439
|
-
if (t.ammo !== "cluster") return [
|
|
1440
|
-
let i =
|
|
1999
|
+
function Ur(e, t, n) {
|
|
2000
|
+
let r = zr(e, t);
|
|
2001
|
+
if (t.ammo !== "cluster") return [Hr("main", 0, Vr(r, n), H[t.ammo])];
|
|
2002
|
+
let i = Vr(r, {
|
|
1441
2003
|
...n,
|
|
1442
2004
|
split: !0
|
|
1443
|
-
}), a = [
|
|
2005
|
+
}), a = [Hr("carrier", 0, i, yr)];
|
|
1444
2006
|
if (i.impact.kind !== "split") return a;
|
|
1445
2007
|
let o = (n.maxTicks ?? 600) - i.ticks;
|
|
1446
|
-
for (let [e, t, r] of
|
|
1447
|
-
let { x: s, y: c, z: l } = i.impact, { vx: u, vy: d, vz: f } = i.velocity, p =
|
|
2008
|
+
for (let [e, t, r] of br) {
|
|
2009
|
+
let { x: s, y: c, z: l } = i.impact, { vx: u, vy: d, vz: f } = i.velocity, p = Vr({
|
|
1448
2010
|
x: s,
|
|
1449
2011
|
y: c,
|
|
1450
2012
|
z: l,
|
|
@@ -1456,18 +2018,18 @@ function Rn(e, t, n) {
|
|
|
1456
2018
|
maxTicks: o,
|
|
1457
2019
|
split: !1
|
|
1458
2020
|
});
|
|
1459
|
-
a.push(
|
|
2021
|
+
a.push(Hr("bomblet", i.ticks, p, yr));
|
|
1460
2022
|
}
|
|
1461
2023
|
return a;
|
|
1462
2024
|
}
|
|
1463
|
-
function
|
|
2025
|
+
function Wr(e, t) {
|
|
1464
2026
|
let n = t.map(() => 0);
|
|
1465
2027
|
for (let r of e) {
|
|
1466
2028
|
let { impact: e, radius: i, maxDmg: a } = r;
|
|
1467
2029
|
if (e.kind === "out" || e.kind === "split") continue;
|
|
1468
2030
|
let o = i * i;
|
|
1469
2031
|
t.forEach((t, r) => {
|
|
1470
|
-
let s = t.y +
|
|
2032
|
+
let s = t.y + pr;
|
|
1471
2033
|
e.kind === "tank" && e.tankId === t.id && (n[r] += 25);
|
|
1472
2034
|
let c = e.x - t.x, l = e.y - s, u = e.z - t.z;
|
|
1473
2035
|
if (c >= i || c <= -i || l >= i || l <= -i || u >= i || u <= -i) return;
|
|
@@ -1477,7 +2039,7 @@ function zn(e, t) {
|
|
|
1477
2039
|
}
|
|
1478
2040
|
return n;
|
|
1479
2041
|
}
|
|
1480
|
-
function
|
|
2042
|
+
function Gr(e) {
|
|
1481
2043
|
return e.filter((e) => e.impact.kind !== "out" && e.impact.kind !== "split").map((e) => ({
|
|
1482
2044
|
x: e.impact.x,
|
|
1483
2045
|
z: e.impact.z,
|
|
@@ -1486,8 +2048,8 @@ function Bn(e) {
|
|
|
1486
2048
|
}));
|
|
1487
2049
|
}
|
|
1488
2050
|
// src/games/tanks/logic/movement.js
|
|
1489
|
-
function
|
|
1490
|
-
let a = t < 0 ? -1 : 1, o = (t < 0 ? -t : t) * (
|
|
2051
|
+
function Kr(e, t, { heights: n, obstacles: r, others: i }) {
|
|
2052
|
+
let a = t < 0 ? -1 : 1, o = (t < 0 ? -t : t) * (gr / B), s = Math.min(o, Math.trunc(e.fuel / B)), c = a * U(B, Tr(e.hullYaw)), l = a * U(B, wr(e.hullYaw)), { x: u, z: d } = e, f = q(n, u, d), p = [{
|
|
1491
2053
|
x: u,
|
|
1492
2054
|
y: f,
|
|
1493
2055
|
z: d
|
|
@@ -1498,7 +2060,7 @@ function Vn(e, t, { heights: n, obstacles: r, others: i }) {
|
|
|
1498
2060
|
h = "border";
|
|
1499
2061
|
break;
|
|
1500
2062
|
}
|
|
1501
|
-
if (r.some((n) =>
|
|
2063
|
+
if (r.some((n) => Pr(n, e, t, 2e5))) {
|
|
1502
2064
|
h = "obstacle";
|
|
1503
2065
|
break;
|
|
1504
2066
|
}
|
|
@@ -1509,7 +2071,7 @@ function Vn(e, t, { heights: n, obstacles: r, others: i }) {
|
|
|
1509
2071
|
h = "tank";
|
|
1510
2072
|
break;
|
|
1511
2073
|
}
|
|
1512
|
-
let a =
|
|
2074
|
+
let a = q(n, e, t);
|
|
1513
2075
|
if ((a > f ? a - f : f - a) * 1e3 > 175e5) {
|
|
1514
2076
|
h = "slope";
|
|
1515
2077
|
break;
|
|
@@ -1529,29 +2091,29 @@ function Vn(e, t, { heights: n, obstacles: r, others: i }) {
|
|
|
1529
2091
|
x: u,
|
|
1530
2092
|
y: f,
|
|
1531
2093
|
z: d,
|
|
1532
|
-
used: m *
|
|
2094
|
+
used: m * B,
|
|
1533
2095
|
stop: h
|
|
1534
2096
|
};
|
|
1535
2097
|
}
|
|
1536
2098
|
// src/games/tanks/logic/game.js
|
|
1537
|
-
var
|
|
2099
|
+
var qr = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, Y = (e) => ({
|
|
1538
2100
|
ok: !1,
|
|
1539
2101
|
reason: e
|
|
1540
|
-
}),
|
|
1541
|
-
function
|
|
1542
|
-
if (!
|
|
1543
|
-
if (!
|
|
1544
|
-
let { heights: i, spawns: a, obstacles: o, decor: s } =
|
|
2102
|
+
}), Jr = (e, [t, n]) => Number.isInteger(e) && e >= t && e <= n;
|
|
2103
|
+
function Yr({ gameId: e, players: t, firstPlayerId: n = t?.[0], seed: r } = {}) {
|
|
2104
|
+
if (!qr(e) || !Array.isArray(t) || t.length !== 2 || !t.every(qr) || t[0] === t[1] || !t.includes(n)) throw TypeError("Supply a gameId, two distinct player IDs and a valid firstPlayerId.");
|
|
2105
|
+
if (!Er(r)) throw TypeError("Supply an integer seed in 0..0xffffffff.");
|
|
2106
|
+
let { heights: i, spawns: a, obstacles: o, decor: s } = Fr(r), c = t.map((e, t) => ({
|
|
1545
2107
|
id: e,
|
|
1546
2108
|
x: a[t].x,
|
|
1547
|
-
y:
|
|
2109
|
+
y: q(i, a[t].x, a[t].z),
|
|
1548
2110
|
z: a[t].z,
|
|
1549
2111
|
hullYaw: t === 0 ? 0 : 180,
|
|
1550
2112
|
yaw: t === 0 ? 0 : 180,
|
|
1551
2113
|
pitch: 30,
|
|
1552
2114
|
hp: 100,
|
|
1553
|
-
fuel:
|
|
1554
|
-
ammo: { ...
|
|
2115
|
+
fuel: _r,
|
|
2116
|
+
ammo: { ...xr },
|
|
1555
2117
|
skips: 0
|
|
1556
2118
|
}));
|
|
1557
2119
|
return {
|
|
@@ -1577,24 +2139,24 @@ function Wn({ gameId: e, players: t, firstPlayerId: n = t?.[0], seed: r } = {})
|
|
|
1577
2139
|
revision: 0
|
|
1578
2140
|
};
|
|
1579
2141
|
}
|
|
1580
|
-
function
|
|
1581
|
-
return !e || !t || typeof t != "object" ?
|
|
2142
|
+
function Xr(e, t) {
|
|
2143
|
+
return !e || !t || typeof t != "object" ? Y("invalid_action") : e.phase === "finished" ? Y("game_finished") : t.gameId !== void 0 && t.gameId !== e.gameId ? Y("wrong_game") : t.expectedRevision !== void 0 && t.expectedRevision !== e.revision ? Y("stale_revision") : e.players.includes(t.playerId) ? { ok: !0 } : Y("unknown_player");
|
|
1582
2144
|
}
|
|
1583
|
-
function
|
|
1584
|
-
let n =
|
|
2145
|
+
function Zr(e, t) {
|
|
2146
|
+
let n = Xr(e, t);
|
|
1585
2147
|
if (!n.ok) return n;
|
|
1586
2148
|
let r = e.players.indexOf(t.playerId);
|
|
1587
|
-
if (r !== e.turnIndex) return
|
|
1588
|
-
if (!
|
|
1589
|
-
if (!
|
|
1590
|
-
if (!
|
|
1591
|
-
if (!
|
|
1592
|
-
if (typeof t.ammo != "string" || !Object.hasOwn(
|
|
1593
|
-
let i =
|
|
1594
|
-
return i > 0 && e.tanks[r].ammo[t.ammo] < i ?
|
|
1595
|
-
}
|
|
1596
|
-
function
|
|
1597
|
-
let r = e.players.indexOf(t.playerId), i = e.tanks[r], a = e.tanks[1 - r], o =
|
|
2149
|
+
if (r !== e.turnIndex) return Y("not_your_turn");
|
|
2150
|
+
if (!Jr(t.move, V.move)) return Y("invalid_move");
|
|
2151
|
+
if (!Jr(t.yaw, V.yaw)) return Y("invalid_yaw");
|
|
2152
|
+
if (!Jr(t.pitch, V.pitch)) return Y("invalid_pitch");
|
|
2153
|
+
if (!Jr(t.power, V.power)) return Y("invalid_power");
|
|
2154
|
+
if (typeof t.ammo != "string" || !Object.hasOwn(H, t.ammo)) return Y("unknown_ammo");
|
|
2155
|
+
let i = H[t.ammo].cost;
|
|
2156
|
+
return i > 0 && e.tanks[r].ammo[t.ammo] < i ? Y("out_of_ammo") : { ok: !0 };
|
|
2157
|
+
}
|
|
2158
|
+
function Qr(e, t, { maxTicks: n = 600 } = {}) {
|
|
2159
|
+
let r = e.players.indexOf(t.playerId), i = e.tanks[r], a = e.tanks[1 - r], o = Or(e.seed, e.ply), s = Kr(i, t.move ?? 0, {
|
|
1598
2160
|
heights: e.heights,
|
|
1599
2161
|
obstacles: e.obstacles,
|
|
1600
2162
|
others: [a]
|
|
@@ -1610,13 +2172,13 @@ function qn(e, t, { maxTicks: n = 600 } = {}) {
|
|
|
1610
2172
|
x: e.x,
|
|
1611
2173
|
y: e.y,
|
|
1612
2174
|
z: e.z
|
|
1613
|
-
}), u =
|
|
2175
|
+
}), u = Ur(c, t, {
|
|
1614
2176
|
wind: o,
|
|
1615
2177
|
heights: e.heights,
|
|
1616
2178
|
tanks: l,
|
|
1617
2179
|
obstacles: e.obstacles,
|
|
1618
2180
|
maxTicks: n
|
|
1619
|
-
}), d =
|
|
2181
|
+
}), d = Wr(u, l), f = {};
|
|
1620
2182
|
return e.players.forEach((e, t) => {
|
|
1621
2183
|
f[e] = d[t];
|
|
1622
2184
|
}), {
|
|
@@ -1627,11 +2189,11 @@ function qn(e, t, { maxTicks: n = 600 } = {}) {
|
|
|
1627
2189
|
tankAfter: c,
|
|
1628
2190
|
shots: u,
|
|
1629
2191
|
damage: f,
|
|
1630
|
-
craters:
|
|
2192
|
+
craters: Gr(u),
|
|
1631
2193
|
wind: o
|
|
1632
2194
|
};
|
|
1633
2195
|
}
|
|
1634
|
-
function
|
|
2196
|
+
function $r(e, t, n, r) {
|
|
1635
2197
|
return {
|
|
1636
2198
|
...e,
|
|
1637
2199
|
...r,
|
|
@@ -1642,7 +2204,7 @@ function G(e, t, n, r) {
|
|
|
1642
2204
|
revision: e.revision + 1
|
|
1643
2205
|
};
|
|
1644
2206
|
}
|
|
1645
|
-
function
|
|
2207
|
+
function ei(e, t) {
|
|
1646
2208
|
let n = e.turnIndex, r = {
|
|
1647
2209
|
playerId: t.playerId,
|
|
1648
2210
|
move: t.move,
|
|
@@ -1650,23 +2212,23 @@ function Jn(e, t) {
|
|
|
1650
2212
|
pitch: t.pitch,
|
|
1651
2213
|
power: t.power,
|
|
1652
2214
|
ammo: t.ammo
|
|
1653
|
-
}, i =
|
|
2215
|
+
}, i = Qr(e, r), a = e.heights;
|
|
1654
2216
|
if (i.craters.length) {
|
|
1655
2217
|
a = Int32Array.from(e.heights);
|
|
1656
|
-
for (let e of i.craters)
|
|
2218
|
+
for (let e of i.craters) Ir(a, e);
|
|
1657
2219
|
}
|
|
1658
|
-
let o = i.craters.length ?
|
|
2220
|
+
let o = i.craters.length ? Lr(e.decor, i.craters) : e.decor, s = e.tanks.map((e, t) => {
|
|
1659
2221
|
let o = t === n ? i.tankAfter : e, s = {
|
|
1660
2222
|
...e,
|
|
1661
2223
|
ammo: { ...e.ammo },
|
|
1662
2224
|
x: o.x,
|
|
1663
2225
|
z: o.z,
|
|
1664
|
-
y:
|
|
2226
|
+
y: q(a, o.x, o.z),
|
|
1665
2227
|
hp: Math.max(0, e.hp - i.damage[e.id])
|
|
1666
2228
|
};
|
|
1667
2229
|
if (t === n) {
|
|
1668
2230
|
s.fuel = e.fuel - i.fuelUsed, s.yaw = r.yaw, s.pitch = r.pitch, s.skips = 0;
|
|
1669
|
-
let t =
|
|
2231
|
+
let t = H[r.ammo].cost;
|
|
1670
2232
|
t > 0 && (s.ammo[r.ammo] -= t);
|
|
1671
2233
|
}
|
|
1672
2234
|
return s;
|
|
@@ -1685,23 +2247,23 @@ function Jn(e, t) {
|
|
|
1685
2247
|
...i
|
|
1686
2248
|
}
|
|
1687
2249
|
}, l = s.map((e) => e.hp === 0);
|
|
1688
|
-
if (l[0] && l[1]) return
|
|
1689
|
-
if (l[0] || l[1]) return
|
|
2250
|
+
if (l[0] && l[1]) return $r(c, -1, "destroyed");
|
|
2251
|
+
if (l[0] || l[1]) return $r(c, +!!l[0], "destroyed");
|
|
1690
2252
|
if (c.shots >= c.maxShots) {
|
|
1691
2253
|
let [e, t] = s.map((e) => e.hp);
|
|
1692
|
-
return
|
|
2254
|
+
return $r(c, e === t ? -1 : e > t ? 0 : 1, "max_shots");
|
|
1693
2255
|
}
|
|
1694
2256
|
return {
|
|
1695
2257
|
...c,
|
|
1696
2258
|
revision: e.revision + 1
|
|
1697
2259
|
};
|
|
1698
2260
|
}
|
|
1699
|
-
function
|
|
2261
|
+
function ti(e, t) {
|
|
1700
2262
|
if (!t || typeof t != "object") return e;
|
|
1701
|
-
if (t.type === "turn") return
|
|
1702
|
-
if (!
|
|
2263
|
+
if (t.type === "turn") return Zr(e, t).ok ? ei(e, t) : e;
|
|
2264
|
+
if (!Xr(e, t).ok) return e;
|
|
1703
2265
|
let n = e.players.indexOf(t.playerId);
|
|
1704
|
-
if (t.type === "resign") return
|
|
2266
|
+
if (t.type === "resign") return $r(e, 1 - n, "resign");
|
|
1705
2267
|
if (t.type === "skip") {
|
|
1706
2268
|
if (n !== e.turnIndex || t.reason !== void 0 && t.reason !== "timeout") return e;
|
|
1707
2269
|
let r = e.tanks[n].skips + 1, i = e.tanks.map((e, t) => t === n ? {
|
|
@@ -1718,22 +2280,22 @@ function Yn(e, t) {
|
|
|
1718
2280
|
playerId: t.playerId
|
|
1719
2281
|
}
|
|
1720
2282
|
};
|
|
1721
|
-
return r >= 3 ?
|
|
2283
|
+
return r >= 3 ? $r(a, 1 - n, "timeout") : {
|
|
1722
2284
|
...a,
|
|
1723
2285
|
revision: e.revision + 1
|
|
1724
2286
|
};
|
|
1725
2287
|
}
|
|
1726
2288
|
return e;
|
|
1727
2289
|
}
|
|
1728
|
-
function
|
|
2290
|
+
function ni(e, t) {
|
|
1729
2291
|
let n = (e.lo ^ t) >>> 0, r = n * 435, i = r >>> 0, a = (r - i) / 4294967296;
|
|
1730
2292
|
e.hi = Math.imul(e.hi, 435) + a + (n << 8) >>> 0, e.lo = i;
|
|
1731
2293
|
}
|
|
1732
|
-
function
|
|
2294
|
+
function ri(e, t) {
|
|
1733
2295
|
let n = t | 0;
|
|
1734
|
-
|
|
2296
|
+
ni(e, n & 255), ni(e, n >>> 8 & 255), ni(e, n >>> 16 & 255), ni(e, n >>> 24 & 255);
|
|
1735
2297
|
}
|
|
1736
|
-
function
|
|
2298
|
+
function ii(e) {
|
|
1737
2299
|
let t = {
|
|
1738
2300
|
hi: 3421674724,
|
|
1739
2301
|
lo: 2216829733
|
|
@@ -1750,11 +2312,11 @@ function Qn(e) {
|
|
|
1750
2312
|
];
|
|
1751
2313
|
for (let t of e.tanks) i.push(t.x, t.y, t.z, t.hp, t.fuel, t.ammo.heavy, t.ammo.cluster, t.skips, t.yaw, t.pitch);
|
|
1752
2314
|
i.push(n, e.decor.length);
|
|
1753
|
-
for (let e of i)
|
|
2315
|
+
for (let e of i) ri(t, e);
|
|
1754
2316
|
return t.hi.toString(16).padStart(8, "0") + t.lo.toString(16).padStart(8, "0");
|
|
1755
2317
|
}
|
|
1756
2318
|
// src/games/tanks/net/sha256.js
|
|
1757
|
-
var
|
|
2319
|
+
var ai = new Uint32Array([
|
|
1758
2320
|
1116352408,
|
|
1759
2321
|
1899447441,
|
|
1760
2322
|
3049323471,
|
|
@@ -1819,8 +2381,8 @@ var $n = new Uint32Array([
|
|
|
1819
2381
|
2756734187,
|
|
1820
2382
|
3204031479,
|
|
1821
2383
|
3329325298
|
|
1822
|
-
]),
|
|
1823
|
-
function
|
|
2384
|
+
]), X = (e, t) => e >>> t | e << 32 - t;
|
|
2385
|
+
function oi(e) {
|
|
1824
2386
|
let t = new TextEncoder().encode(String(e)), n = t.length, r = new Uint8Array((n + 9 >> 6) + 1 << 6);
|
|
1825
2387
|
r.set(t), r[n] = 128;
|
|
1826
2388
|
let i = new DataView(r.buffer);
|
|
@@ -1838,12 +2400,12 @@ function er(e) {
|
|
|
1838
2400
|
for (let e = 0; e < r.length; e += 64) {
|
|
1839
2401
|
for (let t = 0; t < 16; t += 1) o[t] = i.getUint32(e + t * 4);
|
|
1840
2402
|
for (let e = 16; e < 64; e += 1) {
|
|
1841
|
-
let t =
|
|
2403
|
+
let t = X(o[e - 15], 7) ^ X(o[e - 15], 18) ^ o[e - 15] >>> 3, n = X(o[e - 2], 17) ^ X(o[e - 2], 19) ^ o[e - 2] >>> 10;
|
|
1842
2404
|
o[e] = o[e - 16] + t + o[e - 7] + n >>> 0;
|
|
1843
2405
|
}
|
|
1844
2406
|
let [t, n, r, s, c, l, u, d] = a;
|
|
1845
2407
|
for (let e = 0; e < 64; e += 1) {
|
|
1846
|
-
let i = d + (
|
|
2408
|
+
let i = d + (X(c, 6) ^ X(c, 11) ^ X(c, 25)) + (c & l ^ ~c & u) + ai[e] + o[e] >>> 0, a = (X(t, 2) ^ X(t, 13) ^ X(t, 22)) + (t & n ^ t & r ^ n & r) >>> 0;
|
|
1847
2409
|
d = u, u = l, l = c, c = s + i >>> 0, s = r, r = n, n = t, t = i + a >>> 0;
|
|
1848
2410
|
}
|
|
1849
2411
|
a[0] += t, a[1] += n, a[2] += r, a[3] += s, a[4] += c, a[5] += l, a[6] += u, a[7] += d;
|
|
@@ -1851,22 +2413,22 @@ function er(e) {
|
|
|
1851
2413
|
return Array.from(a, (e) => e.toString(16).padStart(8, "0")).join("");
|
|
1852
2414
|
}
|
|
1853
2415
|
// src/games/tanks/net/session.js
|
|
1854
|
-
var
|
|
2416
|
+
var si = "La partida perdió sincronización. Se intentará resincronizar.", ci = "Falta la aceptación de la partida. Ciérrala y vuelve a invitar.", li = "El rival reveló una semilla que no coincide con su invitación.", ui = "Los resultados del disparo no coinciden entre dispositivos.", di = [
|
|
1855
2417
|
"won",
|
|
1856
2418
|
"draw",
|
|
1857
2419
|
"closed",
|
|
1858
2420
|
"declined"
|
|
1859
|
-
],
|
|
2421
|
+
], fi = (e, t) => ({
|
|
1860
2422
|
...e,
|
|
1861
2423
|
status: "conflict",
|
|
1862
2424
|
error: t
|
|
1863
|
-
}),
|
|
1864
|
-
function
|
|
2425
|
+
}), pi = (e) => Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
2426
|
+
function mi() {
|
|
1865
2427
|
let e = /* @__PURE__ */ new Uint8Array(16);
|
|
1866
|
-
return globalThis.crypto.getRandomValues(e),
|
|
2428
|
+
return globalThis.crypto.getRandomValues(e), pi(e);
|
|
1867
2429
|
}
|
|
1868
|
-
var
|
|
1869
|
-
function
|
|
2430
|
+
var hi = (e) => oi(`lira-tanks-seed:${e}`), gi = (e, t) => parseInt(oi(`lira-tanks-map:${e}:${t}`).slice(0, 8), 16) >>> 0;
|
|
2431
|
+
function _i(e, t) {
|
|
1870
2432
|
let n = t.first_player_id === e.guestId ? e.guestId : e.hostId;
|
|
1871
2433
|
return {
|
|
1872
2434
|
...e,
|
|
@@ -1893,21 +2455,21 @@ function ur(e, t) {
|
|
|
1893
2455
|
sync: e.sync ?? null
|
|
1894
2456
|
};
|
|
1895
2457
|
}
|
|
1896
|
-
var
|
|
2458
|
+
var Z = (e) => [e.hostId, e.guestId], vi = (e) => e.logic && e.logic.phase === "playing" ? Z(e)[e.logic.turnIndex] : null, yi = (e) => e?.status === "active" && !e.pendingEvent && vi(e) === e.ownId, bi = (e, t, n) => e === "tk_turn" ? [
|
|
1897
2459
|
1,
|
|
1898
2460
|
t.move,
|
|
1899
2461
|
t.yaw,
|
|
1900
2462
|
t.pitch,
|
|
1901
2463
|
t.power,
|
|
1902
2464
|
t.ammo
|
|
1903
|
-
] : e === "tk_skip" ? [2] : [3, n],
|
|
1904
|
-
function
|
|
1905
|
-
let n =
|
|
2465
|
+
] : e === "tk_skip" ? [2] : [3, n], xi = (e, t) => e.length === t.length && e.every((e, n) => e === t[n]);
|
|
2466
|
+
function Si(e, t) {
|
|
2467
|
+
let n = Z(e);
|
|
1906
2468
|
if (t[0] === 3) return {
|
|
1907
2469
|
type: "resign",
|
|
1908
2470
|
playerId: n[t[1]]
|
|
1909
2471
|
};
|
|
1910
|
-
let r =
|
|
2472
|
+
let r = vi(e);
|
|
1911
2473
|
return t[0] === 2 ? {
|
|
1912
2474
|
type: "skip",
|
|
1913
2475
|
playerId: r,
|
|
@@ -1919,11 +2481,11 @@ function hr(e, t) {
|
|
|
1919
2481
|
yaw: t[2],
|
|
1920
2482
|
pitch: t[3],
|
|
1921
2483
|
power: t[4],
|
|
1922
|
-
ammo:
|
|
2484
|
+
ammo: vt[t[5]]
|
|
1923
2485
|
};
|
|
1924
2486
|
}
|
|
1925
|
-
function
|
|
1926
|
-
let i =
|
|
2487
|
+
function Ci(e, t, n, r) {
|
|
2488
|
+
let i = ti(e.logic, Si(e, t));
|
|
1927
2489
|
if (i === e.logic) return null;
|
|
1928
2490
|
let a = i.phase === "finished";
|
|
1929
2491
|
return {
|
|
@@ -1938,19 +2500,19 @@ function gr(e, t, n, r) {
|
|
|
1938
2500
|
author: r,
|
|
1939
2501
|
turn: i.lastTurn ?? null
|
|
1940
2502
|
},
|
|
1941
|
-
turnId: a ? null :
|
|
2503
|
+
turnId: a ? null : Z(e)[i.turnIndex],
|
|
1942
2504
|
status: a ? i.result === "draw" ? "draw" : "won" : "active",
|
|
1943
2505
|
winnerId: i.winnerId ?? null,
|
|
1944
2506
|
result: i.result ?? null
|
|
1945
2507
|
};
|
|
1946
2508
|
}
|
|
1947
|
-
function
|
|
1948
|
-
if (
|
|
1949
|
-
let r =
|
|
2509
|
+
function wi(e, t, n) {
|
|
2510
|
+
if (hi(t) !== e.seedCommit) return null;
|
|
2511
|
+
let r = Yr({
|
|
1950
2512
|
gameId: e.gameId,
|
|
1951
|
-
players:
|
|
2513
|
+
players: Z(e),
|
|
1952
2514
|
firstPlayerId: e.firstPlayerId,
|
|
1953
|
-
seed:
|
|
2515
|
+
seed: gi(t, e.seedB)
|
|
1954
2516
|
});
|
|
1955
2517
|
return {
|
|
1956
2518
|
...e,
|
|
@@ -1962,11 +2524,11 @@ function _r(e, t, n) {
|
|
|
1962
2524
|
lastEventId: n,
|
|
1963
2525
|
lastAction: null,
|
|
1964
2526
|
status: "active",
|
|
1965
|
-
turnId:
|
|
2527
|
+
turnId: Z(e)[r.turnIndex],
|
|
1966
2528
|
error: ""
|
|
1967
2529
|
};
|
|
1968
2530
|
}
|
|
1969
|
-
function
|
|
2531
|
+
function Ti(e, t, n) {
|
|
1970
2532
|
if (![e.hostId, e.guestId].includes(n)) return e;
|
|
1971
2533
|
let r = t.data;
|
|
1972
2534
|
if (t.type === "game_end") return ["closed", "declined"].includes(e.status) ? e : {
|
|
@@ -1975,7 +2537,7 @@ function vr(e, t, n) {
|
|
|
1975
2537
|
closedBy: n,
|
|
1976
2538
|
error: ""
|
|
1977
2539
|
};
|
|
1978
|
-
if (
|
|
2540
|
+
if (di.includes(e.status) || e.status === "conflict") return e;
|
|
1979
2541
|
if (t.type === "game_accept" || t.type === "game_decline") return n !== e.guestId || e.status !== "invited" || r.invite_event_id !== e.inviteEventId ? e : t.type === "game_decline" ? {
|
|
1980
2542
|
...e,
|
|
1981
2543
|
status: "declined",
|
|
@@ -1987,22 +2549,22 @@ function vr(e, t, n) {
|
|
|
1987
2549
|
acceptEventId: t.event_id,
|
|
1988
2550
|
lastEventId: t.event_id
|
|
1989
2551
|
};
|
|
1990
|
-
if (t.type === "tk_seed") return n !== e.hostId || e.status !== "seeding" ? e :
|
|
2552
|
+
if (t.type === "tk_seed") return n !== e.hostId || e.status !== "seeding" ? e : wi(e, r.seed_a, t.event_id) ?? fi(e, li);
|
|
1991
2553
|
if (![
|
|
1992
2554
|
"tk_turn",
|
|
1993
2555
|
"tk_skip",
|
|
1994
2556
|
"tk_resign"
|
|
1995
2557
|
].includes(t.type)) return e;
|
|
1996
|
-
if (e.status !== "active") return
|
|
1997
|
-
let i =
|
|
1998
|
-
if (r.ply <= e.ply) return
|
|
1999
|
-
if (r.ply > e.ply + 1 || r.prev_event_id !== e.lastEventId) return
|
|
2000
|
-
if (t.type !== "tk_resign" && n !==
|
|
2001
|
-
let o =
|
|
2002
|
-
return o ? t.type === "tk_turn" &&
|
|
2003
|
-
}
|
|
2004
|
-
function
|
|
2005
|
-
if (!
|
|
2558
|
+
if (e.status !== "active") return fi(e, ci);
|
|
2559
|
+
let i = Z(e).indexOf(n), a = bi(t.type, r, i);
|
|
2560
|
+
if (r.ply <= e.ply) return xi(e.log[r.ply - 1] ?? [], a) ? e : fi(e, si);
|
|
2561
|
+
if (r.ply > e.ply + 1 || r.prev_event_id !== e.lastEventId) return fi(e, si);
|
|
2562
|
+
if (t.type !== "tk_resign" && n !== vi(e)) return e;
|
|
2563
|
+
let o = Ci(e, a, t.event_id, n);
|
|
2564
|
+
return o ? t.type === "tk_turn" && ii(o.logic) !== r.hash ? fi(e, ui) : o : e;
|
|
2565
|
+
}
|
|
2566
|
+
function Ei(e, t) {
|
|
2567
|
+
if (!yi(e)) return null;
|
|
2006
2568
|
let n = {
|
|
2007
2569
|
ply: e.ply + 1,
|
|
2008
2570
|
prev_event_id: e.lastEventId,
|
|
@@ -2010,16 +2572,16 @@ function yr(e, t) {
|
|
|
2010
2572
|
yaw: t.yaw,
|
|
2011
2573
|
pitch: t.pitch,
|
|
2012
2574
|
power: t.power,
|
|
2013
|
-
ammo:
|
|
2575
|
+
ammo: vt.indexOf(t.ammo)
|
|
2014
2576
|
};
|
|
2015
2577
|
if (n.ammo < 0) return null;
|
|
2016
|
-
let r =
|
|
2578
|
+
let r = Ci(e, bi("tk_turn", n), "local", e.ownId);
|
|
2017
2579
|
return r ? {
|
|
2018
2580
|
...n,
|
|
2019
|
-
hash:
|
|
2581
|
+
hash: ii(r.logic)
|
|
2020
2582
|
} : null;
|
|
2021
2583
|
}
|
|
2022
|
-
function
|
|
2584
|
+
function Di(e) {
|
|
2023
2585
|
let t = {
|
|
2024
2586
|
log: e.log ?? [],
|
|
2025
2587
|
head: e.lastEventId
|
|
@@ -2032,14 +2594,14 @@ function br(e) {
|
|
|
2032
2594
|
seed_event_id: e.seedEventId
|
|
2033
2595
|
}), t;
|
|
2034
2596
|
}
|
|
2035
|
-
function
|
|
2597
|
+
function Oi(e, t) {
|
|
2036
2598
|
if (e.accept_event_id && t.accept_event_id && e.accept_event_id !== t.accept_event_id || e.seed_a && t.seed_a && e.seed_a !== t.seed_a) return "diverged";
|
|
2037
2599
|
let n = Math.min(e.log.length, t.log.length);
|
|
2038
|
-
for (let r = 0; r < n; r += 1) if (!
|
|
2600
|
+
for (let r = 0; r < n; r += 1) if (!xi(e.log[r], t.log[r])) return "diverged";
|
|
2039
2601
|
let r = (e) => (e.seed_a ? 2 : +!!e.accept_event_id) * 1e3 + e.log.length;
|
|
2040
2602
|
return r(e) === r(t) ? e.log.length === t.log.length && e.head !== t.head && e.log.length > 0 ? "diverged" : "equal" : r(e) < r(t) ? "behind" : "ahead";
|
|
2041
2603
|
}
|
|
2042
|
-
function
|
|
2604
|
+
function ki(e, t) {
|
|
2043
2605
|
let n = {
|
|
2044
2606
|
...e,
|
|
2045
2607
|
status: "invited",
|
|
@@ -2069,16 +2631,16 @@ function Sr(e, t) {
|
|
|
2069
2631
|
seedB: t.seed_b,
|
|
2070
2632
|
lastEventId: t.accept_event_id
|
|
2071
2633
|
}, !t.seed_a) return n;
|
|
2072
|
-
if (n =
|
|
2634
|
+
if (n = wi(n, t.seed_a, t.seed_event_id), !n) return null;
|
|
2073
2635
|
for (let e = 0; e < t.log.length; e += 1) {
|
|
2074
2636
|
let r = t.log[e];
|
|
2075
|
-
if (!
|
|
2076
|
-
let i = e === t.log.length - 1, a = r[0] === 3 ?
|
|
2077
|
-
if (n =
|
|
2637
|
+
if (!xt(r)) return null;
|
|
2638
|
+
let i = e === t.log.length - 1, a = r[0] === 3 ? Z(n)[r[1]] : vi(n);
|
|
2639
|
+
if (n = Ci(n, r, i ? t.head : `${t.seed_event_id}:${e + 1}`, a), !n) return null;
|
|
2078
2640
|
}
|
|
2079
2641
|
return n;
|
|
2080
2642
|
}
|
|
2081
|
-
function
|
|
2643
|
+
function Ai(e, t) {
|
|
2082
2644
|
if (!t) return !1;
|
|
2083
2645
|
if (t.type === "tk_seed") return e.seed_a === t.data.seed_a;
|
|
2084
2646
|
if (t.type === "game_accept") return e.accept_event_id === t.event_id;
|
|
@@ -2088,9 +2650,9 @@ function Cr(e, t) {
|
|
|
2088
2650
|
"tk_resign"
|
|
2089
2651
|
].includes(t.type)) return !1;
|
|
2090
2652
|
let n = e.log[t.data.ply - 1];
|
|
2091
|
-
return !!n && n[0] ===
|
|
2653
|
+
return !!n && n[0] === bi(t.type, t.data, 0)[0];
|
|
2092
2654
|
}
|
|
2093
|
-
function
|
|
2655
|
+
function ji(e, t) {
|
|
2094
2656
|
let n = { ...e };
|
|
2095
2657
|
return [
|
|
2096
2658
|
t.acceptEventId,
|
|
@@ -2100,7 +2662,7 @@ function wr(e, t) {
|
|
|
2100
2662
|
e && (n[e] = !0);
|
|
2101
2663
|
}), n;
|
|
2102
2664
|
}
|
|
2103
|
-
function
|
|
2665
|
+
function Mi(e) {
|
|
2104
2666
|
return {
|
|
2105
2667
|
gameId: e.gameId,
|
|
2106
2668
|
roomId: e.roomId,
|
|
@@ -2113,22 +2675,22 @@ function Tr(e) {
|
|
|
2113
2675
|
inviteEventId: e.inviteEventId,
|
|
2114
2676
|
createdAt: e.createdAt,
|
|
2115
2677
|
status: e.status,
|
|
2116
|
-
...
|
|
2678
|
+
...Di(e)
|
|
2117
2679
|
};
|
|
2118
2680
|
}
|
|
2119
2681
|
// src/games/tanks/net/tankStorage.js
|
|
2120
|
-
var
|
|
2682
|
+
var Ni = "lira:tk:", Pi = 6048e5, Fi = 20, Ii = (e, t) => `${Ni}${e}:${t}`, Li = () => {
|
|
2121
2683
|
try {
|
|
2122
2684
|
return globalThis.localStorage ?? null;
|
|
2123
2685
|
} catch {
|
|
2124
2686
|
return null;
|
|
2125
2687
|
}
|
|
2126
2688
|
};
|
|
2127
|
-
function
|
|
2689
|
+
function Ri(e) {
|
|
2128
2690
|
let t = [];
|
|
2129
2691
|
for (let n = 0; n < e.length; n += 1) {
|
|
2130
2692
|
let r = e.key(n);
|
|
2131
|
-
if (r?.startsWith(
|
|
2693
|
+
if (r?.startsWith(Ni)) try {
|
|
2132
2694
|
let n = JSON.parse(e.getItem(r));
|
|
2133
2695
|
t.push({
|
|
2134
2696
|
key: r,
|
|
@@ -2143,61 +2705,61 @@ function jr(e) {
|
|
|
2143
2705
|
}
|
|
2144
2706
|
return t;
|
|
2145
2707
|
}
|
|
2146
|
-
function
|
|
2147
|
-
let t = Date.now(), n =
|
|
2148
|
-
n.filter(({ value: e }) => !e || !(t - e.savedAt <
|
|
2149
|
-
let r = n.filter(({ value: e }) => e && t - e.savedAt <
|
|
2150
|
-
r.slice(0, Math.max(0, r.length -
|
|
2708
|
+
function zi(e) {
|
|
2709
|
+
let t = Date.now(), n = Ri(e);
|
|
2710
|
+
n.filter(({ value: e }) => !e || !(t - e.savedAt < Pi)).forEach(({ key: t }) => e.removeItem(t));
|
|
2711
|
+
let r = n.filter(({ value: e }) => e && t - e.savedAt < Pi).sort((e, t) => e.value.savedAt - t.value.savedAt);
|
|
2712
|
+
r.slice(0, Math.max(0, r.length - Fi)).forEach(({ key: t }) => e.removeItem(t));
|
|
2151
2713
|
}
|
|
2152
|
-
function
|
|
2714
|
+
function Bi(e, t, n) {
|
|
2153
2715
|
try {
|
|
2154
|
-
let r =
|
|
2716
|
+
let r = Li();
|
|
2155
2717
|
if (!r) return !1;
|
|
2156
|
-
let i =
|
|
2157
|
-
return r.setItem(
|
|
2718
|
+
let i = Vi(e, t) ?? {};
|
|
2719
|
+
return r.setItem(Ii(e, t), JSON.stringify({
|
|
2158
2720
|
...i,
|
|
2159
2721
|
...n,
|
|
2160
2722
|
savedAt: Date.now()
|
|
2161
|
-
})),
|
|
2723
|
+
})), zi(r), !0;
|
|
2162
2724
|
} catch {
|
|
2163
2725
|
return !1;
|
|
2164
2726
|
}
|
|
2165
2727
|
}
|
|
2166
|
-
function
|
|
2728
|
+
function Vi(e, t) {
|
|
2167
2729
|
try {
|
|
2168
|
-
let n = JSON.parse(
|
|
2169
|
-
return !n || typeof n != "object" || !(Date.now() - n.savedAt <
|
|
2730
|
+
let n = JSON.parse(Li()?.getItem(Ii(e, t)) ?? "null");
|
|
2731
|
+
return !n || typeof n != "object" || !(Date.now() - n.savedAt < Pi) || n.seedA !== void 0 && !/^[0-9a-f]{32}$/.test(n.seedA) ? null : n;
|
|
2170
2732
|
} catch {
|
|
2171
2733
|
return null;
|
|
2172
2734
|
}
|
|
2173
2735
|
}
|
|
2174
|
-
function
|
|
2736
|
+
function Hi(e) {
|
|
2175
2737
|
try {
|
|
2176
|
-
let t =
|
|
2177
|
-
return t ?
|
|
2738
|
+
let t = Li();
|
|
2739
|
+
return t ? Ri(t).filter(({ key: t, value: n }) => t.startsWith(`${Ni}${e}:`) && n?.snapshot && Date.now() - n.savedAt < Pi).map(({ value: e }) => e).sort((e, t) => t.savedAt - e.savedAt) : [];
|
|
2178
2740
|
} catch {
|
|
2179
2741
|
return [];
|
|
2180
2742
|
}
|
|
2181
2743
|
}
|
|
2182
2744
|
// src/games/shared/useChatGames.js
|
|
2183
|
-
var
|
|
2745
|
+
var Ui = Vt, Q = (e) => e?.game ?? "connect4", Wi = (e) => Q(e) === "battleship", Gi = (e) => Q(e) === "tanks", Ki = (e) => ["tanks_live", "racing_live"].includes(Q(e)), qi = 250, $ = (e) => [
|
|
2184
2746
|
"won",
|
|
2185
2747
|
"draw",
|
|
2186
2748
|
"closed",
|
|
2187
2749
|
"declined"
|
|
2188
|
-
].includes(e.status),
|
|
2750
|
+
].includes(e.status), Ji = (e, t, n) => JSON.stringify([
|
|
2189
2751
|
e,
|
|
2190
2752
|
String(t),
|
|
2191
2753
|
n
|
|
2192
|
-
]),
|
|
2193
|
-
let t = Object.keys(e).filter((t) =>
|
|
2754
|
+
]), Yi = (e) => {
|
|
2755
|
+
let t = Object.keys(e).filter((t) => $(e[t]));
|
|
2194
2756
|
if (t.length <= 80) return e;
|
|
2195
2757
|
let n = { ...e };
|
|
2196
2758
|
return t.slice(0, t.length - 80).forEach((e) => {
|
|
2197
2759
|
delete n[e];
|
|
2198
2760
|
}), n;
|
|
2199
2761
|
};
|
|
2200
|
-
function
|
|
2762
|
+
function Xi(e, t, n) {
|
|
2201
2763
|
if (![e.hostId, e.guestId].includes(n)) return e;
|
|
2202
2764
|
if (t.type === "game_end" && t.data.reason === "closed") return ["closed", "declined"].includes(e.status) ? e : {
|
|
2203
2765
|
...e,
|
|
@@ -2205,7 +2767,7 @@ function Hr(e, t, n) {
|
|
|
2205
2767
|
closedBy: n,
|
|
2206
2768
|
error: ""
|
|
2207
2769
|
};
|
|
2208
|
-
if (
|
|
2770
|
+
if ($(e) || e.status === "conflict") return e;
|
|
2209
2771
|
if (t.type === "game_accept" || t.type === "game_decline") return n !== e.guestId || e.status !== "invited" || t.data.invite_event_id !== e.inviteEventId ? e : {
|
|
2210
2772
|
...e,
|
|
2211
2773
|
status: t.type === "game_accept" ? "active" : "declined",
|
|
@@ -2226,7 +2788,7 @@ function Hr(e, t, n) {
|
|
|
2226
2788
|
error: "La partida perdió sincronización. Ciérrala y envía una nueva invitación."
|
|
2227
2789
|
};
|
|
2228
2790
|
if (n !== e.turnId) return e;
|
|
2229
|
-
let o =
|
|
2791
|
+
let o = Xt(e.board, a, n);
|
|
2230
2792
|
return o ? {
|
|
2231
2793
|
...e,
|
|
2232
2794
|
board: o.board,
|
|
@@ -2244,7 +2806,7 @@ function Hr(e, t, n) {
|
|
|
2244
2806
|
turnId: n === e.hostId ? e.guestId : e.hostId
|
|
2245
2807
|
} : e;
|
|
2246
2808
|
}
|
|
2247
|
-
var
|
|
2809
|
+
var Zi = 8e3, Qi = {
|
|
2248
2810
|
status: "idle",
|
|
2249
2811
|
requestId: null,
|
|
2250
2812
|
requestedAt: 0,
|
|
@@ -2253,14 +2815,14 @@ var Ur = 8e3, Q = {
|
|
|
2253
2815
|
replies: [],
|
|
2254
2816
|
offer: null,
|
|
2255
2817
|
message: ""
|
|
2256
|
-
},
|
|
2818
|
+
}, $i = (e) => [
|
|
2257
2819
|
"game_resync_request",
|
|
2258
2820
|
"game_resync_state",
|
|
2259
2821
|
"bs_sync_request",
|
|
2260
2822
|
"bs_sync_state",
|
|
2261
2823
|
"tk_sync_request",
|
|
2262
2824
|
"tk_sync_state"
|
|
2263
|
-
].includes(e),
|
|
2825
|
+
].includes(e), ea = (e) => e.acceptEventId ? {
|
|
2264
2826
|
accept_event_id: e.acceptEventId,
|
|
2265
2827
|
moves: e.moves ?? [],
|
|
2266
2828
|
rev: (e.moves ?? []).length
|
|
@@ -2268,10 +2830,10 @@ var Ur = 8e3, Q = {
|
|
|
2268
2830
|
moves: [],
|
|
2269
2831
|
rev: 0
|
|
2270
2832
|
};
|
|
2271
|
-
function
|
|
2833
|
+
function ta(e, t, n) {
|
|
2272
2834
|
let r = {
|
|
2273
2835
|
...e,
|
|
2274
|
-
board:
|
|
2836
|
+
board: Gt(),
|
|
2275
2837
|
ply: 0,
|
|
2276
2838
|
turnId: e.hostId,
|
|
2277
2839
|
winnerId: null,
|
|
@@ -2297,7 +2859,7 @@ function Kr(e, t, n) {
|
|
|
2297
2859
|
let [r, o] = n[t];
|
|
2298
2860
|
if (a.has(o)) return null;
|
|
2299
2861
|
a.add(o);
|
|
2300
|
-
let s = t % 2 == 0 ? e.hostId : e.guestId, c =
|
|
2862
|
+
let s = t % 2 == 0 ? e.hostId : e.guestId, c = Xi(i, {
|
|
2301
2863
|
type: "game_move",
|
|
2302
2864
|
event_id: o,
|
|
2303
2865
|
data: {
|
|
@@ -2311,18 +2873,18 @@ function Kr(e, t, n) {
|
|
|
2311
2873
|
}
|
|
2312
2874
|
return i;
|
|
2313
2875
|
}
|
|
2314
|
-
function
|
|
2876
|
+
function na(e, t) {
|
|
2315
2877
|
if (e.acceptEventId && t.acceptEventId && e.acceptEventId !== t.acceptEventId) return "diverged";
|
|
2316
2878
|
let n = Math.min(e.moves.length, t.moves.length);
|
|
2317
2879
|
for (let r = 0; r < n; r += 1) if (e.moves[r][0] !== t.moves[r][0] || e.moves[r][1] !== t.moves[r][1]) return "diverged";
|
|
2318
2880
|
return e.moves.length === t.moves.length ? e.acceptEventId && !t.acceptEventId ? "ahead" : !e.acceptEventId && t.acceptEventId ? "behind" : "equal" : e.moves.length < t.moves.length ? "behind" : "ahead";
|
|
2319
2881
|
}
|
|
2320
|
-
var
|
|
2882
|
+
var ra = (e) => e.pendingEvent?.type === "game_move" && !e.pending ? e.pendingEvent.event_id : null, ia = {
|
|
2321
2883
|
requestType: "game_resync_request",
|
|
2322
2884
|
stateType: "game_resync_state",
|
|
2323
|
-
historyOf:
|
|
2324
|
-
rebuild: (e, t) =>
|
|
2325
|
-
compare: (e, t) =>
|
|
2885
|
+
historyOf: ea,
|
|
2886
|
+
rebuild: (e, t) => ta(e, t.accept_event_id ?? null, t.moves),
|
|
2887
|
+
compare: (e, t) => na({
|
|
2326
2888
|
acceptEventId: e.acceptEventId ?? null,
|
|
2327
2889
|
moves: e.moves ?? []
|
|
2328
2890
|
}, {
|
|
@@ -2334,7 +2896,7 @@ var Jr = (e) => e.pendingEvent?.type === "game_move" && !e.pending ? e.pendingEv
|
|
|
2334
2896
|
moves: e.moves
|
|
2335
2897
|
}),
|
|
2336
2898
|
covers: (e, t) => {
|
|
2337
|
-
let n =
|
|
2899
|
+
let n = ra(e);
|
|
2338
2900
|
return !!(n && t.moves?.some((e) => e[1] === n));
|
|
2339
2901
|
},
|
|
2340
2902
|
markSeen: (e, t) => {
|
|
@@ -2344,40 +2906,40 @@ var Jr = (e) => e.pendingEvent?.type === "game_move" && !e.pending ? e.pendingEv
|
|
|
2344
2906
|
}), n;
|
|
2345
2907
|
},
|
|
2346
2908
|
merge: () => null
|
|
2347
|
-
},
|
|
2909
|
+
}, aa = (e) => ({
|
|
2348
2910
|
requestType: "bs_sync_request",
|
|
2349
2911
|
stateType: "bs_sync_state",
|
|
2350
|
-
historyOf:
|
|
2351
|
-
rebuild: (t, n) =>
|
|
2352
|
-
compare: (e, t) =>
|
|
2912
|
+
historyOf: Zn,
|
|
2913
|
+
rebuild: (t, n) => er(t, n, { stored: e(t.scope, t.gameId) }),
|
|
2914
|
+
compare: (e, t) => Qn(Zn(e), t),
|
|
2353
2915
|
offerOf: (e) => ({
|
|
2354
2916
|
accept_event_id: e.accept_event_id,
|
|
2355
2917
|
commits: e.commits,
|
|
2356
2918
|
log: e.log,
|
|
2357
2919
|
head: e.head
|
|
2358
2920
|
}),
|
|
2359
|
-
covers: (e, t) => !!(e.pendingEvent && !e.pending &&
|
|
2360
|
-
markSeen:
|
|
2361
|
-
merge: (e, t) =>
|
|
2362
|
-
}),
|
|
2921
|
+
covers: (e, t) => !!(e.pendingEvent && !e.pending && tr(t, e.pendingEvent)),
|
|
2922
|
+
markSeen: nr,
|
|
2923
|
+
merge: (e, t) => $n(Zn(e), t)
|
|
2924
|
+
}), oa = {
|
|
2363
2925
|
requestType: "tk_sync_request",
|
|
2364
2926
|
stateType: "tk_sync_state",
|
|
2365
|
-
historyOf:
|
|
2366
|
-
rebuild:
|
|
2367
|
-
compare: (e, t) =>
|
|
2927
|
+
historyOf: Di,
|
|
2928
|
+
rebuild: ki,
|
|
2929
|
+
compare: (e, t) => Oi(Di(e), t),
|
|
2368
2930
|
offerOf: (e) => ({
|
|
2369
2931
|
...e,
|
|
2370
2932
|
request_event_id: void 0
|
|
2371
2933
|
}),
|
|
2372
|
-
covers: (e, t) => !!(e.pendingEvent && !e.pending &&
|
|
2373
|
-
markSeen:
|
|
2934
|
+
covers: (e, t) => !!(e.pendingEvent && !e.pending && Ai(t, e.pendingEvent)),
|
|
2935
|
+
markSeen: ji,
|
|
2374
2936
|
merge: () => null
|
|
2375
|
-
},
|
|
2937
|
+
}, sa = (e) => ({
|
|
2376
2938
|
...e,
|
|
2377
2939
|
game: "connect4",
|
|
2378
2940
|
turnId: e.hostId,
|
|
2379
2941
|
status: "invited",
|
|
2380
|
-
board:
|
|
2942
|
+
board: Gt(),
|
|
2381
2943
|
ply: 0,
|
|
2382
2944
|
winnerId: null,
|
|
2383
2945
|
lastMove: null,
|
|
@@ -2386,40 +2948,40 @@ var Jr = (e) => e.pendingEvent?.type === "game_move" && !e.pending ? e.pendingEv
|
|
|
2386
2948
|
pendingEvent: null,
|
|
2387
2949
|
acceptEventId: null,
|
|
2388
2950
|
moves: []
|
|
2389
|
-
}),
|
|
2951
|
+
}), ca = (e, t, n) => F(t, {
|
|
2390
2952
|
game_id: e.gameId,
|
|
2391
2953
|
data: n,
|
|
2392
|
-
game:
|
|
2954
|
+
game: Q(e)
|
|
2393
2955
|
});
|
|
2394
|
-
function
|
|
2395
|
-
let e = null, t = /* @__PURE__ */ new Map(), n = (e, n) => t.get(`${e}:${n}`) ??
|
|
2956
|
+
function la() {
|
|
2957
|
+
let e = null, t = /* @__PURE__ */ new Map(), n = (e, n) => t.get(`${e}:${n}`) ?? ur(e, n), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = aa(n), c = /* @__PURE__ */ new Map(), l = (e, t) => c.get(`${e}:${t}`) ?? Vi(e, t)?.seedA ?? null, u = {
|
|
2396
2958
|
connect4: {
|
|
2397
|
-
create: (e) =>
|
|
2398
|
-
apply: (e, t, n) =>
|
|
2399
|
-
sync:
|
|
2959
|
+
create: (e) => sa(e),
|
|
2960
|
+
apply: (e, t, n) => Xi(e, t, n),
|
|
2961
|
+
sync: ia
|
|
2400
2962
|
},
|
|
2401
2963
|
battleship: {
|
|
2402
|
-
create: (e) =>
|
|
2403
|
-
apply: (e, t, r, i) =>
|
|
2964
|
+
create: (e) => _n(e),
|
|
2965
|
+
apply: (e, t, r, i) => qn(e, t, r, { stored: t.type === "bs_commit" && r === i ? n(e.scope, e.gameId) : null }),
|
|
2404
2966
|
sync: s,
|
|
2405
2967
|
after: (e, t) => t().bsScheduleEffects(e)
|
|
2406
2968
|
},
|
|
2407
2969
|
racing_live: {
|
|
2408
|
-
create: (e, t) =>
|
|
2409
|
-
apply:
|
|
2970
|
+
create: (e, t) => st(e, t.data),
|
|
2971
|
+
apply: ct
|
|
2410
2972
|
},
|
|
2411
2973
|
tanks_live: {
|
|
2412
|
-
create: (e, t) =>
|
|
2413
|
-
apply:
|
|
2974
|
+
create: (e, t) => Ze(e, t.data),
|
|
2975
|
+
apply: Qe
|
|
2414
2976
|
},
|
|
2415
2977
|
tanks: {
|
|
2416
|
-
create: (e, t) =>
|
|
2417
|
-
apply: (e, t, n) =>
|
|
2418
|
-
sync:
|
|
2978
|
+
create: (e, t) => _i(e, t.data),
|
|
2979
|
+
apply: (e, t, n) => Ti(e, t, n),
|
|
2980
|
+
sync: oa,
|
|
2419
2981
|
after: (e, t) => t().tkScheduleEffects(e)
|
|
2420
2982
|
}
|
|
2421
|
-
},
|
|
2422
|
-
return
|
|
2983
|
+
}, d = (e) => u[Q(e)] ?? null, f = (e) => d(e)?.sync ?? ia;
|
|
2984
|
+
return p((s, p) => ({
|
|
2423
2985
|
games: {},
|
|
2424
2986
|
configureTransport: (t) => {
|
|
2425
2987
|
e = t;
|
|
@@ -2427,12 +2989,12 @@ function ei() {
|
|
|
2427
2989
|
clear: () => {
|
|
2428
2990
|
r.forEach((e) => clearTimeout(e)), r.clear(), o.forEach((e) => clearTimeout(e)), o.clear(), t.clear(), c.clear(), i.clear(), a.clear(), s({ games: {} });
|
|
2429
2991
|
},
|
|
2430
|
-
markDisconnected: (e) => s((t) => ({ games: Object.fromEntries(Object.entries(t.games).map(([t, n]) => [t, n.scope === e && !
|
|
2992
|
+
markDisconnected: (e) => s((t) => ({ games: Object.fromEntries(Object.entries(t.games).map(([t, n]) => [t, n.scope === e && !Ki(n) && !$(n) ? {
|
|
2431
2993
|
...n,
|
|
2432
2994
|
status: "conflict",
|
|
2433
2995
|
error: "Conexión interrumpida. Se intentará resincronizar al reconectar.",
|
|
2434
2996
|
sync: {
|
|
2435
|
-
...
|
|
2997
|
+
...Qi,
|
|
2436
2998
|
...n.sync,
|
|
2437
2999
|
status: "idle",
|
|
2438
3000
|
auto: !1
|
|
@@ -2442,19 +3004,19 @@ function ei() {
|
|
|
2442
3004
|
let i = typeof n == "object" ? n : {
|
|
2443
3005
|
scope: n,
|
|
2444
3006
|
currentUserId: r
|
|
2445
|
-
}, o = i?.scope ?? e?.getScope?.(), c = String(i?.currentUserId ?? e?.getUserId?.() ?? ""), l = t.data ?? t.payload,
|
|
3007
|
+
}, o = i?.scope ?? e?.getScope?.(), c = String(i?.currentUserId ?? e?.getUserId?.() ?? ""), l = t.data ?? t.payload, d = l && typeof l == "object" ? {
|
|
2446
3008
|
...l,
|
|
2447
3009
|
...t
|
|
2448
|
-
} : t,
|
|
2449
|
-
if (typeof
|
|
2450
|
-
let m =
|
|
3010
|
+
} : t, f = d.message ?? d.text;
|
|
3011
|
+
if (typeof f != "string" || !f.startsWith("LIRA_GAME_V1:")) return !1;
|
|
3012
|
+
let m = Ut(f), h = String(d.room_id ?? ""), g = String(d.user_id ?? "");
|
|
2451
3013
|
if (!m || !o || !c || !g || !h.startsWith("private_")) return !0;
|
|
2452
3014
|
let _ = h.slice(8).split("_");
|
|
2453
3015
|
if (_.length !== 2 || !_.includes(c) || !_.includes(g)) return !0;
|
|
2454
|
-
let v =
|
|
2455
|
-
if (y &&
|
|
2456
|
-
if (
|
|
2457
|
-
if (!y && m.type !== "game_invite" && m.game === "tanks" &&
|
|
3016
|
+
let v = Ji(o, h, m.game_id), y = p().games[v];
|
|
3017
|
+
if (y && Q(y) !== m.game) return !0;
|
|
3018
|
+
if ($i(m.type)) return y && !y.seen[m.event_id] && p().handleResync(v, m, g, c), !0;
|
|
3019
|
+
if (!y && m.type !== "game_invite" && m.game === "tanks" && p().restoreTanks(o, m.game_id)) return p().ingest(t, n, r);
|
|
2458
3020
|
if (!y && m.type !== "game_invite") {
|
|
2459
3021
|
let e = Date.now();
|
|
2460
3022
|
for (let [t, n] of a) e - n.at > 3e4 && a.delete(t);
|
|
@@ -2465,7 +3027,7 @@ function ei() {
|
|
|
2465
3027
|
};
|
|
2466
3028
|
return t.messages.length < 8 && !t.messages.some((e) => e.eventId === m.event_id) && t.messages.push({
|
|
2467
3029
|
eventId: m.event_id,
|
|
2468
|
-
message:
|
|
3030
|
+
message: d
|
|
2469
3031
|
}), a.set(v, t), !0;
|
|
2470
3032
|
}
|
|
2471
3033
|
if (y?.seen[m.event_id]) return !0;
|
|
@@ -2483,11 +3045,11 @@ function ei() {
|
|
|
2483
3045
|
ownId: c,
|
|
2484
3046
|
hostId: g,
|
|
2485
3047
|
guestId: e,
|
|
2486
|
-
createdAt:
|
|
3048
|
+
createdAt: d.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
2487
3049
|
inviteEventId: m.event_id,
|
|
2488
3050
|
lastEventId: m.event_id,
|
|
2489
3051
|
seen: {},
|
|
2490
|
-
sync: { ...
|
|
3052
|
+
sync: { ...Qi }
|
|
2491
3053
|
}, m);
|
|
2492
3054
|
} else y && (b = x.apply(y, m, g, c));
|
|
2493
3055
|
if (!b || b === y) return !0;
|
|
@@ -2503,7 +3065,7 @@ function ei() {
|
|
|
2503
3065
|
[v]: b
|
|
2504
3066
|
};
|
|
2505
3067
|
if (m.type === "game_invite") {
|
|
2506
|
-
let e = Object.values(t).filter((e) => e.scope === o && e.roomId === h &&
|
|
3068
|
+
let e = Object.values(t).filter((e) => e.scope === o && e.roomId === h && !$(e)), n = e.sort((e, t) => e.gameId < t.gameId ? -1 : +(e.gameId > t.gameId))[0];
|
|
2507
3069
|
e.forEach((e) => {
|
|
2508
3070
|
e.key !== n?.key && (t[e.key] = {
|
|
2509
3071
|
...e,
|
|
@@ -2512,52 +3074,58 @@ function ei() {
|
|
|
2512
3074
|
});
|
|
2513
3075
|
});
|
|
2514
3076
|
}
|
|
2515
|
-
return { games:
|
|
3077
|
+
return { games: Yi(t) };
|
|
2516
3078
|
}), b.status === "conflict" && y?.status !== "conflict" && queueMicrotask(() => {
|
|
2517
|
-
|
|
2518
|
-
}),
|
|
3079
|
+
p().requestResync(v, { auto: !0 });
|
|
3080
|
+
}), p().afterGameChange(v), m.type === "game_invite") {
|
|
2519
3081
|
let e = a.get(v);
|
|
2520
|
-
a.delete(v), e && Date.now() - e.at <= 3e4 && e.messages.forEach((e) =>
|
|
3082
|
+
a.delete(v), e && Date.now() - e.at <= 3e4 && e.messages.forEach((e) => p().ingest(e.message, o, c));
|
|
2521
3083
|
}
|
|
2522
3084
|
return !0;
|
|
2523
3085
|
},
|
|
2524
|
-
invite: async ({ roomId: t, opponentId: n, gameType: r = "connect4", firstPlayerId: i, rematchOf: a, speedClass: o }) => {
|
|
3086
|
+
invite: async ({ roomId: t, opponentId: n, gameType: r = "connect4", firstPlayerId: i, rematchOf: a, speedClass: o, trackId: s, mapId: l, lives: u, seed: d }) => {
|
|
2525
3087
|
if (!e) throw Error("Chat no disponible");
|
|
2526
|
-
if (!
|
|
2527
|
-
let
|
|
3088
|
+
if (!Ui.includes(r)) throw Error("Juego no disponible");
|
|
3089
|
+
let f = e.getScope();
|
|
2528
3090
|
if (!String(e.getUserId() ?? "") || !String(t).startsWith("private_")) throw Error("Abre un chat privado para jugar.");
|
|
2529
|
-
if (Object.values(
|
|
2530
|
-
let
|
|
3091
|
+
if (Object.values(p().games).some((e) => e.scope === f && e.roomId === String(t) && (!$(e) || e.pendingEvent))) throw Error("Cierra la partida actual antes de invitar.");
|
|
3092
|
+
let m = h(), g = r === "racing_live" ? ot({
|
|
3093
|
+
opponentId: String(n),
|
|
3094
|
+
seed: parseInt(m.slice(0, 8), 16),
|
|
3095
|
+
rematchOf: a,
|
|
3096
|
+
...o === void 0 ? {} : { speedClass: o },
|
|
3097
|
+
...s === void 0 ? {} : { trackId: s }
|
|
3098
|
+
}) : r === "tanks_live" ? Xe({
|
|
2531
3099
|
opponentId: String(n),
|
|
2532
|
-
seed: parseInt(l.slice(0, 8), 16),
|
|
2533
3100
|
rematchOf: a,
|
|
2534
|
-
...
|
|
3101
|
+
...l === void 0 ? {} : { mapId: l },
|
|
3102
|
+
...u === void 0 ? {} : { lives: u },
|
|
3103
|
+
...d === void 0 ? {} : { seed: d }
|
|
2535
3104
|
}) : {
|
|
2536
3105
|
opponent_id: String(n),
|
|
2537
3106
|
rules_version: 1
|
|
2538
3107
|
};
|
|
2539
3108
|
if (r === "tanks") {
|
|
2540
|
-
let e =
|
|
2541
|
-
c.set(`${
|
|
3109
|
+
let e = mi();
|
|
3110
|
+
c.set(`${f}:${m}`, e), Bi(f, m, { seedA: e }), g.seed_commit = hi(e), i != null && (g.first_player_id = String(i)), a && (g.rematch_of = a);
|
|
2542
3111
|
}
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
data: u,
|
|
3112
|
+
let _ = F("game_invite", {
|
|
3113
|
+
game_id: m,
|
|
3114
|
+
data: g,
|
|
2547
3115
|
game: r
|
|
2548
3116
|
});
|
|
2549
|
-
return
|
|
3117
|
+
return p().sendEvent(t, _);
|
|
2550
3118
|
},
|
|
2551
3119
|
act: async (t, n, r = {}) => {
|
|
2552
|
-
let i =
|
|
3120
|
+
let i = p().games[t], a = String(e?.getUserId?.() ?? "");
|
|
2553
3121
|
if (!i || i.scope !== e?.getScope?.()) throw Error("Partida no disponible");
|
|
2554
3122
|
if (n !== "game_end" && (i.pending || i.pendingEvent)) throw Error("Reintenta el envío pendiente antes de continuar.");
|
|
2555
3123
|
let o = r;
|
|
2556
3124
|
if (n === "game_accept" || n === "game_decline") {
|
|
2557
3125
|
if (i.status !== "invited" || a !== i.guestId) return;
|
|
2558
|
-
o = { invite_event_id: i.inviteEventId }, n === "game_accept" &&
|
|
3126
|
+
o = { invite_event_id: i.inviteEventId }, n === "game_accept" && Gi(i) && (o.seed_b = mi()), n === "game_accept" && i.game === "racing_live" && (o.track_hash = i.raceConfig.trackHash), n === "game_accept" && i.game === "tanks_live" && i.liveConfig && (o.map_hash = i.liveConfig.mapHash);
|
|
2559
3127
|
} else if (n === "game_move") {
|
|
2560
|
-
if (
|
|
3128
|
+
if (Q(i) !== "connect4" || i.status !== "active" || a !== i.turnId || !Xt(i.board, r.column, a)) return;
|
|
2561
3129
|
o = {
|
|
2562
3130
|
column: r.column,
|
|
2563
3131
|
ply: i.ply + 1,
|
|
@@ -2565,51 +3133,51 @@ function ei() {
|
|
|
2565
3133
|
};
|
|
2566
3134
|
} else if (n === "game_end") o = { reason: "closed" };
|
|
2567
3135
|
else return;
|
|
2568
|
-
return
|
|
3136
|
+
return p().sendEvent(i.roomId, F(n, {
|
|
2569
3137
|
game_id: i.gameId,
|
|
2570
3138
|
data: o,
|
|
2571
|
-
game:
|
|
3139
|
+
game: Q(i)
|
|
2572
3140
|
}));
|
|
2573
3141
|
},
|
|
2574
3142
|
bsUpdateLocal: (e, t) => {
|
|
2575
|
-
let n =
|
|
2576
|
-
if (!
|
|
3143
|
+
let n = p().games[e];
|
|
3144
|
+
if (!Wi(n)) return !1;
|
|
2577
3145
|
let r = t(n);
|
|
2578
3146
|
return r !== n && (s((t) => t.games[e] === n ? { games: {
|
|
2579
3147
|
...t.games,
|
|
2580
3148
|
[e]: r
|
|
2581
|
-
} } : t),
|
|
3149
|
+
} } : t), p().games[e] === r);
|
|
2582
3150
|
},
|
|
2583
|
-
bsPlaceShip: (e, t) =>
|
|
2584
|
-
bsRemoveShip: (e, t) =>
|
|
2585
|
-
bsRandomFleet: (e) =>
|
|
3151
|
+
bsPlaceShip: (e, t) => p().bsUpdateLocal(e, (e) => On(e, t)),
|
|
3152
|
+
bsRemoveShip: (e, t) => p().bsUpdateLocal(e, (e) => kn(e, t)),
|
|
3153
|
+
bsRandomFleet: (e) => p().bsUpdateLocal(e, (e) => Mn(e)),
|
|
2586
3154
|
bsReady: async (n) => {
|
|
2587
|
-
let r =
|
|
2588
|
-
if (!
|
|
3155
|
+
let r = p().games[n];
|
|
3156
|
+
if (!Wi(r) || r.status !== "placement" || r.myReady) return;
|
|
2589
3157
|
if (r.scope !== e?.getScope?.()) throw Error("Partida no disponible");
|
|
2590
3158
|
if (r.pending || r.pendingEvent) throw Error("Reintenta el envío pendiente antes de continuar.");
|
|
2591
|
-
let i =
|
|
2592
|
-
if (!
|
|
2593
|
-
let a =
|
|
2594
|
-
if (!(!s || s.myReady || s.status !== "placement" || s.pending || s.pendingEvent || JSON.stringify(
|
|
3159
|
+
let i = wn(r.myFleet);
|
|
3160
|
+
if (!En(i)) throw Error("Coloca los cinco barcos antes de continuar.");
|
|
3161
|
+
let a = Pn(), o = await In(i, a), s = p().games[n];
|
|
3162
|
+
if (!(!s || s.myReady || s.status !== "placement" || s.pending || s.pendingEvent || JSON.stringify(wn(s.myFleet)) !== JSON.stringify(i))) return t.set(`${r.scope}:${r.gameId}`, {
|
|
2595
3163
|
fleet: i,
|
|
2596
3164
|
salt: a,
|
|
2597
3165
|
commitment: o
|
|
2598
|
-
}),
|
|
3166
|
+
}), lr(r.scope, r.gameId, {
|
|
2599
3167
|
fleet: i,
|
|
2600
3168
|
salt: a,
|
|
2601
3169
|
commitment: o
|
|
2602
|
-
}),
|
|
3170
|
+
}), p().sendEvent(r.roomId, F("bs_commit", {
|
|
2603
3171
|
game_id: r.gameId,
|
|
2604
3172
|
data: { commitment: o },
|
|
2605
3173
|
game: "battleship"
|
|
2606
3174
|
}));
|
|
2607
3175
|
},
|
|
2608
3176
|
bsFire: async (t, { row: n, col: r } = {}) => {
|
|
2609
|
-
let i =
|
|
2610
|
-
if (!
|
|
3177
|
+
let i = p().games[t];
|
|
3178
|
+
if (!Wi(i) || i.scope !== e?.getScope?.()) throw Error("Partida no disponible");
|
|
2611
3179
|
if (i.pending || i.pendingEvent) throw Error("Reintenta el envío pendiente antes de continuar.");
|
|
2612
|
-
if (
|
|
3180
|
+
if (yn(i) && i.targetShots[n]?.[r] === null) return p().sendEvent(i.roomId, F("bs_fire", {
|
|
2613
3181
|
game_id: i.gameId,
|
|
2614
3182
|
data: {
|
|
2615
3183
|
ply: i.ply + 1,
|
|
@@ -2622,15 +3190,15 @@ function ei() {
|
|
|
2622
3190
|
},
|
|
2623
3191
|
bsScheduleEffects: (e) => {
|
|
2624
3192
|
r.has(e) || r.set(e, setTimeout(() => {
|
|
2625
|
-
r.delete(e),
|
|
2626
|
-
},
|
|
3193
|
+
r.delete(e), p().bsRunEffects(e);
|
|
3194
|
+
}, qi));
|
|
2627
3195
|
},
|
|
2628
3196
|
bsRunEffects: (t) => {
|
|
2629
|
-
let r =
|
|
2630
|
-
if (!
|
|
3197
|
+
let r = p().games[t];
|
|
3198
|
+
if (!Wi(r) || !e || r.scope !== e.getScope?.()) return;
|
|
2631
3199
|
if (r.opponentReveal && r.verification === "pending" && !i.has(t)) {
|
|
2632
3200
|
let e = r.opponentReveal;
|
|
2633
|
-
i.add(t),
|
|
3201
|
+
i.add(t), Yn(r, e).then((n) => s((r) => {
|
|
2634
3202
|
let i = r.games[t];
|
|
2635
3203
|
return !i || i.opponentReveal !== e || i.verification === n ? r : { games: {
|
|
2636
3204
|
...r.games,
|
|
@@ -2645,14 +3213,14 @@ function ei() {
|
|
|
2645
3213
|
}
|
|
2646
3214
|
if (r.pending || r.pendingEvent) return;
|
|
2647
3215
|
let a = (e, t) => {
|
|
2648
|
-
|
|
3216
|
+
p().sendEvent(r.roomId, F(e, {
|
|
2649
3217
|
game_id: r.gameId,
|
|
2650
3218
|
data: t,
|
|
2651
3219
|
game: "battleship"
|
|
2652
3220
|
})).catch(() => {});
|
|
2653
3221
|
};
|
|
2654
3222
|
if (r.status === "active" && r.pendingShot && r.pendingShot.by !== r.ownId) {
|
|
2655
|
-
let e =
|
|
3223
|
+
let e = Ln(Dn(r), r.pendingShot);
|
|
2656
3224
|
e ? a("bs_result", e) : r.error || s((e) => ({ games: {
|
|
2657
3225
|
...e.games,
|
|
2658
3226
|
[t]: {
|
|
@@ -2664,31 +3232,31 @@ function ei() {
|
|
|
2664
3232
|
}
|
|
2665
3233
|
let o = String(r.winnerId) !== String(r.ownId) || !!r.opponentReveal;
|
|
2666
3234
|
if (r.winnerId && ["won", "closed"].includes(r.status) && !r.myRevealSent && o) {
|
|
2667
|
-
let e =
|
|
2668
|
-
|
|
3235
|
+
let e = wn(r.myFleet), t = r.mySalt ?? n(r.scope, r.gameId)?.salt;
|
|
3236
|
+
En(e) && t && a("bs_reveal", {
|
|
2669
3237
|
fleet: e,
|
|
2670
3238
|
salt: t
|
|
2671
3239
|
});
|
|
2672
3240
|
}
|
|
2673
3241
|
},
|
|
2674
3242
|
afterGameChange: (e) => {
|
|
2675
|
-
let t =
|
|
2676
|
-
|
|
3243
|
+
let t = p().games[e];
|
|
3244
|
+
d(t)?.after?.(e, p);
|
|
2677
3245
|
},
|
|
2678
3246
|
tkTurn: async (t, n) => {
|
|
2679
|
-
let r =
|
|
2680
|
-
if (!
|
|
3247
|
+
let r = p().games[t];
|
|
3248
|
+
if (!Gi(r) || r.scope !== e?.getScope?.()) throw Error("Partida no disponible");
|
|
2681
3249
|
if (r.pending || r.pendingEvent) throw Error("Reintenta el envío pendiente antes de continuar.");
|
|
2682
|
-
let i =
|
|
2683
|
-
if (i) return
|
|
3250
|
+
let i = Ei(r, n);
|
|
3251
|
+
if (i) return p().sendEvent(r.roomId, F("tk_turn", {
|
|
2684
3252
|
game_id: r.gameId,
|
|
2685
3253
|
data: i,
|
|
2686
3254
|
game: "tanks"
|
|
2687
3255
|
}));
|
|
2688
3256
|
},
|
|
2689
3257
|
tkSkip: async (t) => {
|
|
2690
|
-
let n =
|
|
2691
|
-
if (
|
|
3258
|
+
let n = p().games[t];
|
|
3259
|
+
if (Gi(n) && yi(n) && n.scope === e?.getScope?.()) return p().sendEvent(n.roomId, F("tk_skip", {
|
|
2692
3260
|
game_id: n.gameId,
|
|
2693
3261
|
data: {
|
|
2694
3262
|
ply: n.ply + 1,
|
|
@@ -2698,8 +3266,8 @@ function ei() {
|
|
|
2698
3266
|
}));
|
|
2699
3267
|
},
|
|
2700
3268
|
tkResign: async (t) => {
|
|
2701
|
-
let n =
|
|
2702
|
-
if (!(!
|
|
3269
|
+
let n = p().games[t];
|
|
3270
|
+
if (!(!Gi(n) || n.status !== "active" || n.pending || n.pendingEvent || n.scope !== e?.getScope?.())) return p().sendEvent(n.roomId, F("tk_resign", {
|
|
2703
3271
|
game_id: n.gameId,
|
|
2704
3272
|
data: {
|
|
2705
3273
|
ply: n.ply + 1,
|
|
@@ -2710,14 +3278,14 @@ function ei() {
|
|
|
2710
3278
|
},
|
|
2711
3279
|
tkScheduleEffects: (e) => {
|
|
2712
3280
|
r.has(e) || r.set(e, setTimeout(() => {
|
|
2713
|
-
r.delete(e),
|
|
2714
|
-
},
|
|
3281
|
+
r.delete(e), p().tkRunEffects(e);
|
|
3282
|
+
}, qi));
|
|
2715
3283
|
},
|
|
2716
3284
|
tkRunEffects: (t) => {
|
|
2717
|
-
let n =
|
|
2718
|
-
if (!
|
|
3285
|
+
let n = p().games[t];
|
|
3286
|
+
if (!Gi(n) || (Bi(n.scope, n.gameId, { snapshot: Mi(n) }), !e || n.scope !== e.getScope?.() || n.pending || n.pendingEvent) || n.status !== "seeding" || n.ownId !== n.hostId) return;
|
|
2719
3287
|
let r = l(n.scope, n.gameId);
|
|
2720
|
-
r ?
|
|
3288
|
+
r ? p().sendEvent(n.roomId, F("tk_seed", {
|
|
2721
3289
|
game_id: n.gameId,
|
|
2722
3290
|
data: { seed_a: r },
|
|
2723
3291
|
game: "tanks"
|
|
@@ -2731,16 +3299,16 @@ function ei() {
|
|
|
2731
3299
|
},
|
|
2732
3300
|
restoreTanks: (e, t) => {
|
|
2733
3301
|
let n = !1;
|
|
2734
|
-
return
|
|
3302
|
+
return Hi(e).forEach(({ snapshot: r }) => {
|
|
2735
3303
|
if (!r || t && r.gameId !== t || [
|
|
2736
3304
|
"closed",
|
|
2737
3305
|
"declined",
|
|
2738
3306
|
"won",
|
|
2739
3307
|
"draw"
|
|
2740
3308
|
].includes(r.status)) return;
|
|
2741
|
-
let i =
|
|
2742
|
-
if (
|
|
2743
|
-
let a =
|
|
3309
|
+
let i = Ji(e, r.roomId, r.gameId);
|
|
3310
|
+
if (p().games[i]) return;
|
|
3311
|
+
let a = ki(_i({
|
|
2744
3312
|
key: i,
|
|
2745
3313
|
gameId: r.gameId,
|
|
2746
3314
|
game_id: r.gameId,
|
|
@@ -2753,7 +3321,7 @@ function ei() {
|
|
|
2753
3321
|
inviteEventId: r.inviteEventId,
|
|
2754
3322
|
lastEventId: r.inviteEventId,
|
|
2755
3323
|
seen: {},
|
|
2756
|
-
sync: { ...
|
|
3324
|
+
sync: { ...Qi }
|
|
2757
3325
|
}, {
|
|
2758
3326
|
seed_commit: r.seedCommit,
|
|
2759
3327
|
first_player_id: r.firstPlayerId,
|
|
@@ -2763,32 +3331,32 @@ function ei() {
|
|
|
2763
3331
|
n = !0;
|
|
2764
3332
|
let o = {
|
|
2765
3333
|
...a,
|
|
2766
|
-
seen:
|
|
3334
|
+
seen: ji({ [r.inviteEventId]: !0 }, a),
|
|
2767
3335
|
status: "conflict",
|
|
2768
3336
|
error: "Partida recuperada en este dispositivo. Sincronizando con el rival…"
|
|
2769
3337
|
};
|
|
2770
|
-
s((e) => ({ games:
|
|
3338
|
+
s((e) => ({ games: Yi({
|
|
2771
3339
|
...e.games,
|
|
2772
3340
|
[i]: o
|
|
2773
3341
|
}) })), queueMicrotask(() => {
|
|
2774
|
-
|
|
3342
|
+
p().requestResync(i, { auto: !0 });
|
|
2775
3343
|
});
|
|
2776
3344
|
}), n;
|
|
2777
3345
|
},
|
|
2778
3346
|
createLiveSignaling: (t) => {
|
|
2779
|
-
let n =
|
|
3347
|
+
let n = p().games[t];
|
|
2780
3348
|
if (!["tanks_live", "racing_live"].includes(n?.game) || n.scope !== e?.getScope?.()) throw Error("Partida no disponible");
|
|
2781
3349
|
let r = e;
|
|
2782
|
-
return
|
|
3350
|
+
return dt({
|
|
2783
3351
|
roomId: n.roomId,
|
|
2784
3352
|
send: (n, i) => {
|
|
2785
|
-
if (e !== r ||
|
|
3353
|
+
if (e !== r || p().games[t]?.scope !== r.getScope()) throw Error("La sesión cambió");
|
|
2786
3354
|
return r.send(n, i);
|
|
2787
3355
|
}
|
|
2788
3356
|
});
|
|
2789
3357
|
},
|
|
2790
3358
|
liveFinish: (t, n) => {
|
|
2791
|
-
let r =
|
|
3359
|
+
let r = p().games[t];
|
|
2792
3360
|
r?.game === "tanks_live" && r.scope === e?.getScope?.() && r.status === "active" && [r.hostId, r.guestId].includes(String(n)) && s((e) => ({ games: {
|
|
2793
3361
|
...e.games,
|
|
2794
3362
|
[t]: {
|
|
@@ -2798,23 +3366,39 @@ function ei() {
|
|
|
2798
3366
|
}
|
|
2799
3367
|
} }));
|
|
2800
3368
|
},
|
|
2801
|
-
liveRematch: (t) => {
|
|
2802
|
-
let
|
|
2803
|
-
if (
|
|
2804
|
-
|
|
2805
|
-
|
|
3369
|
+
liveRematch: (t, { newMap: n = !1, mapId: r, lives: i } = {}) => {
|
|
3370
|
+
let a = p().games[t];
|
|
3371
|
+
if (a?.game !== "tanks_live" || a.scope !== e?.getScope?.() || !$(a)) return;
|
|
3372
|
+
let o = a.liveConfig, s = n ? {
|
|
3373
|
+
mapId: r ?? "random",
|
|
3374
|
+
lives: i ?? o?.lives
|
|
3375
|
+
} : r === void 0 ? o ? {
|
|
3376
|
+
mapId: o.mapId,
|
|
3377
|
+
seed: o.seed,
|
|
3378
|
+
lives: i ?? o.lives
|
|
3379
|
+
} : i === void 0 ? { mapId: null } : {
|
|
3380
|
+
mapId: "random",
|
|
3381
|
+
lives: i
|
|
3382
|
+
} : {
|
|
3383
|
+
mapId: r,
|
|
3384
|
+
lives: i ?? o?.lives
|
|
3385
|
+
};
|
|
3386
|
+
return s.lives === void 0 && delete s.lives, p().invite({
|
|
3387
|
+
roomId: a.roomId,
|
|
3388
|
+
opponentId: a.ownId === a.hostId ? a.guestId : a.hostId,
|
|
2806
3389
|
gameType: "tanks_live",
|
|
2807
|
-
rematchOf:
|
|
3390
|
+
rematchOf: a.gameId,
|
|
3391
|
+
...s
|
|
2808
3392
|
});
|
|
2809
3393
|
},
|
|
2810
3394
|
sendEvent: async (t, n) => {
|
|
2811
3395
|
if (!e) throw Error("Chat no disponible");
|
|
2812
|
-
let r = e, i = r.getScope(), a = String(r.getUserId() ?? ""), o =
|
|
2813
|
-
if (
|
|
3396
|
+
let r = e, i = r.getScope(), a = String(r.getUserId() ?? ""), o = Ji(i, t, n.game_id), c = Wt(n);
|
|
3397
|
+
if (p().ingest({
|
|
2814
3398
|
room_id: t,
|
|
2815
3399
|
user_id: a,
|
|
2816
3400
|
message: c
|
|
2817
|
-
}, i, a), !
|
|
3401
|
+
}, i, a), !p().games[o]?.seen[n.event_id]) throw Error("Evento de partida inválido");
|
|
2818
3402
|
let l = (e, t = !0) => s((r) => {
|
|
2819
3403
|
let i = r.games[o];
|
|
2820
3404
|
return !i || t && i.pendingEvent?.event_id !== n.event_id ? r : { games: {
|
|
@@ -2834,7 +3418,7 @@ function ei() {
|
|
|
2834
3418
|
await r.send(t, c), l({
|
|
2835
3419
|
pending: !1,
|
|
2836
3420
|
pendingEvent: null
|
|
2837
|
-
}),
|
|
3421
|
+
}), p().afterGameChange(o);
|
|
2838
3422
|
} catch (e) {
|
|
2839
3423
|
throw l({
|
|
2840
3424
|
pending: !1,
|
|
@@ -2844,14 +3428,14 @@ function ei() {
|
|
|
2844
3428
|
return o;
|
|
2845
3429
|
},
|
|
2846
3430
|
handleResync: (e, t, n, r) => {
|
|
2847
|
-
let i =
|
|
3431
|
+
let i = p().games[e], a = f(i), o = {
|
|
2848
3432
|
...i.seen,
|
|
2849
3433
|
[t.event_id]: !0
|
|
2850
3434
|
}, c = (t) => {
|
|
2851
3435
|
s((n) => ({ games: {
|
|
2852
3436
|
...n.games,
|
|
2853
3437
|
[e]: t
|
|
2854
|
-
} })),
|
|
3438
|
+
} })), p().afterGameChange(e);
|
|
2855
3439
|
};
|
|
2856
3440
|
if (n === r || ![i.hostId, i.guestId].includes(n) || ["closed", "declined"].includes(i.status)) {
|
|
2857
3441
|
c({
|
|
@@ -2861,7 +3445,7 @@ function ei() {
|
|
|
2861
3445
|
return;
|
|
2862
3446
|
}
|
|
2863
3447
|
let l = {
|
|
2864
|
-
...
|
|
3448
|
+
...Qi,
|
|
2865
3449
|
...i.sync
|
|
2866
3450
|
};
|
|
2867
3451
|
if (![a.requestType, a.stateType].includes(t.type)) {
|
|
@@ -2879,8 +3463,8 @@ function ei() {
|
|
|
2879
3463
|
});
|
|
2880
3464
|
return;
|
|
2881
3465
|
}
|
|
2882
|
-
let
|
|
2883
|
-
if (!
|
|
3466
|
+
let d = a.rebuild(i, t.data);
|
|
3467
|
+
if (!d) {
|
|
2884
3468
|
c({
|
|
2885
3469
|
...i,
|
|
2886
3470
|
seen: o,
|
|
@@ -2892,15 +3476,15 @@ function ei() {
|
|
|
2892
3476
|
});
|
|
2893
3477
|
return;
|
|
2894
3478
|
}
|
|
2895
|
-
let
|
|
3479
|
+
let m = a.compare(i, t.data), h = {
|
|
2896
3480
|
...l,
|
|
2897
3481
|
status: "ok",
|
|
2898
3482
|
offer: null,
|
|
2899
3483
|
auto: !1,
|
|
2900
3484
|
message: ""
|
|
2901
|
-
}, g, _ = !u, v = !1, y =
|
|
2902
|
-
if (
|
|
2903
|
-
...
|
|
3485
|
+
}, g, _ = !u, v = !1, y = m === "mixed" ? a.merge(i, t.data) : null;
|
|
3486
|
+
if (m === "equal" || m === "behind") g = {
|
|
3487
|
+
...d,
|
|
2904
3488
|
sync: h
|
|
2905
3489
|
}, a.covers(i, t.data) && (g = {
|
|
2906
3490
|
...g,
|
|
@@ -2919,7 +3503,7 @@ function ei() {
|
|
|
2919
3503
|
message: "No se pudo reconstruir la partida local."
|
|
2920
3504
|
}
|
|
2921
3505
|
}, _ = !!e, v = !!e;
|
|
2922
|
-
} else if (
|
|
3506
|
+
} else if (m === "ahead" || n === i.guestId) {
|
|
2923
3507
|
let e = a.rebuild(i, a.historyOf(i));
|
|
2924
3508
|
g = e ? {
|
|
2925
3509
|
...e,
|
|
@@ -2949,7 +3533,7 @@ function ei() {
|
|
|
2949
3533
|
};
|
|
2950
3534
|
let b = Date.now(), x = g.sync.replies.filter((e) => b - e < 3e4), S = null;
|
|
2951
3535
|
if (_ && x.length < 6) try {
|
|
2952
|
-
S =
|
|
3536
|
+
S = ca(i, a.stateType, {
|
|
2953
3537
|
...a.historyOf(g),
|
|
2954
3538
|
request_event_id: t.event_id
|
|
2955
3539
|
});
|
|
@@ -2967,10 +3551,10 @@ function ei() {
|
|
|
2967
3551
|
replies: [...x, b],
|
|
2968
3552
|
outgoing: [...g.sync.outgoing, S.event_id].slice(-8)
|
|
2969
3553
|
}
|
|
2970
|
-
}), c(g), S &&
|
|
3554
|
+
}), c(g), S && p().sendResync(e, S).then(() => {
|
|
2971
3555
|
v && (s((t) => {
|
|
2972
3556
|
let n = t.games[e];
|
|
2973
|
-
return !n || !
|
|
3557
|
+
return !n || !f(n).covers(n, f(n).historyOf(n)) ? t : { games: {
|
|
2974
3558
|
...t.games,
|
|
2975
3559
|
[e]: {
|
|
2976
3560
|
...n,
|
|
@@ -2978,25 +3562,25 @@ function ei() {
|
|
|
2978
3562
|
error: ""
|
|
2979
3563
|
}
|
|
2980
3564
|
} };
|
|
2981
|
-
}),
|
|
3565
|
+
}), p().afterGameChange(e));
|
|
2982
3566
|
}).catch(() => {});
|
|
2983
3567
|
},
|
|
2984
3568
|
sendResync: async (t, n) => {
|
|
2985
|
-
let r =
|
|
3569
|
+
let r = p().games[t];
|
|
2986
3570
|
if (!e || !r || r.scope !== e.getScope?.()) throw Error("Chat no disponible");
|
|
2987
|
-
await e.send(r.roomId,
|
|
3571
|
+
await e.send(r.roomId, Wt(n));
|
|
2988
3572
|
},
|
|
2989
3573
|
requestResync: async (t, { auto: n = !1 } = {}) => {
|
|
2990
|
-
let r =
|
|
2991
|
-
if (!r ||
|
|
3574
|
+
let r = p().games[t];
|
|
3575
|
+
if (!r || Ki(r) || !e || ["closed", "declined"].includes(r.status) || r.scope !== e.getScope?.()) return;
|
|
2992
3576
|
let i = {
|
|
2993
|
-
...
|
|
3577
|
+
...Qi,
|
|
2994
3578
|
...r.sync
|
|
2995
3579
|
};
|
|
2996
|
-
if (i.status === "requesting" && Date.now() - i.requestedAt <
|
|
3580
|
+
if (i.status === "requesting" && Date.now() - i.requestedAt < Zi || n && i.auto) return;
|
|
2997
3581
|
let a;
|
|
2998
3582
|
try {
|
|
2999
|
-
a =
|
|
3583
|
+
a = ca(r, f(r).requestType, f(r).historyOf(r));
|
|
3000
3584
|
} catch {
|
|
3001
3585
|
return;
|
|
3002
3586
|
}
|
|
@@ -3038,18 +3622,18 @@ function ei() {
|
|
|
3038
3622
|
});
|
|
3039
3623
|
let l = setTimeout(() => {
|
|
3040
3624
|
o.delete(l), c("El rival no respondió a la sincronización. Reintenta cuando esté conectado.");
|
|
3041
|
-
},
|
|
3625
|
+
}, Zi);
|
|
3042
3626
|
o.add(l);
|
|
3043
3627
|
try {
|
|
3044
|
-
await
|
|
3628
|
+
await p().sendResync(t, a);
|
|
3045
3629
|
} catch (e) {
|
|
3046
3630
|
c(e.message || "No se pudo enviar la solicitud de sincronización.");
|
|
3047
3631
|
}
|
|
3048
3632
|
},
|
|
3049
3633
|
adoptResyncOffer: (e) => {
|
|
3050
|
-
let t =
|
|
3634
|
+
let t = p().games[e], n = t?.sync?.offer;
|
|
3051
3635
|
if (!n || t.sync.status !== "incompatible") return !1;
|
|
3052
|
-
let r =
|
|
3636
|
+
let r = f(t), i = r.rebuild(t, n);
|
|
3053
3637
|
return s((n) => ({ games: {
|
|
3054
3638
|
...n.games,
|
|
3055
3639
|
[e]: i ? {
|
|
@@ -3073,36 +3657,36 @@ function ei() {
|
|
|
3073
3657
|
message: "El estado del anfitrión ya no es válido."
|
|
3074
3658
|
}
|
|
3075
3659
|
}
|
|
3076
|
-
} })), i &&
|
|
3660
|
+
} })), i && p().afterGameChange(e), !!i;
|
|
3077
3661
|
},
|
|
3078
3662
|
resyncConflicts: (e) => {
|
|
3079
|
-
|
|
3080
|
-
|
|
3663
|
+
p().restoreTanks(e), Object.values(p().games).filter((t) => t.scope === e && t.status === "conflict").forEach((e) => {
|
|
3664
|
+
p().requestResync(e.key, { auto: !0 });
|
|
3081
3665
|
});
|
|
3082
3666
|
},
|
|
3083
3667
|
retry: (t) => {
|
|
3084
|
-
let n =
|
|
3085
|
-
return !n?.pendingEvent || n.pending ? Promise.resolve() : n.scope === e?.getScope?.() ?
|
|
3668
|
+
let n = p().games[t];
|
|
3669
|
+
return !n?.pendingEvent || n.pending ? Promise.resolve() : n.scope === e?.getScope?.() ? p().sendEvent(n.roomId, n.pendingEvent) : Promise.reject(/* @__PURE__ */ Error("La sesión de esta partida ya no está activa."));
|
|
3086
3670
|
}
|
|
3087
3671
|
}));
|
|
3088
3672
|
}
|
|
3089
|
-
var
|
|
3090
|
-
Object.assign(
|
|
3091
|
-
getState:
|
|
3092
|
-
setState:
|
|
3093
|
-
subscribe:
|
|
3673
|
+
var ua = la(), da = (e) => m(ua, e);
|
|
3674
|
+
Object.assign(da, {
|
|
3675
|
+
getState: ua.getState,
|
|
3676
|
+
setState: ua.setState,
|
|
3677
|
+
subscribe: ua.subscribe
|
|
3094
3678
|
});
|
|
3095
3679
|
// src/assets/chatAssets.js
|
|
3096
|
-
var
|
|
3097
|
-
function
|
|
3098
|
-
|
|
3680
|
+
var fa = "/sounds", pa = fa, ma = (e) => String(e).replace(/\/+$/, "");
|
|
3681
|
+
function ha(e) {
|
|
3682
|
+
pa = e == null ? fa : ma(e);
|
|
3099
3683
|
}
|
|
3100
|
-
function
|
|
3101
|
-
return
|
|
3684
|
+
function ga() {
|
|
3685
|
+
return pa;
|
|
3102
3686
|
}
|
|
3103
|
-
function
|
|
3104
|
-
return `${
|
|
3687
|
+
function _a(e) {
|
|
3688
|
+
return `${pa}/${String(e).replace(/^\/+/, "")}`;
|
|
3105
3689
|
}
|
|
3106
|
-
export {
|
|
3690
|
+
export { ce as C, re as D, S as E, ne as O, b as S, de as T, ut as _, da as a, se as b, Vr as c, V as d, dr as f, dt as g, Rt as h, ua as i, h as k, Or as l, wt as m, ga as n, yi as o, R as p, ha as r, zr as s, _a as t, H as u, Le as v, ue as w, y as x, g as y };
|
|
3107
3691
|
|
|
3108
|
-
//# sourceMappingURL=games-
|
|
3692
|
+
//# sourceMappingURL=games-D_9SiSBT.js.map
|