agenthall 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +119 -2
- package/bin/agent-office.js +287 -0
- package/hook-relay.js +35 -0
- package/office-cli.js +82 -0
- package/package.json +52 -4
- package/public/app.js +4745 -0
- package/public/arcade.js +416 -0
- package/public/i18n.js +1038 -0
- package/public/index.html +89 -0
- package/public/logo.svg +23 -0
- package/public/style.css +269 -0
- package/server.js +2613 -0
package/public/arcade.js
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* Break game: a top-down driving game on a four-lane road. It opens only while
|
|
4
|
+
every agent is working; once started it runs until the boss crashes or quits,
|
|
5
|
+
whatever the agents do meanwhile. */
|
|
6
|
+
|
|
7
|
+
(function () {
|
|
8
|
+
const W = 440;
|
|
9
|
+
const H = 680;
|
|
10
|
+
const LANES = 4;
|
|
11
|
+
const LANE_W = 84;
|
|
12
|
+
const ROAD_X = (W - LANES * LANE_W) / 2;
|
|
13
|
+
const laneX = (i) => ROAD_X + LANE_W * (i + 0.5);
|
|
14
|
+
const CAR = { w: 40, h: 70 };
|
|
15
|
+
|
|
16
|
+
const root = document.getElementById('arcade');
|
|
17
|
+
let game = null;
|
|
18
|
+
let raf = 0;
|
|
19
|
+
|
|
20
|
+
function bestLocal() {
|
|
21
|
+
try {
|
|
22
|
+
return Number(localStorage.getItem('ao-arcade-best')) || 0;
|
|
23
|
+
} catch {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function saveBestLocal(v) {
|
|
28
|
+
try {
|
|
29
|
+
localStorage.setItem('ao-arcade-best', String(v));
|
|
30
|
+
} catch {
|
|
31
|
+
/* storage unavailable */
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function newGame() {
|
|
36
|
+
return {
|
|
37
|
+
lane: 1,
|
|
38
|
+
x: laneX(1),
|
|
39
|
+
speed: 260, // road scroll, px/s
|
|
40
|
+
score: 0,
|
|
41
|
+
dist: 0,
|
|
42
|
+
obstacles: [],
|
|
43
|
+
coins: [],
|
|
44
|
+
popups: [],
|
|
45
|
+
sparks: [],
|
|
46
|
+
nextSpawn: 0.6,
|
|
47
|
+
nextCoin: 2.5,
|
|
48
|
+
countdown: 3,
|
|
49
|
+
paused: false,
|
|
50
|
+
over: false,
|
|
51
|
+
best: Math.max(bestLocal(), (S.game && S.game.counters && S.game.counters.arcadeBest) || 0),
|
|
52
|
+
t: 0,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// `force` skips the lock: used by the #test-drive link to try the game any time.
|
|
57
|
+
function open(force) {
|
|
58
|
+
if (game && !game.over) return show();
|
|
59
|
+
if (force !== true && !canPlay()) return toast(tx('arcade.locked'), 'info');
|
|
60
|
+
game = newGame();
|
|
61
|
+
show();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function show() {
|
|
65
|
+
root.innerHTML = `
|
|
66
|
+
<div class="arc-box">
|
|
67
|
+
<div class="arc-head">
|
|
68
|
+
<b>${tx('arcade.heading')}</b>
|
|
69
|
+
<span class="arc-help">${tx('arcade.help')}</span>
|
|
70
|
+
<button class="ghost icon" data-arc="close">✕</button>
|
|
71
|
+
</div>
|
|
72
|
+
<canvas width="${W}" height="${H}"></canvas>
|
|
73
|
+
<div class="arc-over" hidden></div>
|
|
74
|
+
</div>`;
|
|
75
|
+
root.hidden = false;
|
|
76
|
+
root.querySelector('[data-arc="close"]').onclick = close;
|
|
77
|
+
last = performance.now();
|
|
78
|
+
cancelAnimationFrame(raf);
|
|
79
|
+
raf = requestAnimationFrame(loop);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function close() {
|
|
83
|
+
cancelAnimationFrame(raf);
|
|
84
|
+
root.hidden = true;
|
|
85
|
+
root.innerHTML = '';
|
|
86
|
+
game = null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function steer(d) {
|
|
90
|
+
if (!game || game.over || game.paused || game.countdown > 0) return;
|
|
91
|
+
game.lane = Math.max(0, Math.min(LANES - 1, game.lane + d));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
document.addEventListener('keydown', (e) => {
|
|
95
|
+
if (root.hidden || !game) return;
|
|
96
|
+
const k = e.key.toLowerCase();
|
|
97
|
+
if (k === 'arrowleft' || k === 'a') steer(-1);
|
|
98
|
+
else if (k === 'arrowright' || k === 'd') steer(1);
|
|
99
|
+
else if (k === 'p' || k === ' ') {
|
|
100
|
+
if (!game.over && game.countdown <= 0) game.paused = !game.paused;
|
|
101
|
+
} else if (k === 'escape') close();
|
|
102
|
+
else return;
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
e.stopPropagation();
|
|
105
|
+
}, true);
|
|
106
|
+
|
|
107
|
+
root.addEventListener('pointerdown', (e) => {
|
|
108
|
+
const cv = root.querySelector('canvas');
|
|
109
|
+
if (!cv || e.target !== cv) return;
|
|
110
|
+
const r = cv.getBoundingClientRect();
|
|
111
|
+
steer(e.clientX - r.left < r.width / 2 ? -1 : 1);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Left two lanes are oncoming traffic (fast toward you), right two go your way (slower).
|
|
115
|
+
function spawnRow() {
|
|
116
|
+
const free = Math.floor(Math.random() * LANES);
|
|
117
|
+
const count = Math.random() < 0.35 + Math.min(0.35, game.dist / 40000) ? 2 : 1;
|
|
118
|
+
const lanes = [0, 1, 2, 3].filter((l) => l !== free).sort(() => Math.random() - 0.5).slice(0, count);
|
|
119
|
+
for (const lane of lanes) {
|
|
120
|
+
const r = Math.random();
|
|
121
|
+
const kind = r < 0.12 ? 'cone' : r < 0.2 ? 'oil' : r < 0.3 ? 'truck' : 'car';
|
|
122
|
+
const oncoming = lane < 2;
|
|
123
|
+
const own = kind === 'cone' || kind === 'oil' ? 0 : oncoming ? 140 : -110;
|
|
124
|
+
game.obstacles.push({
|
|
125
|
+
kind,
|
|
126
|
+
lane,
|
|
127
|
+
x: laneX(lane),
|
|
128
|
+
y: -100,
|
|
129
|
+
h: kind === 'truck' ? 120 : kind === 'cone' ? 26 : kind === 'oil' ? 34 : CAR.h,
|
|
130
|
+
w: kind === 'cone' ? 22 : kind === 'oil' ? 46 : kind === 'truck' ? 48 : CAR.w,
|
|
131
|
+
own,
|
|
132
|
+
oncoming,
|
|
133
|
+
color: ['#e63946', '#457b9d', '#2a9d8f', '#e9c46a', '#8338ec', '#ffffff', '#1d3557', '#ff006e'][Math.floor(Math.random() * 8)],
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let last = 0;
|
|
139
|
+
function loop(now) {
|
|
140
|
+
const dt = Math.min(0.05, (now - last) / 1000);
|
|
141
|
+
last = now;
|
|
142
|
+
if (game) {
|
|
143
|
+
update(dt);
|
|
144
|
+
draw();
|
|
145
|
+
// Keep "play again" in sync with whether everyone is still working.
|
|
146
|
+
const again = game.over && root.querySelector('[data-arc="again"]');
|
|
147
|
+
if (again) {
|
|
148
|
+
const allowed = canPlay() || testDrive;
|
|
149
|
+
again.disabled = !allowed;
|
|
150
|
+
const hint = root.querySelector('.arc-over .hint');
|
|
151
|
+
if (hint) hint.hidden = allowed;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (!root.hidden) raf = requestAnimationFrame(loop);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function update(dt) {
|
|
158
|
+
const g = game;
|
|
159
|
+
g.t += dt;
|
|
160
|
+
g.x += (laneX(g.lane) - g.x) * Math.min(1, dt * 14);
|
|
161
|
+
for (const s of g.sparks) {
|
|
162
|
+
s.x += s.vx * dt;
|
|
163
|
+
s.y += s.vy * dt;
|
|
164
|
+
s.life -= dt;
|
|
165
|
+
}
|
|
166
|
+
g.sparks = g.sparks.filter((s) => s.life > 0);
|
|
167
|
+
for (const p of g.popups) {
|
|
168
|
+
p.y -= 40 * dt;
|
|
169
|
+
p.life -= dt;
|
|
170
|
+
}
|
|
171
|
+
g.popups = g.popups.filter((p) => p.life > 0);
|
|
172
|
+
if (g.over || g.paused) return;
|
|
173
|
+
if (g.countdown > 0) {
|
|
174
|
+
g.countdown -= dt;
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
g.speed = Math.min(760, g.speed + dt * 9);
|
|
178
|
+
g.dist += g.speed * dt;
|
|
179
|
+
g.score += (g.speed * dt) / 12;
|
|
180
|
+
|
|
181
|
+
g.nextSpawn -= dt;
|
|
182
|
+
if (g.nextSpawn <= 0) {
|
|
183
|
+
spawnRow();
|
|
184
|
+
g.nextSpawn = Math.max(0.42, 1.25 - g.dist / 22000) * (0.75 + Math.random() * 0.5);
|
|
185
|
+
}
|
|
186
|
+
g.nextCoin -= dt;
|
|
187
|
+
if (g.nextCoin <= 0) {
|
|
188
|
+
const lane = Math.floor(Math.random() * LANES);
|
|
189
|
+
g.coins.push({ lane, x: laneX(lane), y: -40 });
|
|
190
|
+
g.nextCoin = 2 + Math.random() * 3;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
for (const o of g.obstacles) o.y += (g.speed + o.own) * dt;
|
|
194
|
+
g.obstacles = g.obstacles.filter((o) => o.y < H + 160);
|
|
195
|
+
for (const c of g.coins) c.y += g.speed * dt;
|
|
196
|
+
|
|
197
|
+
const py = H - 110;
|
|
198
|
+
const hit = (o) => Math.abs(o.x - g.x) < (o.w + CAR.w) / 2 - 6 && Math.abs(o.y - py) < (o.h + CAR.h) / 2 - 8;
|
|
199
|
+
for (const c of g.coins) {
|
|
200
|
+
if (!c.taken && Math.abs(c.x - g.x) < 34 && Math.abs(c.y - py) < 44) {
|
|
201
|
+
c.taken = true;
|
|
202
|
+
g.score += 50;
|
|
203
|
+
g.popups.push({ x: c.x, y: c.y, text: tx('arcade.coffee'), life: 1 });
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
g.coins = g.coins.filter((c) => !c.taken && c.y < H + 40);
|
|
207
|
+
if (g.obstacles.some(hit)) crash(py);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async function crash(py) {
|
|
211
|
+
const g = game;
|
|
212
|
+
g.over = true;
|
|
213
|
+
for (let i = 0; i < 40; i++) {
|
|
214
|
+
const a = Math.random() * Math.PI * 2;
|
|
215
|
+
const sp = 60 + Math.random() * 260;
|
|
216
|
+
g.sparks.push({ x: g.x, y: py, vx: Math.cos(a) * sp, vy: Math.sin(a) * sp, life: 0.6 + Math.random() * 0.6, c: i % 2 ? '#ffb347' : '#ff4d4f' });
|
|
217
|
+
}
|
|
218
|
+
const score = Math.round(g.score);
|
|
219
|
+
let best = g.best;
|
|
220
|
+
let newBest = score > best;
|
|
221
|
+
if (newBest) {
|
|
222
|
+
best = score;
|
|
223
|
+
saveBestLocal(score);
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
const r = await api('POST', '/api/arcade', { score });
|
|
227
|
+
best = Math.max(best, r.best);
|
|
228
|
+
newBest = newBest || r.newBest;
|
|
229
|
+
} catch {
|
|
230
|
+
/* offline: keep the local best */
|
|
231
|
+
}
|
|
232
|
+
if (game !== g) return;
|
|
233
|
+
g.best = best;
|
|
234
|
+
const box = root.querySelector('.arc-over');
|
|
235
|
+
if (!box) return;
|
|
236
|
+
const allowed = canPlay() || testDrive;
|
|
237
|
+
box.innerHTML = `
|
|
238
|
+
<h2>${tx('arcade.crash')}</h2>
|
|
239
|
+
<div class="arc-score">${score}</div>
|
|
240
|
+
<div class="muted">${tx('arcade.best')}: ${best}</div>
|
|
241
|
+
${newBest ? `<div class="arc-best">${tx('arcade.newBest')}</div>` : ''}
|
|
242
|
+
<div class="arc-actions">
|
|
243
|
+
<button class="primary" data-arc="again" ${allowed ? '' : `disabled title="${tx('arcade.againLocked')}"`}>${tx('arcade.again')}</button>
|
|
244
|
+
<button data-arc="quit">${tx('arcade.close')}</button>
|
|
245
|
+
</div>
|
|
246
|
+
<div class="hint" ${allowed ? 'hidden' : ''}>${tx('arcade.againLocked')}</div>`;
|
|
247
|
+
box.hidden = false;
|
|
248
|
+
box.querySelector('[data-arc="quit"]').onclick = close;
|
|
249
|
+
box.querySelector('[data-arc="again"]').onclick = () => {
|
|
250
|
+
if (!canPlay() && !testDrive) return toast(tx('arcade.againLocked'), 'info');
|
|
251
|
+
game = newGame();
|
|
252
|
+
box.hidden = true;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// ---------------------------------------------------------------- drawing
|
|
257
|
+
|
|
258
|
+
function carShape(c, x, y, w, h, color, flip) {
|
|
259
|
+
c.save();
|
|
260
|
+
c.translate(x, y);
|
|
261
|
+
if (flip) c.rotate(Math.PI);
|
|
262
|
+
c.fillStyle = 'rgba(0,0,0,.3)';
|
|
263
|
+
c.beginPath();
|
|
264
|
+
c.roundRect(-w / 2 + 3, -h / 2 + 4, w, h, 8);
|
|
265
|
+
c.fill();
|
|
266
|
+
c.fillStyle = color;
|
|
267
|
+
c.beginPath();
|
|
268
|
+
c.roundRect(-w / 2, -h / 2, w, h, 8);
|
|
269
|
+
c.fill();
|
|
270
|
+
c.fillStyle = 'rgba(150,200,255,.85)';
|
|
271
|
+
c.beginPath();
|
|
272
|
+
c.roundRect(-w / 2 + 5, -h / 2 + 12, w - 10, h * 0.2, 3);
|
|
273
|
+
c.fill();
|
|
274
|
+
c.fillStyle = 'rgba(150,200,255,.55)';
|
|
275
|
+
c.beginPath();
|
|
276
|
+
c.roundRect(-w / 2 + 6, h / 2 - h * 0.25, w - 12, h * 0.14, 3);
|
|
277
|
+
c.fill();
|
|
278
|
+
c.fillStyle = '#fff6b0';
|
|
279
|
+
c.fillRect(-w / 2 + 4, -h / 2, 7, 3);
|
|
280
|
+
c.fillRect(w / 2 - 11, -h / 2, 7, 3);
|
|
281
|
+
c.fillStyle = '#ff4d4f';
|
|
282
|
+
c.fillRect(-w / 2 + 4, h / 2 - 3, 7, 3);
|
|
283
|
+
c.fillRect(w / 2 - 11, h / 2 - 3, 7, 3);
|
|
284
|
+
c.restore();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function draw() {
|
|
288
|
+
const cv = root.querySelector('canvas');
|
|
289
|
+
if (!cv) return;
|
|
290
|
+
const c = cv.getContext('2d');
|
|
291
|
+
const g = game;
|
|
292
|
+
// grass & road
|
|
293
|
+
c.fillStyle = '#5f9e4f';
|
|
294
|
+
c.fillRect(0, 0, W, H);
|
|
295
|
+
c.fillStyle = '#4c8a3f';
|
|
296
|
+
const off = (g.dist * 0.5) % 60;
|
|
297
|
+
for (let y = -60 + off; y < H; y += 60) {
|
|
298
|
+
c.fillRect(8, y, 18, 18);
|
|
299
|
+
c.fillRect(W - 26, y + 30, 18, 18);
|
|
300
|
+
}
|
|
301
|
+
c.fillStyle = '#3a4152';
|
|
302
|
+
c.fillRect(ROAD_X - 6, 0, LANES * LANE_W + 12, H);
|
|
303
|
+
c.fillStyle = '#cfd4dc';
|
|
304
|
+
c.fillRect(ROAD_X - 6, 0, 4, H);
|
|
305
|
+
c.fillRect(ROAD_X + LANES * LANE_W + 2, 0, 4, H);
|
|
306
|
+
const dash = g.dist % 60;
|
|
307
|
+
c.fillStyle = 'rgba(255,255,255,.6)';
|
|
308
|
+
for (const k of [1, 3]) for (let y = -60 + dash; y < H; y += 60) c.fillRect(ROAD_X + LANE_W * k - 2, y, 4, 32);
|
|
309
|
+
c.fillStyle = '#f4c430';
|
|
310
|
+
c.fillRect(ROAD_X + LANE_W * 2 - 5, 0, 3, H);
|
|
311
|
+
c.fillRect(ROAD_X + LANE_W * 2 + 2, 0, 3, H);
|
|
312
|
+
|
|
313
|
+
// coins (coffee cups)
|
|
314
|
+
c.font = '26px system-ui, sans-serif';
|
|
315
|
+
c.textAlign = 'center';
|
|
316
|
+
c.textBaseline = 'middle';
|
|
317
|
+
for (const k of g.coins) c.fillText('☕', k.x, k.y + Math.sin(g.t * 6 + k.lane) * 3);
|
|
318
|
+
|
|
319
|
+
for (const o of g.obstacles) {
|
|
320
|
+
if (o.kind === 'cone') {
|
|
321
|
+
c.fillStyle = '#ff7b00';
|
|
322
|
+
c.beginPath();
|
|
323
|
+
c.moveTo(o.x, o.y - 14);
|
|
324
|
+
c.lineTo(o.x + 11, o.y + 12);
|
|
325
|
+
c.lineTo(o.x - 11, o.y + 12);
|
|
326
|
+
c.fill();
|
|
327
|
+
c.fillStyle = '#fff';
|
|
328
|
+
c.fillRect(o.x - 6, o.y, 12, 4);
|
|
329
|
+
} else if (o.kind === 'oil') {
|
|
330
|
+
c.fillStyle = 'rgba(20,20,30,.85)';
|
|
331
|
+
c.beginPath();
|
|
332
|
+
c.ellipse(o.x, o.y, 24, 16, 0.3, 0, Math.PI * 2);
|
|
333
|
+
c.fill();
|
|
334
|
+
c.fillStyle = 'rgba(120,90,200,.35)';
|
|
335
|
+
c.beginPath();
|
|
336
|
+
c.ellipse(o.x - 5, o.y - 4, 9, 5, 0.3, 0, Math.PI * 2);
|
|
337
|
+
c.fill();
|
|
338
|
+
} else {
|
|
339
|
+
carShape(c, o.x, o.y, o.w, o.h, o.kind === 'truck' ? '#6c757d' : o.color, o.oncoming);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// the boss's car
|
|
344
|
+
const py = H - 110;
|
|
345
|
+
const tilt = (laneX(g.lane) - g.x) * -0.004;
|
|
346
|
+
c.save();
|
|
347
|
+
c.translate(g.x, py);
|
|
348
|
+
c.rotate(tilt);
|
|
349
|
+
carShape(c, 0, 0, CAR.w, CAR.h, '#ff3b30', false);
|
|
350
|
+
c.fillStyle = '#fff';
|
|
351
|
+
c.font = '700 11px system-ui, sans-serif';
|
|
352
|
+
c.fillText('BOSS', 0, 6);
|
|
353
|
+
c.restore();
|
|
354
|
+
|
|
355
|
+
for (const s of g.sparks) {
|
|
356
|
+
c.globalAlpha = Math.max(0, Math.min(1, s.life * 2));
|
|
357
|
+
c.fillStyle = s.c;
|
|
358
|
+
c.fillRect(s.x - 3, s.y - 3, 6, 6);
|
|
359
|
+
}
|
|
360
|
+
c.globalAlpha = 1;
|
|
361
|
+
c.font = '700 16px system-ui, sans-serif';
|
|
362
|
+
for (const p of g.popups) {
|
|
363
|
+
c.globalAlpha = Math.max(0, p.life);
|
|
364
|
+
c.fillStyle = '#fff7d6';
|
|
365
|
+
c.fillText(p.text, p.x, p.y);
|
|
366
|
+
}
|
|
367
|
+
c.globalAlpha = 1;
|
|
368
|
+
|
|
369
|
+
// HUD
|
|
370
|
+
c.fillStyle = 'rgba(10,12,18,.65)';
|
|
371
|
+
c.beginPath();
|
|
372
|
+
c.roundRect(10, 10, W - 20, 40, 10);
|
|
373
|
+
c.fill();
|
|
374
|
+
c.font = '700 15px system-ui, sans-serif';
|
|
375
|
+
c.fillStyle = '#fff';
|
|
376
|
+
c.textAlign = 'left';
|
|
377
|
+
c.fillText(`${tx('arcade.score')}: ${Math.round(g.score)}`, 22, 30);
|
|
378
|
+
c.textAlign = 'center';
|
|
379
|
+
c.fillText(`${tx('arcade.speed')}: ${Math.round(g.speed / 4)} km/h`, W / 2, 30);
|
|
380
|
+
c.textAlign = 'right';
|
|
381
|
+
c.fillStyle = '#ffd66b';
|
|
382
|
+
c.fillText(`${tx('arcade.best')}: ${Math.max(g.best, Math.round(g.score))}`, W - 22, 30);
|
|
383
|
+
c.textAlign = 'center';
|
|
384
|
+
|
|
385
|
+
if (g.countdown > 0) {
|
|
386
|
+
const n = Math.ceil(g.countdown);
|
|
387
|
+
c.fillStyle = 'rgba(0,0,0,.35)';
|
|
388
|
+
c.fillRect(0, 0, W, H);
|
|
389
|
+
c.fillStyle = '#fff';
|
|
390
|
+
c.font = '900 90px system-ui, sans-serif';
|
|
391
|
+
c.fillText(String(n), W / 2, H / 2 - 20);
|
|
392
|
+
c.font = '700 20px system-ui, sans-serif';
|
|
393
|
+
c.fillText(tx('arcade.go'), W / 2, H / 2 + 50);
|
|
394
|
+
} else if (g.paused) {
|
|
395
|
+
c.fillStyle = 'rgba(0,0,0,.45)';
|
|
396
|
+
c.fillRect(0, 0, W, H);
|
|
397
|
+
c.fillStyle = '#fff';
|
|
398
|
+
c.font = '700 22px system-ui, sans-serif';
|
|
399
|
+
c.fillText(tx('arcade.paused'), W / 2, H / 2);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
window.openArcade = open;
|
|
404
|
+
document.getElementById('btn-arcade').onclick = () => open();
|
|
405
|
+
|
|
406
|
+
// http://127.0.0.1:4321/#test-drive opens the game right away, lock or not.
|
|
407
|
+
let testDrive = false;
|
|
408
|
+
const checkHash = () => {
|
|
409
|
+
if (location.hash !== '#test-drive') return;
|
|
410
|
+
testDrive = true;
|
|
411
|
+
history.replaceState(null, '', location.pathname);
|
|
412
|
+
setTimeout(() => open(true), 600);
|
|
413
|
+
};
|
|
414
|
+
window.addEventListener('hashchange', checkHash);
|
|
415
|
+
checkHash();
|
|
416
|
+
})();
|