@uzuhq/code-cli 0.4.1 → 0.5.1

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.
@@ -162,7 +162,10 @@ export class GameRoom {
162
162
  return;
163
163
  this.seed = Date.now() & 0xffffffff;
164
164
  this.random = new SeededRandomImpl(this.seed);
165
- this.gameState = this.logic.setup(this.seats, this.random);
165
+ this.gameState = this.logic.setup({
166
+ seats: this.seats,
167
+ ctx: { random: this.random, now: Date.now() },
168
+ });
166
169
  this.stateInitialized = true;
167
170
  this.tickCount = 0;
168
171
  this.seq = 0;
@@ -209,14 +212,17 @@ export class GameRoom {
209
212
  const tickNow = Date.now();
210
213
  const tickDraft = new ScheduleDraft(tickNow, (a) => this.hasAction(a));
211
214
  try {
212
- this.logic.update(this.gameState, {
213
- random: this.random,
214
- tick: this.tickCount,
215
- now: tickNow,
216
- schedule: (o) => tickDraft.schedule(o),
217
- unschedule: (k) => tickDraft.unschedule(k),
218
- emit,
219
- playerInputs: this.playerInputs,
215
+ this.logic.update({
216
+ state: this.gameState,
217
+ ctx: {
218
+ random: this.random,
219
+ tick: this.tickCount,
220
+ now: tickNow,
221
+ schedule: (o) => tickDraft.schedule(o),
222
+ unschedule: (k) => tickDraft.unschedule(k),
223
+ emit,
224
+ playerInputs: this.playerInputs,
225
+ },
220
226
  });
221
227
  }
222
228
  catch (err) {
@@ -385,14 +391,25 @@ export class GameRoom {
385
391
  try {
386
392
  // 決定的な部分を先に走らせ、serverActions がその結果を見られるようにする。
387
393
  if (plain && !legacyServerOnly) {
388
- plain(this.gameState, payload ?? {}, senderId, emit, { now, ...scheduleCtx });
394
+ plain({
395
+ state: this.gameState,
396
+ payload: payload ?? {},
397
+ playerId: senderId,
398
+ ctx: { now, emit, ...scheduleCtx },
399
+ });
389
400
  }
390
401
  if (serverHandler) {
391
- await serverHandler(this.gameState, payload ?? {}, senderId, serverEmit, {
392
- tick: this.tickCount,
393
- random: this.random ?? new SeededRandomImpl(this.seed),
394
- now,
395
- ...scheduleCtx,
402
+ await serverHandler({
403
+ state: this.gameState,
404
+ payload: payload ?? {},
405
+ playerId: senderId,
406
+ ctx: {
407
+ tick: this.tickCount,
408
+ random: this.random ?? new SeededRandomImpl(this.seed),
409
+ now,
410
+ emit: serverEmit,
411
+ ...scheduleCtx,
412
+ },
396
413
  });
397
414
  }
398
415
  }
@@ -540,7 +557,10 @@ export class GameRoom {
540
557
  this.seed = opts.seed;
541
558
  }
542
559
  this.random = new SeededRandomImpl(this.seed);
543
- this.gameState = this.logic.setup(this.seats, this.random);
560
+ this.gameState = this.logic.setup({
561
+ seats: this.seats,
562
+ ctx: { random: this.random, now: Date.now() },
563
+ });
544
564
  this.tickCount = 0;
545
565
  // reset は新規ゲーム = 実行可能状態を意味するので pause も解除する。
546
566
  this.tickPaused = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uzuhq/code-cli",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "UZU ゲーム開発 CLI - ビルド・パブリッシュ・プロジェクト作成ツール",
5
5
  "type": "module",
6
6
  "bin": {