@genex-ai/cli-demo 1.4.2-dev.382 → 1.5.0-dev.389
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.
package/dist/index.js
CHANGED
|
@@ -1013,6 +1013,7 @@ Important note: put soul into your creations, with many details and love. Aim to
|
|
|
1013
1013
|
16. Never add debug-only code to the game to check your own work \u2014 no hidden test modes, no special URL parameters, no forced-visible flags, no auth mocks, no pixel-sampling hooks. \`?genex_local_test=1\` is the platform's own supported mode and is fine; your own bypass is not. (The multiplayer skill's small build identifier, token-free status line, and connected-quorum watchdog are production supportability, not a bypass \u2014 keep those.)
|
|
1014
1014
|
17. Input directions match their labels: A/\u2190 moves or turns the player screen-LEFT, D/\u2192 screen-RIGHT, mouse-up looks up, and drag-pan axes share ONE convention. The cursor is either the gameplay tool (RTS, card, builder) or locked away during play \u2014 keyboard-only games included. Check it in every milestone's smoke pass.
|
|
1015
1015
|
18. NEVER delete, empty, move, rename, or overwrite anything you did not create yourself. This folder may hold the player's own reference images, notes, sketches, or an earlier attempt \u2014 files that exist nowhere else and have no undo, no trash, no backup. A non-empty folder is normal and is NEVER something to clean up, and "start clean" is never a reason. That rules out \`rm\`/\`rm -rf\`, \`git clean\`, \`git checkout -- .\`, \`git reset --hard\` over their work, deleting to resolve a conflict or a stuck interactive prompt, and every setup tool's offer to empty a directory (\`--force\`, \`--overwrite\`, "Remove existing files") \u2014 scaffold into a fresh subfolder and copy in instead. You may add files and edit the ones you wrote. If a step genuinely cannot continue without removing something of theirs, STOP and ask, naming the exact files, and wait for a yes \u2014 "it looks like junk" is never that yes. This binds hardest during setup, where it runs fast and automatically before the player has asked for anything at all.
|
|
1016
|
+
19. If the game sells anything, it sells it for coin at a fixed, visible price, and NEVER sells chance. Run this test on any purchasable thing before building it: does the player pay (with coin, or with anything coin bought, directly or indirectly), is the outcome uncertain when they pay, and is there a prize they wanted \u2014 all three yes means it is paid randomness, and you build the deterministic version instead. That rules out loot boxes, gacha, mystery boxes, crates, card packs, prize wheels and raffles; wagering, staking, betting, coinflips and casino or slot mechanics denominated in coin; and donation prompts, tip jars or any player-to-player coin transfer, because coin buys goods and never just moves. Randomness the player EARNS by playing is gameplay, not commerce \u2014 an enemy dropping a random item, a chest found in the level, a procedural layout, a crit roll \u2014 and is completely fine. Every coin price renders its real-money equivalent beside it (the server sends one with every item), item prices sit on the platform's price grid so no player is left holding change they cannot spend, and nothing in a shop carries a countdown, "limited time", or a stock counter. When a request crosses one of these lines, name the mechanic, give the one-sentence reason, propose a specific compliant alternative, and build that \u2014 never the banned version "as an option", never a partial one, and never after asking the player to confirm they want it. Load \`$genex-monetization\` before building a shop.
|
|
1016
1017
|
${CONTRACT_END}
|
|
1017
1018
|
`;
|
|
1018
1019
|
var CLAUDE_IMPORT_LINE = "@AGENTS.md";
|
|
@@ -5041,6 +5042,156 @@ async function runDomain(opts) {
|
|
|
5041
5042
|
log.success(`${hostname} disconnected.`);
|
|
5042
5043
|
}
|
|
5043
5044
|
|
|
5045
|
+
// src/commands/shop.ts
|
|
5046
|
+
var SUBS = ["list", "add", "set", "remove"];
|
|
5047
|
+
function money(cents) {
|
|
5048
|
+
return cents === void 0 ? "" : ` ($${(cents / 100).toFixed(2)})`;
|
|
5049
|
+
}
|
|
5050
|
+
async function runShop(opts) {
|
|
5051
|
+
const log = createLogger({ quiet: opts.quiet });
|
|
5052
|
+
const sub = opts.name?.trim() || "list";
|
|
5053
|
+
if (!SUBS.includes(sub)) {
|
|
5054
|
+
log.error(`Unknown subcommand ${c.cyan(sub)}. Use: ${SUBS.join(", ")}.`);
|
|
5055
|
+
process.exitCode = 1;
|
|
5056
|
+
return;
|
|
5057
|
+
}
|
|
5058
|
+
const meta = await readProject();
|
|
5059
|
+
if (!meta?.id) {
|
|
5060
|
+
log.error("This folder isn't linked to a game.");
|
|
5061
|
+
log.dim(` Run ${c.cyan("genex link")} (or ${c.cyan("genex list")} to find the slug) first.`);
|
|
5062
|
+
process.exitCode = 1;
|
|
5063
|
+
return;
|
|
5064
|
+
}
|
|
5065
|
+
const apiUrl = getApiUrl(opts.apiUrl ?? meta.apiUrl);
|
|
5066
|
+
let token = opts.token ?? await readUserToken(opts.envPath);
|
|
5067
|
+
if (!token) {
|
|
5068
|
+
if (opts.noAuth) {
|
|
5069
|
+
log.error("Not signed in. Re-run without --no-auth to connect.");
|
|
5070
|
+
process.exitCode = 1;
|
|
5071
|
+
return;
|
|
5072
|
+
}
|
|
5073
|
+
log.plain("Not signed in \u2014 connecting\u2026");
|
|
5074
|
+
try {
|
|
5075
|
+
token = await authorize(apiUrl, getAuthUrl(opts.authUrl), {
|
|
5076
|
+
log,
|
|
5077
|
+
inlineWaitMs: opts.timeoutSec ? opts.timeoutSec * 1e3 : void 0
|
|
5078
|
+
});
|
|
5079
|
+
} catch (err) {
|
|
5080
|
+
if (err instanceof AuthPendingError) {
|
|
5081
|
+
printAuthHandoff(log, err);
|
|
5082
|
+
log.dim(`Then re-run ${c.cyan(`genex shop ${sub}`)}.`);
|
|
5083
|
+
return;
|
|
5084
|
+
}
|
|
5085
|
+
log.error(`Sign-in didn't complete: ${err instanceof Error ? err.message : String(err)}`);
|
|
5086
|
+
process.exitCode = 1;
|
|
5087
|
+
return;
|
|
5088
|
+
}
|
|
5089
|
+
await writeUserToken(token, opts.envPath);
|
|
5090
|
+
}
|
|
5091
|
+
const auth = { Authorization: `Bearer ${token}`, "Content-Type": "application/json" };
|
|
5092
|
+
const call = (url, init2) => apiFetch(url, { ...init2, headers: { ...auth, ...init2?.headers ?? {} } });
|
|
5093
|
+
const projectSkus = `${apiUrl}/api/coin/projects/${encodeURIComponent(meta.id)}/skus`;
|
|
5094
|
+
async function fail3(res2, what) {
|
|
5095
|
+
if (printedStructuredError(res2)) {
|
|
5096
|
+
process.exitCode = 1;
|
|
5097
|
+
return;
|
|
5098
|
+
}
|
|
5099
|
+
process.exitCode = 1;
|
|
5100
|
+
const body = await res2.json().catch(() => ({}));
|
|
5101
|
+
if (res2.status === 404 && body.error === "not_found") {
|
|
5102
|
+
log.error("In-game purchases aren't enabled on this environment yet.");
|
|
5103
|
+
return;
|
|
5104
|
+
}
|
|
5105
|
+
log.error(body.message ?? `Couldn't ${what} (HTTP ${res2.status}).`);
|
|
5106
|
+
if (body.error === "price_off_grid") {
|
|
5107
|
+
log.dim(` See the full list any time: ${c.cyan("genex shop list")}`);
|
|
5108
|
+
}
|
|
5109
|
+
}
|
|
5110
|
+
if (sub === "list") {
|
|
5111
|
+
const res2 = await call(projectSkus);
|
|
5112
|
+
if (!res2.ok) return fail3(res2, "read your shop");
|
|
5113
|
+
const body = await res2.json();
|
|
5114
|
+
if (opts.json) {
|
|
5115
|
+
log.plain(JSON.stringify(body, null, 2));
|
|
5116
|
+
return;
|
|
5117
|
+
}
|
|
5118
|
+
if (body.items.length === 0) {
|
|
5119
|
+
log.plain("This game sells nothing yet.");
|
|
5120
|
+
log.dim(` Add something: ${c.cyan('genex shop add "Iron Key" --price 100')}`);
|
|
5121
|
+
log.dim(` Prices available: ${body.priceGrid.join(", ")} coin`);
|
|
5122
|
+
return;
|
|
5123
|
+
}
|
|
5124
|
+
log.plain(`${body.items.length} item${body.items.length === 1 ? "" : "s"}:`);
|
|
5125
|
+
for (const s of body.items) {
|
|
5126
|
+
const state = s.active ? "" : c.dim(" (retired)");
|
|
5127
|
+
log.plain(
|
|
5128
|
+
` ${c.cyan(s.id)} ${s.name} \u2014 ${s.priceCoins} coin${money(s.priceDisplayUsdCents)} ${c.dim(s.type)}${state}`
|
|
5129
|
+
);
|
|
5130
|
+
}
|
|
5131
|
+
log.dim(`Prices available: ${body.priceGrid.join(", ")} coin`);
|
|
5132
|
+
return;
|
|
5133
|
+
}
|
|
5134
|
+
if (sub === "add") {
|
|
5135
|
+
const name = opts.hostname?.trim();
|
|
5136
|
+
if (!name) {
|
|
5137
|
+
log.error(`\`genex shop add\` needs a name, e.g. ${c.cyan('genex shop add "Iron Key" --price 100')}.`);
|
|
5138
|
+
process.exitCode = 1;
|
|
5139
|
+
return;
|
|
5140
|
+
}
|
|
5141
|
+
if (!opts.price) {
|
|
5142
|
+
log.error(`\`genex shop add\` needs ${c.cyan("--price")}, in coin.`);
|
|
5143
|
+
process.exitCode = 1;
|
|
5144
|
+
return;
|
|
5145
|
+
}
|
|
5146
|
+
const res2 = await call(projectSkus, {
|
|
5147
|
+
method: "POST",
|
|
5148
|
+
body: JSON.stringify({
|
|
5149
|
+
name,
|
|
5150
|
+
priceCoins: opts.price,
|
|
5151
|
+
type: opts.type === "durable" ? "durable" : "consumable",
|
|
5152
|
+
...opts.icon ? { iconUrl: opts.icon } : {}
|
|
5153
|
+
})
|
|
5154
|
+
});
|
|
5155
|
+
if (!res2.ok) return fail3(res2, "add that item");
|
|
5156
|
+
const sku = await res2.json();
|
|
5157
|
+
if (opts.json) {
|
|
5158
|
+
log.plain(JSON.stringify(sku, null, 2));
|
|
5159
|
+
return;
|
|
5160
|
+
}
|
|
5161
|
+
log.success(`Added ${c.cyan(sku.name)} \u2014 ${sku.priceCoins} coin.`);
|
|
5162
|
+
log.plain(` id: ${c.cyan(sku.id)}`);
|
|
5163
|
+
log.dim(` Use it in the game: buy({ skuId: "${sku.id}" })`);
|
|
5164
|
+
return;
|
|
5165
|
+
}
|
|
5166
|
+
const skuId = opts.hostname?.trim();
|
|
5167
|
+
if (!skuId) {
|
|
5168
|
+
log.error(`\`genex shop ${sub}\` needs an item id \u2014 see ${c.cyan("genex shop list")}.`);
|
|
5169
|
+
process.exitCode = 1;
|
|
5170
|
+
return;
|
|
5171
|
+
}
|
|
5172
|
+
const skuUrl = `${apiUrl}/api/coin/skus/${encodeURIComponent(skuId)}`;
|
|
5173
|
+
if (sub === "set") {
|
|
5174
|
+
const patch = {};
|
|
5175
|
+
if (opts.rename) patch.name = opts.rename;
|
|
5176
|
+
if (opts.price) patch.priceCoins = opts.price;
|
|
5177
|
+
if (opts.icon) patch.iconUrl = opts.icon;
|
|
5178
|
+
if (Object.keys(patch).length === 0) {
|
|
5179
|
+
log.error(`Nothing to change. Pass ${c.cyan("--rename")}, ${c.cyan("--price")} or ${c.cyan("--icon")}.`);
|
|
5180
|
+
process.exitCode = 1;
|
|
5181
|
+
return;
|
|
5182
|
+
}
|
|
5183
|
+
const res2 = await call(skuUrl, { method: "PATCH", body: JSON.stringify(patch) });
|
|
5184
|
+
if (!res2.ok) return fail3(res2, "update that item");
|
|
5185
|
+
const sku = await res2.json();
|
|
5186
|
+
log.success(`Updated ${c.cyan(sku.name)} \u2014 ${sku.priceCoins} coin.`);
|
|
5187
|
+
return;
|
|
5188
|
+
}
|
|
5189
|
+
const res = await call(skuUrl, { method: "DELETE" });
|
|
5190
|
+
if (!res.ok) return fail3(res, "remove that item");
|
|
5191
|
+
log.success("Removed from the shop.");
|
|
5192
|
+
log.dim(" Players who already bought it keep it.");
|
|
5193
|
+
}
|
|
5194
|
+
|
|
5044
5195
|
// src/lib/promote.ts
|
|
5045
5196
|
async function promoteBuild(apiUrl, projectId, token, log) {
|
|
5046
5197
|
let res;
|
|
@@ -19255,6 +19406,11 @@ ${c.bold("Usage")}
|
|
|
19255
19406
|
add | list | verify | remove. "add" opens a
|
|
19256
19407
|
one-click approval at your DNS host \u2014 no
|
|
19257
19408
|
records to copy or paste.
|
|
19409
|
+
genex shop <sub> [name|id] What this game sells: list | add | set | remove.
|
|
19410
|
+
"add" prints the item id your game passes to
|
|
19411
|
+
buy({ skuId }) \u2014 the platform owns the catalog,
|
|
19412
|
+
so this is the only way one exists. Prices come
|
|
19413
|
+
off a fixed grid, printed on any refusal.
|
|
19258
19414
|
genex model "<prompt>" [options] Generate a 3D model (GLB); prints a public asset URL.
|
|
19259
19415
|
genex skybox "<prompt>" [options] Generate a skybox (equirect); prints a public asset URL.
|
|
19260
19416
|
genex sfx "<prompt>" [options] Generate a sound effect (mp3); prints a public asset URL.
|
|
@@ -19502,6 +19658,10 @@ ${c.bold("Examples")}
|
|
|
19502
19658
|
genex make-remixable
|
|
19503
19659
|
genex domain add play.mygame.com
|
|
19504
19660
|
genex domain list
|
|
19661
|
+
genex shop list
|
|
19662
|
+
genex shop add "Iron Key" --price 100 --type durable
|
|
19663
|
+
genex shop set sku_123 --price 200
|
|
19664
|
+
genex shop remove sku_123
|
|
19505
19665
|
genex publish --no-push --title "My Game"
|
|
19506
19666
|
genex model "weathered wooden barrel with iron bands"
|
|
19507
19667
|
genex skybox "golden hour over a misty mountain range"
|
|
@@ -19554,6 +19714,10 @@ function parseArgs(argv) {
|
|
|
19554
19714
|
"--name",
|
|
19555
19715
|
"--repo",
|
|
19556
19716
|
"--remixed-from",
|
|
19717
|
+
"--price",
|
|
19718
|
+
"--icon",
|
|
19719
|
+
"--rename",
|
|
19720
|
+
"--type",
|
|
19557
19721
|
"--title",
|
|
19558
19722
|
"--description",
|
|
19559
19723
|
"--categories",
|
|
@@ -19762,6 +19926,12 @@ function parseArgs(argv) {
|
|
|
19762
19926
|
} else {
|
|
19763
19927
|
(parsed.options.selectors ??= []).push(arg);
|
|
19764
19928
|
}
|
|
19929
|
+
} else if (parsed.command === "shop") {
|
|
19930
|
+
if (!parsed.options.hostname) parsed.options.hostname = arg;
|
|
19931
|
+
else {
|
|
19932
|
+
parsed.error = `Unexpected argument: ${arg}`;
|
|
19933
|
+
return parsed;
|
|
19934
|
+
}
|
|
19765
19935
|
} else if (parsed.command === "domain") {
|
|
19766
19936
|
if (!parsed.options.hostname) parsed.options.hostname = arg;
|
|
19767
19937
|
else {
|
|
@@ -19938,6 +20108,27 @@ function applyValueFlag(options, flag, value) {
|
|
|
19938
20108
|
options.duration = n;
|
|
19939
20109
|
break;
|
|
19940
20110
|
}
|
|
20111
|
+
case "--price": {
|
|
20112
|
+
const n = Number(value);
|
|
20113
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
20114
|
+
throw new Error(`Invalid --price value: ${value} (whole coin, e.g. 100)`);
|
|
20115
|
+
}
|
|
20116
|
+
options.price = n;
|
|
20117
|
+
break;
|
|
20118
|
+
}
|
|
20119
|
+
case "--icon":
|
|
20120
|
+
options.icon = value;
|
|
20121
|
+
break;
|
|
20122
|
+
case "--type": {
|
|
20123
|
+
if (value !== "consumable" && value !== "durable") {
|
|
20124
|
+
throw new Error(`Invalid --type value: ${value} (consumable or durable)`);
|
|
20125
|
+
}
|
|
20126
|
+
options.type = value;
|
|
20127
|
+
break;
|
|
20128
|
+
}
|
|
20129
|
+
case "--rename":
|
|
20130
|
+
options.rename = value;
|
|
20131
|
+
break;
|
|
19941
20132
|
case "--aspect":
|
|
19942
20133
|
options.aspect = value;
|
|
19943
20134
|
break;
|
|
@@ -20103,6 +20294,9 @@ async function main() {
|
|
|
20103
20294
|
case "make-remixable":
|
|
20104
20295
|
await runMakeRemixable(parsed.options);
|
|
20105
20296
|
break;
|
|
20297
|
+
case "shop":
|
|
20298
|
+
await runShop(parsed.options);
|
|
20299
|
+
break;
|
|
20106
20300
|
case "domain":
|
|
20107
20301
|
await runDomain(parsed.options);
|
|
20108
20302
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genex-ai/cli-demo",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0-dev.389",
|
|
4
4
|
"description": "Set up your project's agent workspace (.claude/.codex/.cursor in the game folder), authorize, create a game project, generate AI assets, and publish (genex CLI).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -59,6 +59,7 @@ copy demo architecture.
|
|
|
59
59
|
| in-world motion art or another requested video | `$genex-ai-video` |
|
|
60
60
|
| sound effect, one looping music bed, or a short spoken line | `$genex-ai-sfx`, `$genex-ai-music`, or `$genex-ai-voice` |
|
|
61
61
|
| requested UI/HUD/menu/interface work, a visible UI problem, or an interface you decided this game wants built with generated art | `$genex-threejs-game-ui` |
|
|
62
|
+
| selling anything for platform coin: a shop, an item catalog, boosts, cosmetics, "make it earn"; also any request for a loot box, gacha, wager, casino mechanic or donation prompt, which that skill refuses and replaces | `$genex-monetization` |
|
|
62
63
|
| cinematic menu/title/pause/victory/defeat/lobby/credits video treatment | `$genex-ai-menu` |
|
|
63
64
|
| drawn HUD chrome the game's style wants—one element or a matched set of frames, masks, and icons | `$genex-ai-hud` |
|
|
64
65
|
| the game works but feels flat, floaty, or unresponsive: input response, camera, impacts, cooldowns, difficulty, fail/retry | `$genex-threejs-game-feel` |
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: genex-monetization
|
|
3
|
+
description: Build an in-game shop that sells for platform coin — item catalog, purchase flow, delivery, and the per-game soft-currency economy a purchase attaches to. Use when the player asks to sell things, add a shop, monetize, or make the game earn. Carries the hard rules: no paid randomness, no gambling in coin, no donation mechanics, and a real-money price beside every coin price.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Genex Monetization
|
|
7
|
+
|
|
8
|
+
Games on Genex can sell things for **coin**, the platform currency. The player
|
|
9
|
+
buys coin with real money once; spending it inside a game is a ledger movement
|
|
10
|
+
the game never touches. You design what is for sale; the platform owns the
|
|
11
|
+
wallet, the confirmation, and the money.
|
|
12
|
+
|
|
13
|
+
Load this when the game should sell something. Ask first if it should — a game
|
|
14
|
+
with no loop worth monetizing is better without a shop (see §1).
|
|
15
|
+
|
|
16
|
+
## The hard rules, and the test that generalizes them
|
|
17
|
+
|
|
18
|
+
Before you build ANY purchasable thing, run this test:
|
|
19
|
+
|
|
20
|
+
> **Does the player pay?** (with coin, or with anything bought with coin —
|
|
21
|
+
> directly or indirectly, including a per-game token or key that coin bought.)
|
|
22
|
+
> **Is the outcome uncertain when they pay?**
|
|
23
|
+
> **Is there a prize** — an item, currency, or advantage they wanted?
|
|
24
|
+
>
|
|
25
|
+
> **All three yes = paid randomness. Build the deterministic version instead.**
|
|
26
|
+
|
|
27
|
+
That triad is the test used by every app store to identify gambling, and it
|
|
28
|
+
catches mechanics that do not exist yet — which a list of banned names cannot.
|
|
29
|
+
|
|
30
|
+
Four things are never built, whatever the request:
|
|
31
|
+
|
|
32
|
+
1. **No paid randomness.** No loot boxes, gacha, mystery boxes, crates, packs,
|
|
33
|
+
prize wheels, raffles, "spin for a bonus", "chance to double your coins".
|
|
34
|
+
Directly or indirectly.
|
|
35
|
+
2. **No gambling in coin.** No wagering, staking, betting, coinflips, casino or
|
|
36
|
+
slot mechanics denominated in coin or in anything coin buys.
|
|
37
|
+
3. **No donation or begging mechanics.** No "donate to me" prompts, tip jars, or
|
|
38
|
+
player-to-player coin transfers. Coin buys goods; it never just moves.
|
|
39
|
+
4. **No pressure.** No countdown timers, "ends in", "limited time", "only N
|
|
40
|
+
left", or stock counters anywhere in the shop.
|
|
41
|
+
|
|
42
|
+
**Randomness the player EARNS by playing is gameplay, not commerce, and is
|
|
43
|
+
completely fine**: an enemy dropping a random item, a chest you found in the
|
|
44
|
+
level, a procedural layout, a critical-hit roll, a shuffled deck. The line is
|
|
45
|
+
what triggered the roll — play, or payment. Build those freely.
|
|
46
|
+
|
|
47
|
+
Genex refuses paid randomness outright rather than allowing it with disclosed
|
|
48
|
+
odds. That is stricter than any app store, and it is why no Genex game needs an
|
|
49
|
+
odds table, an age gate, or a per-country check.
|
|
50
|
+
|
|
51
|
+
### When a request crosses a line
|
|
52
|
+
|
|
53
|
+
Answer in exactly three parts, then build:
|
|
54
|
+
|
|
55
|
+
1. **Name it.** "A loot crate is paid randomness — the player pays before
|
|
56
|
+
knowing what they get."
|
|
57
|
+
2. **Why.** One sentence. "Genex doesn't sell chance; it's a purchase the player
|
|
58
|
+
can't price, and it's what regulators fine studios over."
|
|
59
|
+
3. **Offer the alternative,** concretely enough to start on, and build that.
|
|
60
|
+
|
|
61
|
+
Never build the banned version "as an option", never build a partial one, and
|
|
62
|
+
never ask the user to confirm they want it. If they insist, restate the rule
|
|
63
|
+
once and build the compliant version. There is no escalation path.
|
|
64
|
+
|
|
65
|
+
**What to build instead:**
|
|
66
|
+
|
|
67
|
+
| They asked for | Build |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| Loot box, crate, mystery box, card pack | A direct-purchase shop: every item listed at a fixed price, contents visible. For the collecting feel, add a **visible catalog with a completion track** — any purchase advances a meter to a stated milestone reward. |
|
|
70
|
+
| Gacha, banner, pull, summon | A **deterministic unlock**: the character costs a fixed price, or unlocks at a stated number of runs. Coin may buy a stated, visible number of those points. |
|
|
71
|
+
| Prize wheel, spin-to-win, slot machine | A **free spin earned by finishing a run** (never bought), or a **"pick one of three"** screen where all three are visible and the player chooses. Keeps the moment, drops the wager. |
|
|
72
|
+
| Casino game, blackjack, poker, roulette | The same game with **chips that are granted free each session, reset on restart, cannot be bought and cannot become coin**. It becomes a card game. Sell cosmetics — table felt, card backs — for coin. |
|
|
73
|
+
| Coinflip, double-or-nothing, wager my coins | A **skill-based risk/reward inside the run**: a harder route with a bigger payout, staking the run's own score, which was never purchasable. |
|
|
74
|
+
| Betting on matches, PvP wagers | **Leaderboards with a fixed cosmetic reward for placement**, paid by the game. Nobody's balance goes down. |
|
|
75
|
+
| Donate button, tip jar, "pls donate" | A **gift that is a purchase**: they buy a specific item at a stated price and give it. Or a **supporter cosmetic** — a badge or aura at a normal price, where what's delivered is visible. |
|
|
76
|
+
| Pay to remove a wait / energy gate | **Delete the gate** and sell a permanent upgrade or a cosmetic. Pace with difficulty, not with a timer. |
|
|
77
|
+
| Limited-time offer, flash sale | A **permanent tiered ladder** — the value comes from volume, not from a clock. |
|
|
78
|
+
| Pay-to-win stat boost in a competitive game | **Cosmetics**, or a boost that only applies in single-player content. |
|
|
79
|
+
|
|
80
|
+
## Designing a shop worth buying from
|
|
81
|
+
|
|
82
|
+
Nine checks. Each one is answerable about your actual design.
|
|
83
|
+
|
|
84
|
+
1. **The shop attaches to a progression that already exists.** Name the screen
|
|
85
|
+
it opens from and the meter a purchase moves. Build the loop first; a shop in
|
|
86
|
+
a game with nothing to want is furniture.
|
|
87
|
+
2. **A boost shortens a grind the player has already felt.** State it in one
|
|
88
|
+
sentence: "this skips the ore-gathering they've done four times." If you
|
|
89
|
+
can't, it isn't a boost, it's a number.
|
|
90
|
+
3. **Nothing sold invalidates the core loop.** If a paying and a non-paying
|
|
91
|
+
player both reach the end, the payer must not have skipped the part that IS
|
|
92
|
+
the game.
|
|
93
|
+
4. **No manufactured friction.** If the annoyance wouldn't exist without the
|
|
94
|
+
shop, remove the annoyance instead of selling the cure.
|
|
95
|
+
5. **Everything sold is reachable free.** Spending is a shortcut or a
|
|
96
|
+
decoration, never the only path.
|
|
97
|
+
6. **Prices land on the grid.** Item prices use 50 / 100 / 200 / 500 / 1000 coin
|
|
98
|
+
so every coin pack divides evenly into them and nobody is left holding change
|
|
99
|
+
they cannot spend.
|
|
100
|
+
7. **Every price shows real money next to it.** The server sends
|
|
101
|
+
`priceDisplayUsdCents` with every item — render it. `250 coins ($2.49)`.
|
|
102
|
+
8. **One currency layer between money and goods.** Coin buys items. A per-game
|
|
103
|
+
earned currency buys per-game upgrades. They never convert into each other.
|
|
104
|
+
9. **Purchases never expire and survive a reinstall.** Entitlements live on the
|
|
105
|
+
server; the game re-reads them on every boot.
|
|
106
|
+
|
|
107
|
+
For a per-game earned currency, the load-bearing number is **minutes of play per
|
|
108
|
+
unit earned**. Set it, then price the cheapest meaningful item at one to three
|
|
109
|
+
sessions of earning. Everything else follows. Spend sinks come in three kinds —
|
|
110
|
+
permanent upgrades, refills, cosmetics — and cosmetics are what absorbs late-game
|
|
111
|
+
currency without touching balance.
|
|
112
|
+
|
|
113
|
+
## Stocking the shop
|
|
114
|
+
|
|
115
|
+
Items live on the platform, not in the game's code. You create them with the CLI,
|
|
116
|
+
and the game names them by id — which is what stops a game inventing its own
|
|
117
|
+
items or repricing them.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npx genex shop add "Iron Key" --price 100 --type durable
|
|
121
|
+
# → id: sku_a1b2c3 ← what the game passes to buy()
|
|
122
|
+
|
|
123
|
+
npx genex shop list # what this game sells, and the valid prices
|
|
124
|
+
npx genex shop set sku_a1b2c3 --price 200
|
|
125
|
+
npx genex shop remove sku_a1b2c3 # retires it; players who bought it keep it
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
`--type consumable` (default) is spent on use; `durable` is owned permanently.
|
|
129
|
+
|
|
130
|
+
**Prices come off a fixed grid** — `genex shop list` prints it, and an off-grid
|
|
131
|
+
price is refused. The grid exists so every coin pack divides evenly by the
|
|
132
|
+
cheapest item, which is what stops a player being left holding change too small
|
|
133
|
+
to spend. Pick the nearest grid price rather than working around it.
|
|
134
|
+
|
|
135
|
+
Record the ids in `DESIGN.md` next to what each item does. They are the one
|
|
136
|
+
thing the game's code cannot regenerate for itself.
|
|
137
|
+
|
|
138
|
+
## The API
|
|
139
|
+
|
|
140
|
+
From `@genex-ai/embed-sdk`, already installed. `initEmbed()` must have run.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { getShop, buy, getEntitlements, consumeEntitlement } from '@genex-ai/embed-sdk';
|
|
144
|
+
|
|
145
|
+
const items = await getShop();
|
|
146
|
+
// [{ id, type, name, iconUrl, priceCoins, priceDisplayUsdCents }]
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Render `name`, `iconUrl`, `priceCoins` **and** `priceDisplayUsdCents`. Never
|
|
150
|
+
hardcode a price: the server charges what its own catalog says, so a hardcoded
|
|
151
|
+
number can silently disagree with what the player is charged.
|
|
152
|
+
|
|
153
|
+
### Buying
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
buyButton.addEventListener('click', async () => { // must be a real click
|
|
157
|
+
const result = await buy({ skuId: item.id });
|
|
158
|
+
if (result.status === 'canceled') return; // normal — say nothing
|
|
159
|
+
if (result.status !== 'succeeded') {
|
|
160
|
+
showMessage(result.message ?? 'That did not go through.');
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
await deliverPending();
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Call `buy()` synchronously from the click handler.** On the game's own origin
|
|
168
|
+
the confirmation is a popup, and browsers only allow one while a user gesture is
|
|
169
|
+
live — an `await` before it loses the gesture and nothing opens.
|
|
170
|
+
|
|
171
|
+
`buy()` resolves when the SERVER says what happened, not when a window closes.
|
|
172
|
+
Statuses: `succeeded`, `canceled`, `expired`, `insufficient_balance`, `failed`.
|
|
173
|
+
|
|
174
|
+
The player confirms on a Genex-drawn surface — your game does not render the
|
|
175
|
+
price sheet, cannot skin it, and cannot complete a purchase itself. That is
|
|
176
|
+
deliberate: it is what lets a player trust a purchase in a game they have never
|
|
177
|
+
played before.
|
|
178
|
+
|
|
179
|
+
### Delivering
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
async function deliverPending() {
|
|
183
|
+
for (const e of await getEntitlements({ excludeConsumed: true })) {
|
|
184
|
+
const { alreadyConsumed } = await consumeEntitlement(e.id);
|
|
185
|
+
if (alreadyConsumed) continue; // someone got there first
|
|
186
|
+
applyItem(e.skuId); // AFTER the consume
|
|
187
|
+
await savePlayerState(currentSave());
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Consume first, apply second, and run `deliverPending()` on every boot.**
|
|
193
|
+
|
|
194
|
+
That order is not stylistic. If the game dies between consuming and applying,
|
|
195
|
+
the player loses one item — a support ticket. If you apply first and die before
|
|
196
|
+
consuming, every boot re-delivers it forever — an exploit. Re-listing on boot is
|
|
197
|
+
what makes a purchase survive a crash, a refresh, or a closed tab.
|
|
198
|
+
|
|
199
|
+
`consumable` items are used up. `durable` items are owned permanently — consume
|
|
200
|
+
them once, then record ownership in the player's save.
|
|
201
|
+
|
|
202
|
+
## Checklist
|
|
203
|
+
|
|
204
|
+
- [ ] Items exist (`npx genex shop list`) before the shop UI is written
|
|
205
|
+
- [ ] The game has a loop and a progression before it has a shop
|
|
206
|
+
- [ ] Every item price is on the 50/100/200/500/1000 grid
|
|
207
|
+
- [ ] Every price renders `priceDisplayUsdCents` beside the coin figure
|
|
208
|
+
- [ ] `buy()` is called synchronously inside a click/tap handler
|
|
209
|
+
- [ ] `canceled` is silent; only real failures show a message
|
|
210
|
+
- [ ] `deliverPending()` runs on every boot, before the player can act
|
|
211
|
+
- [ ] `consumeEntitlement()` is awaited BEFORE the effect is applied
|
|
212
|
+
- [ ] `alreadyConsumed: true` skips the effect
|
|
213
|
+
- [ ] Durable purchases are written to the player's save
|
|
214
|
+
- [ ] No timer, "limited", "ends in", or stock counter anywhere
|
|
215
|
+
- [ ] Nothing sold is unreachable without paying
|
|
216
|
+
- [ ] No paid randomness, no coin wagering, no donation prompt
|
|
217
|
+
|
|
218
|
+
## Troubleshooting
|
|
219
|
+
|
|
220
|
+
**`buy()` returns `failed` with "the confirmation window was blocked"** — `buy()`
|
|
221
|
+
was not called inside a user gesture, or an `await` ran before it. Move it to the
|
|
222
|
+
first line of the click handler.
|
|
223
|
+
|
|
224
|
+
**The purchase succeeded but the player got nothing** — the game applied the
|
|
225
|
+
effect without consuming, or never ran `deliverPending()` on boot. The
|
|
226
|
+
entitlement is still there; re-list it.
|
|
227
|
+
|
|
228
|
+
**The player got the item twice** — the effect was applied before consuming, or
|
|
229
|
+
`alreadyConsumed` was ignored. Both are the same bug.
|
|
230
|
+
|
|
231
|
+
**`unauthorized` from `getShop()`** — no player identity yet. `initEmbed()` must
|
|
232
|
+
have run and `waitForPlayer()` resolved. See `$genex-threejs-embed-auth`.
|
|
233
|
+
|
|
234
|
+
**`guest_no_wallet`** — guests play but hold no wallet. Show the shop as
|
|
235
|
+
sign-in-to-buy rather than hiding it.
|
|
236
|
+
|
|
237
|
+
**`staging_no_purchase`** — a `genex preview` build cannot spend real coin. Test
|
|
238
|
+
the shop's layout on staging; test a purchase after `genex promote`.
|
|
239
|
+
|
|
240
|
+
**`getShop()` returns nothing** — the game has no items yet. `npx genex shop add
|
|
241
|
+
"<name>" --price <coin>` and use the id it prints.
|
|
242
|
+
|
|
243
|
+
**`price_off_grid`** — that price isn't on the platform's grid. `npx genex shop
|
|
244
|
+
list` prints the valid ones; pick the nearest.
|
|
245
|
+
|
|
246
|
+
**Everything coin-related 404s** — in-game purchases aren't enabled on this
|
|
247
|
+
environment. Nothing to fix in the game; say so and build the rest.
|
|
248
|
+
|
|
249
|
+
**Purchases do nothing in local testing** — local test mode has no wallet and no
|
|
250
|
+
server. `buy()` returns `failed` immediately by design. Test purchases on a
|
|
251
|
+
preview or published build.
|