playertwo-sdk 0.2.2 → 0.2.3

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.
Files changed (3) hide show
  1. package/index.d.ts +18 -4
  2. package/package.json +1 -1
  3. package/room.d.ts +18 -2
package/index.d.ts CHANGED
@@ -303,8 +303,10 @@ export interface RoomPlayer {
303
303
  kind: string;
304
304
  /** Their connection dropped; their seat is held for them (20 s). */
305
305
  away: boolean;
306
- /** Their rating in this game (room.result in room.js), once they have one. */
306
+ /** Their rating in this room's mode (room.result in room.js; 1v1 and 3v3 rated apart), once they have one. */
307
307
  rating?: number;
308
+ /** Their team, 1 to room.teams, in a room with teams. */
309
+ team?: number;
308
310
  }
309
311
 
310
312
  export interface MatchOptions {
@@ -312,6 +314,8 @@ export interface MatchOptions {
312
314
  mode?: string;
313
315
  /** 1 to 64 players. */
314
316
  size?: number;
317
+ /** How many teams (2 to 16), the size split evenly between them: each player's team is in room.players. */
318
+ teams?: number;
315
319
  }
316
320
 
317
321
  export interface JoinOptions extends MatchOptions {
@@ -320,14 +324,18 @@ export interface JoinOptions extends MatchOptions {
320
324
  /** The room you were in (room.id), to come back to it. */
321
325
  room?: string;
322
326
  resume?: string;
323
- /** A match by skill: rooms of players rated near you first (the game's own ratings: room.result in room.js). */
327
+ /** A match by skill: rooms of players rated near you first (the game's own ratings in this mode: room.result in
328
+ room.js). */
324
329
  skill?: boolean;
330
+ /** A match for your whole party: every member who asks with together is seated in the same room, on one team (their
331
+ seats held 30 s while they come), and players on their own fill the other teams. Rejects no-party, party-too-big. */
332
+ together?: boolean;
325
333
  /** Keep the room as a replay, from its first player (a scripted room's code says so itself: room.record). */
326
334
  record?: boolean;
327
335
  }
328
336
 
329
337
  /** One of the game's public rooms open now (p2.rooms.live), to watch. */
330
- export interface LiveRoom { id: string; mode: string; size: number; players: number; watchers: number; skill: number | null; closed: boolean }
338
+ export interface LiveRoom { id: string; mode: string; size: number; teams?: number; players: number; watchers: number; skill: number | null; closed: boolean }
331
339
  /** One of the game's replays (p2.rooms.replays). */
332
340
  export interface ReplayInfo { id: string; room: string; mode: string; size: number; players: { id: string; handle: string; name: string }[]; from: number; ms: number }
333
341
  /** A replay's controls (room.replay, on a room from p2.rooms.replay). */
@@ -405,7 +413,9 @@ export interface Voice {
405
413
  export interface SendOptions {
406
414
  /** One player's id, or a list; everyone else in the room when left out. */
407
415
  to?: string | string[];
408
- /** The fast lane: lossy, for updates that the next one replaces (where a thing is, not what happened). */
416
+ /** The fast lane: lossy, for updates that the next one replaces (where a thing is, not what happened). Where it
417
+ can't go player to player (a scripted room, a room over 16), it goes by the room's two sockets in turn, and an
418
+ older one that arrives after a newer one of its type is dropped. */
409
419
  fast?: boolean;
410
420
  }
411
421
 
@@ -538,6 +548,8 @@ export interface Room {
538
548
  readonly code: string | null;
539
549
  readonly mode: string;
540
550
  readonly size: number;
551
+ /** How many teams it has (1: none); each player's team is in room.players. */
552
+ readonly teams: number;
541
553
  /** Your id in the room (the same as p2.player.id). */
542
554
  readonly me: string;
543
555
  /** The host's id: whoever has been here longest. */
@@ -589,6 +601,8 @@ export interface Room {
589
601
  /** why: "left", "dropped", "kicked", ... */
590
602
  on(type: "leave", fn: (player: RoomPlayer | { id: string }, why: string) => void): () => void;
591
603
  on(type: "host", fn: (id: string) => void): () => void;
604
+ /** The room's code moved a player to another team (room.team in room.js). */
605
+ on(type: "team", fn: (id: string, team: number) => void): () => void;
592
606
  /** A key changed (value null: taken away); by: who wrote it. */
593
607
  on(type: "state", fn: (key: string, value: any, by: string | null) => void): () => void;
594
608
  /** `from` is the sending player's id, or null for the room's own code (a scripted room's room.js). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playertwo-sdk",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "license": "MIT",
5
5
  "description": "Player Two's game SDK: trophies, leaderboards, saves and multiplayer rooms for games hosted on Player Two, with TypeScript types",
6
6
  "type": "module",
package/room.d.ts CHANGED
@@ -32,8 +32,11 @@ export interface Player {
32
32
  level: number;
33
33
  /** What the game kept of them with room.save (in any of its rooms, any time before), or null. */
34
34
  saved: Json | null;
35
- /** Their rating in this game (room.result moves it; 1500 before their first match). */
35
+ /** Their rating in this room's mode (room.result moves it; 1v1 and 3v3 apart; a new mode starts from their game
36
+ rating, or 1500). */
36
37
  rating?: number;
38
+ /** Their team, 1 to room.teams, in a room with teams. */
39
+ team?: number;
37
40
  }
38
41
 
39
42
  /** What room.js is handed: the room it runs for. `D` is what you keep in room.data. */
@@ -44,6 +47,9 @@ export type PhysicsBody =
44
47
  | { position: { x: number; y: number; z?: number }; quaternion: { x: number; y: number; z: number; w: number } };
45
48
 
46
49
  export interface Room<D extends object = Record<string, any>> {
50
+ /** The room's id, as its pages have it (room.id). Your build's rooms that run on one machine share your module's
51
+ own variables: keep what is one room's in room.data, or by this. */
52
+ readonly id: string;
47
53
  /** Who is here. */
48
54
  readonly players: readonly Player[];
49
55
  /** One of them, or null. */
@@ -71,8 +77,18 @@ export interface Room<D extends object = Record<string, any>> {
71
77
  /** A match's outcome, best first (each place an id, or a list of those level), or ids by score: every player's rating
72
78
  moves by it (Elo, every two compared), as player.rating, and players are matched by it ({ skill: true }). */
73
79
  result(places: (string | string[])[] | Record<string, number>): void;
74
- /** Closed to matching while a match is under way (false), and open again so its empty places are filled (true). */
80
+ /** Closed to matching while a match is under way (false: a seat by the room's id is refused too, not-open), and open
81
+ again so its empty places are filled (true). */
75
82
  open(on?: boolean): void;
83
+ /** How many teams the room has (1: none). */
84
+ readonly teams: number;
85
+ /** Move a player to a team (1 to room.teams): every page hears "team". False when there is no such player or team. */
86
+ team(id: string, team: number): boolean;
87
+ /** A trusted score for a player on one of the game's leaderboards (kept if it is their best), as the game's own server
88
+ sends it: the way onto a board only its server may send to. Errors show in the studio. */
89
+ score(id: string, board: string, value: number): void;
90
+ /** One of the game's trophies for a player, as its own server gives it (server-only ones too). */
91
+ trophy(id: string, key: string): void;
76
92
  /** Keep the room as a replay from now (true), until record(false) or the room closes (up to 30 minutes). */
77
93
  record(on?: boolean): void;
78
94
  /** What your code moves (enemies, projectiles, a platform), drawn smoothly on every page (room.objects() there):