@xgamesfun/xcore 0.2.1 → 0.4.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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bring-your-own-game
3
- description: Help someone bring a web game they already made without this kit (plain HTML/JS, or a Vite, Next.js static export, Astro, SvelteKit, Nuxt, Create React App or Parcel project) to xgames.fun - adopt it, fix what does not fit the hosting (server-side rendering, paths from the root, CDN scripts and fonts, undeclared backend origins, secrets, size limits), check it with the page check, connect their own backend or a server/ Worker, add a loot economy, and publish it. Use when the person has an existing game folder or repository and wants web3, xgames.fun hosting, or the kit's checks for it; never rebuild such a game through the creation loop.
3
+ description: Help someone bring a web game they already made without this kit (plain HTML/JS, or a Vite, Next.js static export, Astro, SvelteKit, Nuxt, Create React App or Parcel project) to xgames.fun - adopt it, fix what does not fit the hosting (server-side rendering, paths from the root, CDN scripts and fonts, undeclared backend origins, secrets, size limits), check it with the page check, connect their own backend or a server/ Worker, add a loot economy, review what a cheater gets from it, and publish it. Use when the person has an existing game folder or repository and wants web3, xgames.fun hosting, or the kit's checks for it; never rebuild such a game through the creation loop.
4
4
  ---
5
5
 
6
6
  # Bring your own game
@@ -12,7 +12,7 @@ here is `@xgamesfun/xcore` (the `xcore` command: `npx -y @xgamesfun/xcore …`,
12
12
  @xgamesfun/xcore`; never a bare `npx xcore`, which is another package), which needs no kit; with the kit, its MCP tools
13
13
  (`gamesfun_adopt` and the rest, named below) do the same.
14
14
 
15
- The order: **adopt → fix the list → check → (backend) → (economy) → publish when they ask.**
15
+ The order: **adopt → fix the list → check → (backend) → (economy) → (review, when it pays) → publish when they ask → (review --live).**
16
16
 
17
17
  ## 1. Adopt
18
18
 
@@ -57,6 +57,17 @@ stays on their host as a backend (README, "A game with its own Node server"). Su
57
57
  Never edit their build tool's output by hand (it is made again on every build): change the source or the config.
58
58
  Adopt again after the fixes; the list should be empty.
59
59
 
60
+ **Full screen.** Most players meet a game in a post on X or on a phone, where it first shows in a small frame. When adopt
61
+ warns that the game has no way to go full screen, offer the person a button for it (their game, their call): a small
62
+ button in a corner of the first screen, big enough for a thumb, that calls `GamesFun.fullscreen()` from the click
63
+ (`gamesfun.js`, loaded by `xcore add signin`; Godot `await GamesFun.fullscreen()`; Unity `Screen.fullScreen`).
64
+ Pressed again it comes back. It answers `{on, how}`: on xgames.fun the page around the game goes full screen, or fills
65
+ the screen in an app's own browser (X's on a phone among them); on the game's own link the browser does; in a frame
66
+ that allows none (a post on X on a computer) the game opens in a tab of its own (`how: 'tab'`); an iPhone's Safari has
67
+ no full screen for a page (`how: 'none'`): there the button can hide, or say "Add to Home Screen".
68
+ `GamesFun.onFullscreen(on => …)` follows it (Esc, the browser's own controls). A game that goes full screen already
69
+ (its own button, or its engine's) needs nothing.
70
+
60
71
  ## 3. Check
61
72
 
62
73
  ```bash
@@ -68,7 +79,9 @@ console errors, nothing missing, nothing from the root, something on screen), it
68
79
  screenshots in `evidence/verify-N/` and look at them. A failing check 4 names the origin and why: declare it in
69
80
  `backend.json` if the game really calls it, or remove the call. The page check does not say the game plays well:
70
81
  that is the person's own game; ask them what to try, and try it with `xcore dev <folder>` (the game as xgames.fun
71
- hosts it, with its server, sign-in, saves, rooms and economy RPC) or their own.
82
+ hosts it, with its server, sign-in, saves, rooms and economy RPC, refusing what xgames.fun refuses on the Free plan;
83
+ `--plan creator` for a Creator game) or their own. A refusal there (`rate`, `full`, `too-many`, `order`) is one the
84
+ published game would get: fix the game, not the stand-in.
72
85
 
73
86
  ## 4. Players, a database, a backend (only when the game has or needs them)
74
87
 
