playertwo-sdk 0.2.12 → 0.2.14

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 (4) hide show
  1. package/README.md +32 -11
  2. package/index.d.ts +106 -13
  3. package/package.json +1 -1
  4. package/room.d.ts +13 -0
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # playertwo-sdk
2
2
 
3
3
  The game SDK for [PlayerTwo](https://playertwo.plus), with TypeScript types. Trophies, XP and levels, stats,
4
- leaderboards, cloud saves, presence, invites, add-ons, in-game purchases, donations to you, the player's avatar, travel
5
- between games, and multiplayer rooms with no server of your own (voice chat, worlds, replays and your own server code in `room.js`
4
+ leaderboards, cloud saves, presence, invites, add-ons, in-game purchases, donations to you, moments to share, the
5
+ player's avatar, travel between games, and multiplayer rooms with no server of your own (voice chat, worlds, replays and your own server code in `room.js`
6
6
  included).
7
7
 
8
8
  PlayerTwo is a game store and a launchpad. Games are sold (or free) to play in the browser or download, and raises
@@ -74,8 +74,9 @@ with code `not-on-player-two`; with `{ required: true }` the page says "Play thi
74
74
  | Stats | `p2.stats.get()`, `.get(key)`, `.set(key, n)`, `.add(key, n?)` | [call-stats](https://playertwo.plus/docs/sdk#call-stats) |
75
75
  | Cloud saves (8 slots, 1 MB each) | `p2.saves.list()`, `.get(slot)`, `.put(slot, data, { version })`, `.delete(slot)` | [call-saves](https://playertwo.plus/docs/sdk#call-saves) |
76
76
  | Add-ons (sold on the game's page) | `p2.addons.list()`, `p2.addons.has(key)` | [addons](https://playertwo.plus/docs/sdk#addons) |
77
- | In-game purchases | `p2.store.list()`, `.owned()`, `.buy(key)`, `.pay(chargeId)` | [purchases](https://playertwo.plus/docs/sdk#purchases) |
77
+ | In-game purchases | `p2.store.list({ coming })`, `.owned()`, `.access()`, `.sold(refs)`, `.buy(key)`, `.pay(chargeId)` | [purchases](https://playertwo.plus/docs/sdk#purchases) |
78
78
  | Donations to you | `p2.donate.available()`, `.open()`, `.button({ corner, parent })` | [donate](https://playertwo.plus/docs/sdk#donate) |
79
+ | Moments to share, on your results screen | `p2.moments.offer()` | [moments](https://playertwo.plus/docs/sdk#moments) |
79
80
  | Presence | `p2.presence.set(line, { join })` | [call-presence](https://playertwo.plus/docs/sdk#call-presence) |
80
81
  | Identity and invites | `p2.identity()`, `p2.invite(params)`, `p2.params` | [call-identity](https://playertwo.plus/docs/sdk#call-identity) |
81
82
  | Loading and play events | `p2.loading.done()`, `p2.gameplay.start()`, `.stop()` | [call-gameplay](https://playertwo.plus/docs/sdk#call-gameplay) |
@@ -97,6 +98,7 @@ Multiplayer, through `p2.rooms`:
97
98
  | Smooth movement | `room.sync(object, options)` | [rooms-sync](https://playertwo.plus/docs/sdk#rooms-sync) |
98
99
  | Ping, stats, the room's clock | `room.ping()`, `room.stats()`, `room.now()` | [rooms-fast](https://playertwo.plus/docs/sdk#rooms-fast) |
99
100
  | Your server code (`room.js`) | see below | [rooms-scripted](https://playertwo.plus/docs/sdk#rooms-scripted) |
101
+ | What each player owns of your store, in `room.js` | `player.owned`, `room.owned(id)`, `room.owns(id, keyOrRef)`, `onOwned` | [rooms-scripted](https://playertwo.plus/docs/sdk#rooms-scripted) |
100
102
  | Input-run rooms (client prediction, corrected by the server's state) | `room.inputs({ state, input, step })` | [rooms-inputs](https://playertwo.plus/docs/sdk#rooms-inputs) |
101
103
  | Corrections and lag-compensated hits | `onSync`, `room.correct`, `room.past` (room.js); `sync.seen(id)` | [rooms-corrections](https://playertwo.plus/docs/sdk#rooms-corrections) |
102
104
  | Server-moved objects | `room.objects()` (page), `room.objects.set` (room.js) | [rooms-objects](https://playertwo.plus/docs/sdk#rooms-objects) |
@@ -111,7 +113,7 @@ Multiplayer, through `p2.rooms`:
111
113
  | A bad connection, on purpose | `p2.rooms.simulate({ lag, jitter, loss })` or `?p2-net=150,30,0.02` | [rooms-simulate](https://playertwo.plus/docs/sdk#rooms-simulate) |
112
114
 
113
115
  Rooms are 1 to 64 players (256 in an area of a world) and are for games hosted on PlayerTwo (a build you push, or
114
- your own site served through PlayerTwo). A release never mixes versions in a room. All limits:
116
+ a game already played from its own site that PlayerTwo serves). A release never mixes versions in a room. All limits:
115
117
  https://playertwo.plus/docs/sdk#rooms-limits.
116
118
 
117
119
  ## A room's server: `playertwo-sdk/room`
@@ -193,11 +195,24 @@ Using the script tag and only want the types of the global `PlayerTwo`? Add `"ty
193
195
 
194
196
  Two ways, and a game can use both: products you make in your studio (`p2.store.buy(key)`), or charges your own server
195
197
  makes at its own prices with your game key (`p2.store.pay(chargeId)`). PlayerTwo's own card takes the player's yes
196
- and the payment from their PlayerTwo balance (USDC on Base). You get 80% of every in-game purchase, PlayerTwo keeps
198
+ and the payment from their PlayerTwo balance (one balance, added by card, PayPal or stablecoins), showing the piece's
199
+ picture big when you give one. You get 80% of every in-game purchase, PlayerTwo keeps
197
200
  20% (less your backers' share if your game raised with a share of its sales). Add-ons sold on the game's page are split
198
201
  as its sales are: PlayerTwo keeps 20%. Every purchase gives your game a signed receipt (a JWT typed `p2-buy`, RS256,
199
- keys at https://playertwo.plus/.well-known/p2-keys.json) and your studio's webhooks a `purchase` event. Docs:
200
- https://playertwo.plus/docs/sdk#purchases.
202
+ keys at https://playertwo.plus/.well-known/p2-keys.json) and your studio's webhooks a `purchase` event.
203
+
204
+ - **Who may buy:** `p2.store.access()` says where the player stands: `owned`, `free-game`, `free-period` (a paid game
205
+ played free for a while, with `until`), `test` or `none`. Every state but `none` may buy in the game, and what they
206
+ buy stays theirs.
207
+ - **Counts:** each product's `owners` ("Owned by N players"), and `p2.store.sold(refs)`: how many of your charges were
208
+ paid with each ref. A paid charge carries its `number` among them, for "#12 of Season 1".
209
+ - **Seasons:** a product's `onSaleFrom` and `onSaleUntil` take it on and off sale by themselves, and its owners keep it.
210
+ `p2.store.list({ coming: true })` lists the ones not on sale yet, `coming: true`, never buyable.
211
+ - **Packs:** a pack can be sold only to a player who owns none of its pieces (`noneOwned`).
212
+ - **In a room:** each player's `owned` arrives as they take their seat and again when they buy (`onOwned`);
213
+ `room.owns(id, keyOrRef)` refuses a look they don't own.
214
+
215
+ Docs: https://playertwo.plus/docs/sdk#purchases and https://playertwo.plus/docs/sdk#store-access.
201
216
 
202
217
  ## Donations
203
218
 
@@ -205,7 +220,9 @@ Players can donate to your studio for your game, even while it's free. Turn dona
205
220
  Donations) and pick their one place: your game's PlayerTwo page (PlayerTwo's card, in your words, colour and picture),
206
221
  or inside the game. Inside the game, your own button calls `p2.donate.open()` to open PlayerTwo's donation sheet, or
207
222
  `p2.donate.button()` puts PlayerTwo's pixel-heart "Support the dev" button in a corner (or inside an element of yours);
208
- `p2.donate.available()` says whether donations are on inside the game. The entire donation, minus the transaction fees,
223
+ `p2.donate.available()` says whether donations are on inside the game. A press of the player's opens the sheet at once,
224
+ however soon after the last (call `open()` within a second of it); asked without one, it opens at most once every two
225
+ minutes (`too-soon`). The entire donation, minus the transaction fees,
209
226
  goes to your studio: PlayerTwo takes no cut. A donation buys nothing in the game, and the game never learns who gave
210
227
  or how much, so it never belongs in your shop. Docs: https://playertwo.plus/docs/sdk#donate.
211
228
 
@@ -214,15 +231,19 @@ or how much, so it never belongs in your shop. Docs: https://playertwo.plus/docs
214
231
  A game key (`p2g_...`, made in your studio) lets your server check a session or a signed identity from
215
232
  `p2.identity()`, give server-only trophies, post to trusted leaderboards, read add-ons, make and check charges, use up
216
233
  consumables and report matches, under `https://playertwo.plus/api/v1/sdk/server/...`. Docs:
217
- https://playertwo.plus/docs/sdk#server and https://playertwo.plus/docs/sdk/connect (a game played on its own site).
234
+ https://playertwo.plus/docs/sdk#server and https://playertwo.plus/docs/sdk/connect (a game already played on its own
235
+ site).
218
236
 
219
237
  ## Putting it on PlayerTwo
220
238
 
221
239
  A whole game to start from: `npm create playertwo-game@latest my-game` (a small multiplayer Three.js game with rooms
222
240
  and `room.js`, see [create-playertwo-game](https://www.npmjs.com/package/create-playertwo-game)).
223
241
 
224
- 1. Submit the game at https://playertwo.plus/submit (that gives it its address, `your-game`).
225
- 2. Make an agent key in your studio, under Agents.
242
+ 1. Submit the game at https://playertwo.plus/submit with its web build: a zip of its folder (up to 5 GB unpacked,
243
+ 20,000 files, 512 MB a file), sent from your browser a file at a time, or one .html page. That gives it its
244
+ address, `your-game`. Playing from your own site is closed to new games.
245
+ 2. Each update goes up the same way (a zip, from its page's editor in your studio), or pushed: make an agent key in your
246
+ studio, under Agents.
226
247
  3. Push the build:
227
248
 
228
249
  ```
package/index.d.ts CHANGED
@@ -115,6 +115,9 @@ export interface Unlocked {
115
115
  /** The completion trophy, earned with this one. */
116
116
  complete?: Trophy;
117
117
  test?: boolean;
118
+ /** A guest's (p2.guest): kept for them until they sign in, when their account earns it (numbered, with its XP); n is
119
+ null and there is no XP until then. */
120
+ guest?: true;
118
121
  }
119
122
 
120
123
  export interface Addon {
@@ -148,6 +151,9 @@ export interface Submitted {
148
151
  previous: number | null;
149
152
  rank: number | null;
150
153
  total: number | null;
154
+ /** A guest's (p2.guest): their best kept for them until they sign in, when it goes to their account's place on the
155
+ board; no rank or total until then. */
156
+ guest?: true;
151
157
  }
152
158
 
153
159
  export interface BoardRow {
@@ -209,7 +215,7 @@ export interface Product {
209
215
  name: string;
210
216
  about: string;
211
217
  /** Its picture, when its studio gave it one: an https address in PlayerTwo's file store. PlayerTwo's card shows it
212
- beside the name; use it in your own shop too. */
218
+ big, over the name; use it in your own shop too. */
213
219
  picture?: string;
214
220
  /** In US dollars. */
215
221
  price: number;
@@ -220,6 +226,31 @@ export interface Product {
220
226
  owned: boolean;
221
227
  /** A consumable's: how many the player has. */
222
228
  count?: number;
229
+ /** How many players own it ("Owned by N players"): tests not counted; a pack's buyers; a consumable's, everyone who
230
+ ever bought it. Up to 30 seconds behind. */
231
+ owners: number;
232
+ /** Its on-sale dates (ms), or null: outside them it's off sale by itself (its owners keep it). Read your season clock
233
+ from these. */
234
+ onSaleFrom: number | null;
235
+ onSaleUntil: number | null;
236
+ /** Listed by list({ coming: true }) before its on-sale date: never buyable (buy rejects "not-yet"). */
237
+ coming?: boolean;
238
+ /** A pack's: sold only to a player who owns none of its pieces (buy rejects "owns-piece"). */
239
+ noneOwned?: boolean;
240
+ }
241
+
242
+ /** Where the player stands with the game (p2.store.access; docs: /docs/sdk#store-access). Every state but "none" may
243
+ buy in the game, and what they buy stays theirs. */
244
+ export interface Access {
245
+ /** owned: they own it. free-game: it costs nothing. free-period: a paid game played free for a while (never owning
246
+ it). test: its team and testers. none: no-game. */
247
+ state: "owned" | "free-game" | "free-period" | "test" | "none";
248
+ /** A free period by sale: when it ends (ms). */
249
+ until: number | null;
250
+ /** A free period by trial: seconds of play left. */
251
+ left?: number;
252
+ /** What the free period is: the game's free-to-play sale, or the player's own free trial. */
253
+ via?: "sale" | "trial";
223
254
  }
224
255
 
225
256
  /** What the player has of the game's products (a consumable: how many). */
@@ -243,8 +274,9 @@ export type Bought =
243
274
  export type Paid =
244
275
  | {
245
276
  ok: true;
246
- /** `ref`: your own reference for it, as your server gave it. */
247
- charge: { id: string; name: string; ref: string | null };
277
+ /** `ref`: your own reference for it, as your server gave it. `number`: its place among the charges paid with
278
+ that ref (1 for the first; null for a test, or with no ref), for "#12 of Season 1". */
279
+ charge: { id: string; name: string; ref: string | null; number: number | null };
248
280
  /** What was paid, in US dollars (0 for a test). */
249
281
  amount: number;
250
282
  /** A JWT typed "p2-buy" (kind "charge", key the charge's id), RS256 with PlayerTwo's keys, for your own server: an hour. */
@@ -259,14 +291,22 @@ export type Paid =
259
291
  export type SignUpAnswer = { ok: true; card?: true; local?: true } | { ok: false; reason: "cancelled" };
260
292
 
261
293
  export interface Store {
262
- /** Each product on sale, with what the player has of it. */
263
- list(): Promise<Product[]>;
294
+ /** Each product on sale, with what the player has of it; { coming: true } lists those whose on-sale date is ahead
295
+ too, each coming: true and never buyable. */
296
+ list(options?: { coming?: boolean }): Promise<Product[]>;
264
297
  /** What the player has. */
265
298
  owned(): Promise<Holding[]>;
299
+ /** Where the player stands with the game: owned, a free game, a free period (with its end), a test, or none. */
300
+ access(): Promise<Access>;
301
+ /** How many of your charges were paid with each ref (a ref ending in * counts every ref starting so): { [ref]: n }.
302
+ Tests not counted. */
303
+ sold(refs: string[] | string): Promise<Record<string, number>>;
266
304
  /** Asks PlayerTwo to sell one: its own step, outside the game's frame, where the player says yes. Rejects with code
267
305
  "no-store" where it can't (outside PlayerTwo's player on the web), "busy" (its sheet is open already),
268
- "unknown-product", "owned" (a skin, item or mod they have), "no-game" (they don't have the game yet), "guest" or
269
- "offline". */
306
+ "unknown-product" (nothing on sale by that key: retired, or past its on-sale end), "not-yet" (before its on-sale
307
+ start; from: when, ms), "owned" (a skin, item or mod they have), "pack-owned" (a pack whose pieces are all theirs),
308
+ "owns-piece" (a pack sold to players who own none of it; owned: the keys), "no-game" (they may not buy in it: see
309
+ access()), "guest" or "offline". */
270
310
  buy(key: string): Promise<Bought>;
271
311
  /** Asks the player to pay a charge your server made (POST /api/v1/sdk/server/store/charges, your game's key): its
272
312
  name and price on PlayerTwo's card, paid once; one paid already answers its receipt again. Rejects with code
@@ -278,21 +318,67 @@ export interface Store {
278
318
  /** What p2.donate.open() answers: the sheet was shown (never how much, nor whether anything was given), or why not. */
279
319
  export type DonateShown = { shown: true; local?: true } | { shown: false; reason: "off" | "placement" | "too-soon" };
280
320
 
321
+ /** Moments to share (p2.moments; docs: /docs/sdk#moments): the player's best moment of this session, which PlayerTwo
322
+ picks from what the game already sent it (a new best, a rare trophy, a level, the hours), offered on the game's own
323
+ results screen. */
324
+ export interface Moments {
325
+ /** Call it once your results screen is showing, never during play. When the session did something worth sharing,
326
+ PlayerTwo's share sheet opens over the game and this resolves once it closes ({ offered: true, shared }); otherwise
327
+ (nothing worth it, offers turned off, a guest, a test, outside PlayerTwo's player, a second ask this session) it
328
+ resolves { offered: false, shared: false } at once. Never rejects. One ask a session: offered here, closing the game
329
+ asks nothing more. */
330
+ offer(): Promise<{ offered: boolean; shared: boolean }>;
331
+ }
332
+
281
333
  /** Donations to the game's developer (p2.donate; docs: /docs/sdk#donate), when its studio put them inside the game (its
282
334
  one place: the game or its PlayerTwo page). The entire donation, minus the transaction fees, goes to the studio; PlayerTwo takes
283
335
  nothing. A donation buys nothing in the game, and the game never learns of one. */
284
336
  export interface Donate {
285
337
  /** Whether the game takes donations inside itself now. */
286
338
  available(): Promise<boolean>;
287
- /** Opens PlayerTwo's donation sheet over the game (from the player's press on your own button). At most once every
288
- two minutes. Rejects with code "no-donate" outside PlayerTwo's player on the web, "busy" while another of its
289
- sheets is open. */
339
+ /** Opens PlayerTwo's donation sheet over the game (from the player's press on your own button). A press opens it at
340
+ once, however soon after the last (call it within a second of the press: the browser's navigator.userActivation is
341
+ sent with it); without one, at most once every two minutes ("too-soon"). Rejects with code "no-donate" outside
342
+ PlayerTwo's player on the web, "busy" while another of its sheets is open. */
290
343
  open(): Promise<DonateShown>;
291
344
  /** PlayerTwo's own Donate button (a pixel heart, "Support the dev"), for a game that draws none: in a corner of the
292
345
  page, or inside an element of yours. Shown only while the game takes donations inside itself; null otherwise. */
293
346
  button(options?: { corner?: "top-right" | "top-left" | "bottom-right" | "bottom-left"; parent?: HTMLElement }): Promise<HTMLButtonElement | null>;
294
347
  }
295
348
 
349
+ /** Notifications from the game's server (p2.notify; docs: /docs/sdk#notify), to a player who let the game send them: in
350
+ their PlayerTwo notifications, and on their devices where push is on. The server sends with its key (POST
351
+ /api/v1/sdk/server/notify): one an hour and three a day to a player at most. */
352
+ export interface Notify {
353
+ /** Asks the player, on PlayerTwo's own card over the game, whether the game may notify them, with its reason (`why`,
354
+ up to 120 characters). `asked` is false, and nothing shows, when they said yes already, a card was shown this
355
+ session, or they said not now in the last week. Rejects with code "guest", "busy", "no-notify" (outside
356
+ PlayerTwo's player on the web) or "offline". */
357
+ ask(options?: { why?: string }): Promise<{ allowed: boolean; asked: boolean }>;
358
+ /** Whether the player let the game notify them (false wherever it can't be known). */
359
+ allowed(): Promise<boolean>;
360
+ }
361
+
362
+ /** The device the game runs on (p2.device.get(); docs: /docs/sdk#device), worked out in the game's page once. */
363
+ export interface DeviceInfo {
364
+ /** A starting point for the game's settings. */
365
+ tier: "low" | "mid" | "high";
366
+ phone: boolean;
367
+ touch: boolean;
368
+ /** GB, or null where the browser won't say. */
369
+ memory: number | null;
370
+ cores: number | null;
371
+ /** The GPU's name, or "". */
372
+ gpu: string;
373
+ /** A GPU drawn by the processor (SwiftShader, llvmpipe). */
374
+ software: boolean;
375
+ screen: { w: number; h: number; dpr: number };
376
+ saveData: boolean;
377
+ reducedMotion: boolean;
378
+ /** Frames a second over half a second as it was asked, or null while the page was hidden. */
379
+ fps: number | null;
380
+ }
381
+
296
382
  export interface Stats {
297
383
  /** Every stat. */
298
384
  get(): Promise<{ stats: Record<string, number> }>;
@@ -728,9 +814,10 @@ export interface Avatar {
728
814
  export interface Item {
729
815
  key: string;
730
816
  name: string;
731
- kind: "skin" | "avatar" | "wear" | "emote" | "effect";
817
+ kind: "skin" | "avatar" | "wear" | "emote" | "effect" | "frame";
732
818
  tier: "common" | "rare" | "epic" | "legendary" | "mythic" | "divine";
733
- /** Where it goes: head, face, neck or back for a wearable; skin, avatar or effect; none for an emote. */
819
+ /** Where it goes: head, face, neck or back for a wearable; skin, avatar, effect or frame (what the moments a player
820
+ shares on PlayerTwo wear, earned, never sold: "crew-frame"); none for an emote. */
734
821
  slot: string | null;
735
822
  /** Whether the player has it on. */
736
823
  worn: boolean;
@@ -819,7 +906,8 @@ export interface P2 {
819
906
  /** True in a demo: demos earn no trophies. */
820
907
  demo: boolean;
821
908
  /** True for a guest: playing without a PlayerTwo account (in Instagram's browser, or a card on X). Nothing is sold to
822
- a guest (the store's calls reject "guest"): ask them to sign up with signUp(). */
909
+ a guest (the store's calls reject "guest"): ask them to sign up with signUp(). Their trophies and bests are kept for
910
+ them until they sign in (answered with guest: true). */
823
911
  guest: boolean;
824
912
  /** Asks a guest to sign up to PlayerTwo, on PlayerTwo's own card, with your reason (`why`, up to 80 characters: "To
825
913
  buy the Gold Pack"). In PlayerTwo's player: { ok: true } as they press Sign up (your last saves are asked for,
@@ -843,6 +931,11 @@ export interface P2 {
843
931
  store: Store;
844
932
  /** Donations to the game's developer, when its studio put them inside the game. */
845
933
  donate: Donate;
934
+ moments: Moments;
935
+ /** Notifications from the game's server, to players who said yes. */
936
+ notify: Notify;
937
+ /** The device: a quality tier and what it was worked out from. */
938
+ device: { get(): Promise<DeviceInfo> };
846
939
  stats: Stats;
847
940
  scores: Scores;
848
941
  saves: Saves;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playertwo-sdk",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "description": "SDK for HTML5 and browser games on PlayerTwo (playertwo.plus): trophies, leaderboards, stats, cloud saves, in-game purchases, donations to the developer, your own events and errors in your analytics, feeds of outside data, voice chat and multiplayer rooms with server-side room code.",
5
5
  "keywords": [
6
6
  "playertwo",
package/room.d.ts CHANGED
@@ -42,8 +42,15 @@ export interface Player {
42
42
  ping: number | null;
43
43
  /** How much their round trip varies, in ms (null until known). */
44
44
  jitter: number | null;
45
+ /** (r29) What they own of the game's store, read from PlayerTwo as they take their seat in a room of a game that
46
+ sells, and again when they buy in the room (onOwned); null when the game sells nothing or it couldn't be read. */
47
+ owned: Owned | null;
45
48
  }
46
49
 
50
+ /** What a player owns of the game's store (r29): the keys of the products they own (a consumable while they have
51
+ some), a consumable's count by key, and the refs of the charges they paid. */
52
+ export interface Owned { products: string[]; counts: Record<string, number>; refs: string[] }
53
+
47
54
  /** What room.js is handed: the room it runs for. `D` is what you keep in room.data. */
48
55
  /** A physics body room.objects.set takes as it is: Rapier's (translation() and rotation()), or one with a position and
49
56
  a quaternion. */
@@ -57,6 +64,10 @@ export interface Room<D extends object = Record<string, any>> {
57
64
  readonly id: string;
58
65
  /** Who is here. */
59
66
  readonly players: readonly Player[];
67
+ /** (r29) What a player owns of the game's store (player.owned), or null. */
68
+ owned(id: string): Owned | null;
69
+ /** (r29) Whether a player owns a product (by its key) or paid a charge with that ref: refuse a look they don't own. */
70
+ owns(id: string, keyOrRef: string): boolean;
60
71
  /** One of them, or null. */
61
72
  player(id: string): Player | null;
62
73
  /** A message to every page in the room, or to `to` (an id, or a list). Pages hear it with room.on("message:<type>"). */
@@ -167,6 +178,8 @@ export interface RoomScript<D extends object = Record<string, any>> {
167
178
  /** `inputs`: in an input-run room (its pages send room.inputs), each player's input for this step, by id (none when
168
179
  theirs didn't come in time); dt is then always 1 / tickRate, the steps kept to real time. */
169
180
  onTick?(room: Room<D>, dt: number, inputs: Record<string, any>): void;
181
+ /** (r29) What a player owns changed while they're here: they bought something in the game. */
182
+ onOwned?(room: Room<D>, player: Player, owned: Owned | null): void;
170
183
  }
171
184
 
172
185
  /** Types every hook at once: answers `script` as it is. */