defineProducts
defineProducts<
Schemas>(products):Readonly<typeofproducts>
A game’s products by key, checked and returned as they are, each key
typed. A price is whole Spawnites from 10 to 10,000, a consumable needs a
grant and a durable product has none, stock and perPlayerLimit
are whole numbers from 1, and a game declares at most 200. Throws,
naming the first product it refuses and what it breaks, for any other. A consumable’s
context types what its grant receives.
Register the keys once with
declare module "@spawnite/engine" { interface Register { products: typeof products } }.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Schemas extends Record<string, unknown> |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
products |
{ [Key in string | number | symbol]: ProductDeclaration<SchemaOrNone<Schemas[Key]>> } |
Returns
Section titled “Returns”Readonly<typeof products>