@@ -100,7 +113,11 @@ supabase|railway` with the kit installed). Without the kit, they set one up them
100
113
  ([docs/SERVER.md](../../docs/SERVER.md)): a Worker on `/api/*`, Durable Objects for rooms, `env.GF` for sign-in, saves
101
114
  and scores. Their page calls it with a relative address (`fetch('api/scores')`): `/api/*` at the published origin,
102
115
  `/game/api/*` under `xcore dev`, which runs it under workerd with a local `env.GF`. A Node-only server stays on
103
- their own host.
116
+ their own host, and so does anything that opens raw sockets (a database driver, a mail or chat client): xgames.fun
117
+ refuses `cloudflare:sockets`, `node:net` and the like, an `import()` of a name made at run time, and `nodejs_compat`.
118
+ Every route that does work checks the player's token first (`env.GF.verifyPlayer`; 401 at once without one): a
119
+ stranger's request that does work counts toward what caps the game. Key a player's data on `sub` (the account:
120
+ `x:…`, or `g:…` for Google, different in every game), never on the wallet; `wallet` is its own claim, maybe null.
104
121
 
105
122
  ## 5. An economy (only when they ask: tokens, NFTs, a shop, prizes, staking)
106
123
 
@@ -139,8 +156,9 @@ out of `.dev.vars` or repeat it.
139
156
 
140
157
  Design it so a cheater gains little (docs/SERVER.md, "How much your server can check" and "Who gets paid"): never send
141
158
  the page a run's whole seed up front (reveal randomness as the run goes); give slack per second, not per request; one
142
- open run per player; pay only proven wallets (the page calls `gf.loot.link()` once; a wallet sign-in needs none);
143
- a wallet is free, so for rewards worth farming set `VOUCHERS.payOnly` to `'x'` and give every grant a `perDay` total.
159
+ open run per player; pay only proven wallets (the page calls `gf.loot.link()` once; a player whose xgames.fun account
160
+ has a wallet linked needs none); a wallet is free, so for rewards worth farming set `VOUCHERS.payOnly` to `'x'` (X only)
161
+ or `'account'` (X or Google; a Google account is easier to make) and give every grant a `perDay` total.
144
162
 
145
163
  A page alone can't prove a score or a win: anyone can change it in the console. A leaderboard that must be fair is
146
164
  one the server owns: `env.GF.scores.setup(board, {writer: 'server'})` refuses the page's submits to it (a pattern,
@@ -152,7 +170,35 @@ your server can check". A bounded result earns small capped amounts; entry fees
152
170
  replayed one. Without a server,
153
171
  offer what the player pays for or the chain decides (a shop, boxes, raffles, staking, perks), and say why.
154
172
 
155
- ## 6. Publish (only when they ask)
173
+ ## 6. Review (a game whose server pays results)
174
+
175
+ Before publishing a game that pays results, read it as a cheater would:
176
+
177
+ ```bash
178
+ xcore review <folder> # evidence/review-N/review.md and review.json; exits 1 on a high finding
179
+ xcore loot review # the economy's part alone (@xgamesfun/solana's xsolana_review)
180
+ ```
181
+
182
+ - **Fix every high finding** (a `PAY.check` that pays from the request alone, a route anyone can call, a seed in the
183
+ page, `.dev.vars` in git…), and run it again. Mediums are the person's to decide with you: say each one plainly.
184
+ - **Declare `trust` honestly** on every grant a voucher pays: `"decides"` (the server runs the game; the page sends
185
+ only inputs), `"replays"` (the server runs the page's inputs again) or `"bounds"` (the page plays and reports; the
186
+ server checks its clock, order and caps). It is what `PAY.check` really does, not what you hope it does: a server
187
+ that times a run the page simulated is `bounds`, whatever it is called. (The field needs the `@xgamesfun/solana`
188
+ that has `review`: 0.25.0's `xcore loot check` refuses it, so with that one leave it out and still tell the person
189
+ the level in words.)
190
+ - **Tell the person**, in plain words, from the end of `review.md`: for each paid route, the level it uses, what a
191
+ cheater gets (a bounded result pays a script that waits and reports, without playing; a decided one pays what a bot
192
+ that plays well wins), and what the stronger level would cost to build (replaying: a deterministic step and about
193
+ 3 ms of CPU a second played; deciding: the rules moved to the server, a request each step). Let them choose: a
194
+ smaller prize and tighter caps, or the stronger level. Never call a bounded result safe.
195
+
196
+ After publishing, `xcore review <folder> --live` asks the published game as a stranger (no sign-in, a forged one;
197
+ nothing it sends can spend or sign) and checks its voucher key and economy against the folder. Under `xcore dev`,
198
+ give its address: `--live http://127.0.0.1:<port>/game/`. `xcore publish` reminds you when the economy or `server/`
199
+ changed since the last review.
200
+
201
+ ## 7. Publish (only when they ask)
156
202
 
157
203
  ```bash
158
204
  xcore publish <folder> --check # the offline part: what goes up, what refuses it
@@ -160,11 +206,14 @@ xcore publish <folder> # or gamesfun_login, then gamesfun_publish {"gam
160
206
  ```
161
207
 
162
208
  It builds, runs the page check on exactly those files, uploads the published folder and the `server/` bundle. A failed
163
- check makes a private draft only. Tell them the link, what you changed in their files, what the checks proved and what
209
+ check makes a private draft only. `xcore login` asks the person to tick, on xgames.fun's approval page, the games this
210
+ computer may work on (or their whole account), and says which it got; a command refused with code `not-granted` means
211
+ the sign-in was not given that game: they run `xcore login` again and tick it (never work around it). Tell them the link, what you changed in their files, what the checks proved and what
164
212
  nothing checked (their gameplay, their backend's own behaviour).
165
213
 
166
214
  A game with a `server/`, saves or scores runs under its **plan** (`xcore plan <folder>`): Free by default (50 ms of CPU
167
- and 600 requests a minute, $1 of use a month, then capped and slow until the month ends). When the game needs more
215
+ and 600 requests a minute, $1 of use a month; past it the game is capped until the month ends: its server is switched
216
+ off and saves and scores slow down). When the game needs more
168
217
  (a server that replays play, many players at once), tell them: a paid slot makes it Creator
169
218
  (`xcore plan activate <folder>` once they have one), and the paid slot moves between their games at any time. Everyone
170
219
  has 2 free slots: a third game is refused on publish (`no-free-slot`) until they archive one on their console