Content catalogs for game modules
A catalog is a table of rows a designer edits in the Dashboard. The module declares its row
type in manifest.json and reads the rows of the release; it never writes them.
"content": { "seasons": {"row": "Season", "key": "key", "window": "window", "exclusive": true}, "tiers": {"row": "Tier", "indexes": ["season"]}, "settings": {"row": "Settings", "single": true, "default": {"xpPerWin": 10}}}season, found := seasons.Current()for _, tier := range tiers.BySeason(season.Key) { ... }xp := settings.Get().XpPerWinThe name of a catalog is the generated package variable.
Options
Section titled “Options”| Option | Meaning | Generated |
|---|---|---|
row | An object type of types. Required. | All() []T |
key | A string property that names each row, unique in the catalog. | Get(key) (T, bool) |
indexes | String or integer properties to look rows up by. | By<Field>(value) []T |
window | A property of type rudder:window: when the row is active. | Active() []T |
exclusive | With window: windows must not overlap. | Current() (T, bool) |
period | A property whose enum values day, week, month say the row starts again. Shown on the Calendar only. | |
single | Exactly one row: the settings of the module. | Get() T |
default | With single: the row a new install starts from. |
- Rows keep the order the designer gives them;
All,By<Field>andActivereturn that order. - A row without the window property is always active. A window is half-open, from
starttoend; a missing bound is open. - A method the catalog does not declare does not exist, so a wrong lookup is a compile error.
- A
singlecatalog takes nokey,indexesorwindow. Its row is written into the draft fromdefaultwhen the module is installed, and an update adds the properties a newdefaultbrings while keeping what an operator saved.
Windows in code
Section titled “Windows in code”rudder.Window has Open(), Closed() and Finished() at the time of the call, for a window
that is a field of a row rather than the window of the catalog:
if !offer.Window.Open() { return OfferState{}, ErrNotOnSale}What is checked
Section titled “What is checked”A row is checked when it is saved and again when a release is published:
- its type: required properties present and not null, no unknown property;
- its key: present, a non-empty string, unique in the catalog;
- its window: the end after the start;
- every amount, at any depth: a currency of the project, not negative.
What one row cannot tell, such as windows that overlap in an exclusive catalog or a row that
stopped fitting after an update, is a problem of the catalog: shown above its rows and
refusing a publish until fixed.
Samples
Section titled “Samples”Example rows live in samples/<name>.json next to manifest.json, and an operator adds them
in a click from the Samples tab of the module:
{ "title": "A potion and a sword", "description": "Two items to start with.", "catalogs": { "items": [ {"key": "potion", "name": "Potion", "kind": "stack", "stack": 99, "tradable": true}, {"key": "sword", "name": "Sword", "kind": "unique", "tradable": true} ] }}A file name is lowercase letters, digits and dashes. A sample has a title and rows of
catalogs the module declares, one row at most for a single one. Adding a sample skips a row
whose key is taken; a row that fails its checks refuses the whole sample. A sample that names a
currency needs that currency in the project first. Samples are uploaded with the module and
never reach a release.