@uzuhq/code-cli 0.4.0 → 0.5.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/dist/dev-server/game-room.js +28 -14
- package/dist/harness/dev-button.js +7 -1
- package/dist/harness/mount.js +12 -0
- package/package.json +1 -1
|
@@ -209,14 +209,17 @@ export class GameRoom {
|
|
|
209
209
|
const tickNow = Date.now();
|
|
210
210
|
const tickDraft = new ScheduleDraft(tickNow, (a) => this.hasAction(a));
|
|
211
211
|
try {
|
|
212
|
-
this.logic.update(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
212
|
+
this.logic.update({
|
|
213
|
+
state: this.gameState,
|
|
214
|
+
ctx: {
|
|
215
|
+
random: this.random,
|
|
216
|
+
tick: this.tickCount,
|
|
217
|
+
now: tickNow,
|
|
218
|
+
schedule: (o) => tickDraft.schedule(o),
|
|
219
|
+
unschedule: (k) => tickDraft.unschedule(k),
|
|
220
|
+
emit,
|
|
221
|
+
playerInputs: this.playerInputs,
|
|
222
|
+
},
|
|
220
223
|
});
|
|
221
224
|
}
|
|
222
225
|
catch (err) {
|
|
@@ -385,14 +388,25 @@ export class GameRoom {
|
|
|
385
388
|
try {
|
|
386
389
|
// 決定的な部分を先に走らせ、serverActions がその結果を見られるようにする。
|
|
387
390
|
if (plain && !legacyServerOnly) {
|
|
388
|
-
plain(
|
|
391
|
+
plain({
|
|
392
|
+
state: this.gameState,
|
|
393
|
+
payload: payload ?? {},
|
|
394
|
+
playerId: senderId,
|
|
395
|
+
ctx: { now, emit, ...scheduleCtx },
|
|
396
|
+
});
|
|
389
397
|
}
|
|
390
398
|
if (serverHandler) {
|
|
391
|
-
await serverHandler(
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
399
|
+
await serverHandler({
|
|
400
|
+
state: this.gameState,
|
|
401
|
+
payload: payload ?? {},
|
|
402
|
+
playerId: senderId,
|
|
403
|
+
ctx: {
|
|
404
|
+
tick: this.tickCount,
|
|
405
|
+
random: this.random ?? new SeededRandomImpl(this.seed),
|
|
406
|
+
now,
|
|
407
|
+
emit: serverEmit,
|
|
408
|
+
...scheduleCtx,
|
|
409
|
+
},
|
|
396
410
|
});
|
|
397
411
|
}
|
|
398
412
|
}
|
|
@@ -17,7 +17,7 @@ function isInspectorOpen() {
|
|
|
17
17
|
* UZU ボタン (button 要素) にタップメニューを配線する。 メニューはボタン直下に出る。
|
|
18
18
|
*/
|
|
19
19
|
export function attachUzuMenu(button, opts = {}) {
|
|
20
|
-
const { stateGetter, playerCount, adminEnabled, resetGame, onOpenMobile } = opts;
|
|
20
|
+
const { stateGetter, playerCount, adminEnabled, resetGame, onOpenMobile, onOpenSingleView } = opts;
|
|
21
21
|
let popup = null;
|
|
22
22
|
const closePopup = () => {
|
|
23
23
|
popup?.remove();
|
|
@@ -81,6 +81,12 @@ export function attachUzuMenu(button, opts = {}) {
|
|
|
81
81
|
el.appendChild(b);
|
|
82
82
|
return b;
|
|
83
83
|
};
|
|
84
|
+
if (onOpenSingleView) {
|
|
85
|
+
addAction('🖥 この画面だけ開く', '#0984e3', '#74b9ff', () => {
|
|
86
|
+
onOpenSingleView();
|
|
87
|
+
closePopup();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
84
90
|
if (onOpenMobile) {
|
|
85
91
|
addAction('📱 スマホで開く', '#0984e3', '#74b9ff', () => {
|
|
86
92
|
onOpenMobile();
|
package/dist/harness/mount.js
CHANGED
|
@@ -320,6 +320,15 @@ function resolveMobileUrl(opts, playerIndex) {
|
|
|
320
320
|
const port = location.port ? `:${location.port}` : '';
|
|
321
321
|
return `http://${host}${port}/?player=${playerIndex}`;
|
|
322
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* その player の単体表示 (`?player=N`) URL。 実機リンクと違い LAN host には
|
|
325
|
+
* 読み替えず、 いま harness を見ている origin をそのまま使う。
|
|
326
|
+
*/
|
|
327
|
+
function singleViewUrl(playerIndex) {
|
|
328
|
+
const url = new URL(location.href);
|
|
329
|
+
url.searchParams.set('player', String(playerIndex));
|
|
330
|
+
return url.toString();
|
|
331
|
+
}
|
|
323
332
|
/** 携帯リンクの QR ポップアップ (カメラで読めばそのキャラの画面がスマホで開く)。 */
|
|
324
333
|
function openMobileQrPopup(url, label) {
|
|
325
334
|
const backdrop = document.createElement('div');
|
|
@@ -467,6 +476,9 @@ onUzuClick) {
|
|
|
467
476
|
resetGame: opts.resetGame,
|
|
468
477
|
playerCount: opts.playerCount,
|
|
469
478
|
adminEnabled: opts.seats.some((s) => s.kind === 'admin'),
|
|
479
|
+
onOpenSingleView: () => {
|
|
480
|
+
window.open(singleViewUrl(playerIndex), '_blank', 'noopener');
|
|
481
|
+
},
|
|
470
482
|
});
|
|
471
483
|
}
|
|
472
484
|
wrap.appendChild(uzu);
|