Sets up the Step 1 (Project Foundation) and Step 2 (Content Schemas) scaffold from the implementation sequence. Includes Docker Compose stack, Nakama TypeScript module stubs, PostgreSQL migration, Godot 4 project shell with scene stubs and NakamaClient singleton, YAML content schemas for all entity types, and example data for 3 characters, 2 jobs, and all 7 core resources. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
// inventory.ts — player inventory and resource ledger
|
|
//
|
|
// Every grant and spend must produce a ledger entry so the economy is
|
|
// fully auditable. The wallet tracks numeric resources (gold, wood, etc.).
|
|
// The inventory tracks discrete items and character roster membership.
|
|
|
|
// Resource IDs — must match the keys used in content/schema/resource.yaml
|
|
export const RESOURCE_IDS = [
|
|
"gold",
|
|
"wood",
|
|
"stone",
|
|
"knowledge",
|
|
"experience",
|
|
"mana",
|
|
"diamond",
|
|
] as const;
|
|
|
|
export type ResourceId = typeof RESOURCE_IDS[number];
|
|
|
|
export function rpcGetInventory(
|
|
ctx: nkruntime.Context,
|
|
logger: nkruntime.Logger,
|
|
nk: nkruntime.Nakama,
|
|
_payload: string
|
|
): string {
|
|
// TODO PR 4: read character roster and item inventory from storage
|
|
logger.info(`inventory/get stub called by ${ctx.userId}`);
|
|
|
|
return JSON.stringify({
|
|
characters: [],
|
|
items: [],
|
|
message: "Inventory is stubbed. Implement in PR 4.",
|
|
});
|
|
}
|
|
|
|
export function rpcGetResources(
|
|
ctx: nkruntime.Context,
|
|
logger: nkruntime.Logger,
|
|
nk: nkruntime.Nakama,
|
|
_payload: string
|
|
): string {
|
|
// Read wallet balances — these are already tracked by Nakama's wallet system
|
|
const account = nk.accountGetId(ctx.userId);
|
|
const wallet = account.wallet ?? {};
|
|
|
|
const resources: Record<string, number> = {};
|
|
for (const id of RESOURCE_IDS) {
|
|
resources[id] = Number(wallet[id] ?? 0);
|
|
}
|
|
|
|
return JSON.stringify({ resources });
|
|
}
|