@maco-online/shuttle-blitz-rules 0.1.0 → 0.1.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.
@@ -3,7 +3,7 @@ import type { SimInput } from '../sim/match.ts';
3
3
  import type { MatchState } from '../sim/state.ts';
4
4
  import type { ActionId, Side } from '../sim/types.ts';
5
5
  /** Bump when a client and a room can no longer talk to each other; the room refuses a client that sends another one. */
6
- export declare const ONLINE_PROTOCOL = 1;
6
+ export declare const ONLINE_PROTOCOL = 2;
7
7
  /** The room's name on the Colyseus server. */
8
8
  export declare const ONLINE_ROOM = "shuttle-blitz";
9
9
  /** Simulation and input rate in Hz: one input frame advances the match exactly one step. */
package/dist/net/wire.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Bump when a client and a room can no longer talk to each other; the room refuses a client that sends another one. */
2
- export const ONLINE_PROTOCOL = 1;
2
+ export const ONLINE_PROTOCOL = 2;
3
3
  /** The room's name on the Colyseus server. */
4
4
  export const ONLINE_ROOM = 'shuttle-blitz';
5
5
  /** Simulation and input rate in Hz: one input frame advances the match exactly one step. */
package/dist/sim/match.js CHANGED
@@ -69,6 +69,10 @@ export function updateShuttle(ctx, dt) {
69
69
  if (sh.y >= FLOOR - 6 && sh.vy > 0)
70
70
  land(ctx);
71
71
  }
72
+ /** The solo game: a person plays the left side against the AI. */
73
+ const SOLO_HUMANS = new Set(['p']);
74
+ /** A two-player match: a person plays each side, so both get the player's shots. */
75
+ const PVP_HUMANS = new Set(['p', 'ai']);
72
76
  export function createMatch(cfg, rng) {
73
77
  assertConfig(cfg);
74
78
  const training = cfg.mode === 'training';
@@ -103,7 +107,7 @@ export function createMatch(cfg, rng) {
103
107
  train: training && cfg.trainingId ? makeTrainState(cfg.trainingId) : null,
104
108
  };
105
109
  const slow = createSlowMo();
106
- const ctx = { s, rng, out: [], slow };
110
+ const ctx = { s, rng, out: [], slow, humans: SOLO_HUMANS };
107
111
  if (s.train) {
108
112
  s.phase = 'feed';
109
113
  ctx.out.push({
@@ -296,7 +300,7 @@ export function createPvpMatch(rng, bestOf = 3) {
296
300
  train: null,
297
301
  };
298
302
  const slow = createSlowMo();
299
- const ctx = { s, rng, out: [], slow };
303
+ const ctx = { s, rng, out: [], slow, humans: PVP_HUMANS };
300
304
  setupServe(ctx);
301
305
  const drain = () => {
302
306
  const out = ctx.out;
package/dist/sim/shots.js CHANGED
@@ -78,9 +78,9 @@ export function strike(ctx, a, type, power, o) {
78
78
  const careful = q > 0.38;
79
79
  const scatter = (rng.next() * 2 - 1) * err * 200;
80
80
  const lowSave = sh.y > RESCUE_Y;
81
- // The jump-smash reward and the wider cross are the player's tools; the AI keeps the mockup's shots, so its strength
82
- // across the career only moves through its brain (src/sim/ai.ts).
83
- const player = a.side === 'p';
81
+ // The jump-smash reward and the wider cross are a person's tools, on either side of a two-player match; the solo AI
82
+ // keeps the mockup's shots, so its strength across the career only moves through its brain (src/sim/ai.ts).
83
+ const player = ctx.humans.has(a.side);
84
84
  const air = player && !a.onGround;
85
85
  const returnsSmash = player && sh.kind === 'smash' && sh.lastHitter !== a.side;
86
86
  const shift = (legacy) => (o.cross ? (player ? CROSS_SHIFT : legacy) : 0);
@@ -136,11 +136,11 @@ export function strike(ctx, a, type, power, o) {
136
136
  pop(ctx, POP_KEYS.kmh, sh.x, sh.y + 50, 'speed', { kmh: sh.kmh });
137
137
  ctx.out.push({ type: 'excite', amount: 0.6 });
138
138
  }
139
- if (o.perfect && a.side === 'p')
139
+ if (o.perfect && player)
140
140
  pop(ctx, POP_KEYS.perfect, sh.x, sh.y - 90, 'perfect');
141
141
  if (returnsSmash)
142
142
  pop(ctx, POP_KEYS.smashSave, sh.x, sh.y - 140, 'save');
143
- if (o.cross && a.side === 'p')
143
+ if (o.cross && player)
144
144
  pop(ctx, POP_KEYS.cross, sh.x + 60, sh.y + 40, 'small');
145
145
  if (rescue) {
146
146
  pop(ctx, POP_KEYS.rescue, sh.x, sh.y - 120, 'save');
@@ -201,7 +201,7 @@ export function launchServe(ctx, a, type, v, cross = false) {
201
201
  s.stats.shots++;
202
202
  ctx.out.push({ type: 'hit', side: a.side, kind: type, power: type === 'drop' ? 0.2 : 0.5, x: sh.x, y: sh.y });
203
203
  ctx.out.push({ type: 'bannerHide' });
204
- if (cross && a.side === 'p')
204
+ if (cross && ctx.humans.has(a.side))
205
205
  pop(ctx, POP_KEYS.cross, sh.x + 60, sh.y + 40, 'small');
206
206
  }
207
207
  /**
@@ -161,5 +161,7 @@ export interface SimCtx {
161
161
  rng: Rng;
162
162
  out: SimEvent[];
163
163
  slow: SlowMo;
164
+ /** The sides a person plays: the solo game's player only, or both sides of a two-player match. */
165
+ humans: ReadonlySet<Side>;
164
166
  }
165
167
  export declare const other: (side: Side) => Side;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maco-online/shuttle-blitz-rules",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Shuttle Blitz simulation, online wire format and the room game definition that runs it on the Maco online server",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,10 +28,10 @@
28
28
  "dist"
29
29
  ],
30
30
  "maco": {
31
- "protocolVersion": 1
31
+ "protocolVersion": 2
32
32
  },
33
33
  "dependencies": {
34
- "@maco-online/online-core": "0.1.0"
34
+ "@maco-online/online-core": "0.2.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "zod": "^4.1.12"