Rules
Interface of @v12-engine/engine
export interface RulesA game module is the data and rules of one kind of game. The engine knows nothing about peasants or town halls, it gets all of that from here.
Members
abilities
abilities?: AbilityDef[];The abilities of the game; none when left out
afterLoad
afterLoad?: (world: World) => void;Runs once a world is loaded from a save, everything put back: for what a game keeps outside the world, to make again from what is in it
ai
ai?: GameAi;What it says of its computer players' profiles (GameAi, AI plan D1): difficulties and personalities of its own beside the engine's, defaults over the engine's, and whether a lobby offers each seat a difficulty and a personality (seatSettingsOf)
areas
areas?: AreaDef[];Parts of the map the rules watch: who walks in and out (see AreaDef)
brains
brains?: BrainDef[];The brains of its computer players (defineBrain), given here as components and timers are, so that a save that remembers a seat by its brain's id (world.computers.seat) finds the brain again when loaded. The first is what a seat that names no brain gets: meleeBrain of @v12-engine/engine/ai for a game played as melee, or a computer player of the game's own (defineComputer). None listed: the game has no computer player, and seating one throws
buffs
buffs?: BuffDef[];The buffs of the game; none when left out
cellLayers
cellLayers?: CellLayerDef[];Its own layers of cells, for its rules to read and the editor to paint: where the bushes are (see CellLayerDef). Any layer can be read and set by id whether it is listed or not; listed, the editor offers it
commands
commands?: CommandDef[];Commands of the game's own, made with defineCommand, or replacements for the core ones
components
components?: Component<any>[];The state of its own the game keeps (see defineComponent): on entities, players and the world. Given here as timers and listeners are, so that a world knows who is told which (replicate) from its own game, and not from whatever else the process has loaded. One used without being listed is an error (UnlistedError): no world finds it, so a save or a snapshot would lose it
currency
currency?: ResourceId;The resource prices, bounties, revives and sales are in. The first resource when left out
day
day?: DayCycle;Day and night. Always day when left out
defaults beta
defaults?: ChosenDefaults;The default sets the game took (useDefaults), what it chose of each, and how to choose again (what a data.json's defaults does). Set by useDefaults, never by hand
editable
editable?: EditableData;Which fields of its definitions the editor's Data panel may change (S61): all, or by kind (units, abilities, buffs, items, upgrades) all of them, some (their paths, stats.health, or fields said in full, with bounds and a kind), or each definition's own in code. None when left out. What is changed there is kept in the game's data.json, which the game reads over its code with layData
editor
editor?: MapEditorDef;What the game brings to the map editor (see MapEditorDef)
effects
effects?: EffectType[];Kinds of effects abilities can have, next to the ones the engine knows (defineEffect): one of a type the engine has takes its place
events
events?: EventKey<any>[];The events of its own the game emits (see defineEvent): given here for the same reason
files
files?: GameFileDef<unknown>[];Files of the game's own data its rules read as they run, and a panel edits (see defineGameFile, registry.file)
formations
formations?: FormationDef[];Formations of its own for units ordered to a point together (FormationDef), next to the engine's rows, circle, square and none, or in place of one of the same id. Which an order takes is the order's to say (OrderInit.formation), and the rules' where it does not (RuleSettings.movement.formation)
generator
generator?: MapGenerator;Its generator of maps (MapGenerator, generateMap): what the editor's New map from a generator and the page's Random map make a map with, its parameters as their sliders. None when left out: the engine's presetGenerator is there to take, with the game's trees and rocks
hooks
hooks?: HookDef[];Handlers of hooks: how the module takes part in damage, deaths, orders. One with the id of a core one takes its place
id
id: string;The game's id, which a save and a server know it by
items
items?: ItemDef[];The items of the game; none when left out
listeners
listeners?: ListenerDef[];How the game reacts to events, the engine's and its own (see defineListener)
log
log?: {
level?: LogLevel;
};How much its worlds say (world.log): the least an entry must matter to be said, everything when left out. Where the entries go is whoever runs the game's to say (world.log.to, the logger a world is made under)
maps
maps?: readonly GameMap[];The maps the game ships (S36): a world made from one of them keeps, in its save and in the welcome a server sends, only what changed of its ground, and whoever reads it finds the rest here (by its name and the ground it makes). Not in the game's hash. A map not among them, or changed since, is kept whole, as before
maxPlayers
maxPlayers?: number;Players a map of the game may have, besides the neutral and the creeps: 8 when left out, 32 at most (MAX_MAP_PLAYERS). A map with more is refused, saying so, not cut
mods
mods?: {
id: string;
version: string;
hash?: string;
}[];The mods on it, with their versions, when it was made with composeGame
name
name: string;What the player sees the game called
navigation
navigation?: GameNavigationOptions;How its worlds find their way: the radius the walkable ground is cut for, how steep it may be, how many units the crowd makes room for at first (maxAgents), the sizes it is cut for (radii: 'auto' unless said, a navigation for each size of ground unit the game has). What a world is made with (CreateWorldOptions.navigation) goes over it
onError
onError?: ErrorPolicy;What becomes of a part of the game that throws (a hook's handler, a listener, a system, a timer, an order, a command): throw (the error goes on: tests), end (the game ends there, the players told), disable (the part is switched off and the game goes on), or a function that says which for each. When left out: a world throws, and a server and a launched game end the game (world.errorPolicy)
onReload
onReload?: (world: World) => void;Runs as a world takes a new version of the game while it runs (hot reload, reloadGame), the new version's: for what the game made of the old one (a cache of its definitions, a state worked out of them), to make again. What else hears it: world.events.on(gameReloaded, …), and a screen's GameView.on
orders
orders?: OrderBehavior[];Extra order types, or replacements for the core ones
packs beta
packs?: GamePack[];The parts of the rules the game opts into, with what they bring (GamePack): [heroesPack()] for heroes, camps and shops. None when left out. The game's own commands, orders, systems and hooks come after a pack's, and one of the same id takes its place
paths beta
paths?: 'all' | 'seen';What a route of a ground unit knows of the buildings in its way (determinism plan F2): all of them (the default), as the ground is; or only those its side has seen, so the way it goes in the dark says nothing of what is there. With seen, each side has a navigation of its own to plan on, of what it knows: a few megabytes a side on a big map. Units still walk around every building: they see one before they reach it, and plan again
prefabs
prefabs?: PrefabDef[];Groups of things the game spawns as one (see definePrefab, world.spawnPrefab); a designer's from the editor through prefabsFrom
races
races?: RaceDef[];The sides players can play, each with its own roster (UnitTypeDef.race): none when left out, and with that no race anywhere. The first is what a player plays when nobody chose
report
report?: (world: World, player: PlayerId) => Record<string, unknown>;What the game tells each player about itself, beyond what the engine knows: the wave a tower defense is at, a score, a countdown. Plain data that survives being sent; it goes into every snapshot as report, where the game's view (GameView.hud.status) puts it on the screen. Only what that player may know
resources
resources?: ResourceDef[];What players have amounts of and pay with, in the order they are shown. None when left out
saves
saves?: SaveRules;How its saves outlive its patches (SaveRules): the version of what it keeps in a save, the steps that bring an older save up to it, and what becomes of a save made with other rules. A game that declares it, even empty, loads the saves made before a patch; one that does not refuses every save not made with its very rules, as a test wants
sequences
sequences?: SequenceDef[];Scripts of steps the game starts, like a mission's (see defineSequence): given here, so that a save finds them
server
server?: ServerHooks;What the game does on a server, around its games: who joins and leaves, the start and the end (see ServerHooks)
settings
settings?: RuleSettingsInit;The numbers of the game that are not about any one unit, like the supply cap. The engine's for those left out
startingBase
startingBase?: StartingBase;What a player starts a map with, for players the map places nothing for: a hall and workers as data, or a function (StartingBase)
stats
stats?: StatDef[];Stats of the game's own, next to the engine's (CoreStats). Units, buffs, items and upgrades change them, and abilities scale with them, like any other
systems
systems?: SystemDef[];Systems of the game's own. They run after the core ones unless they give a phase (see System); one with the name of a core system takes its place, and its phase too unless it gives its own. A function makes a system for each world: what keeps state between ticks has to be made that way, or every game made from the module shares it
tags beta
tags?: TagDef[];The tags of its items named and given a look, and which of them a shop filters by (TagDef). A tag no definition names still works, shown as its word. None when left out
targetings
targetings?: Targeting[];Ways of aiming an ability of the game's own (defineTargeting), next to the engine's (AimKind): named by an ability's target
tiles
tiles?: TileDef[];What the ground of its maps can be painted with, in order: the first is index 1 of Terrain.tiles, 0 being no paint (see TileDef). What each looks like is the view's (GameView.ground.tiles)
timers
timers?: TimerDef[];What the game sets to go off later (see defineTimer): given here, so that a save finds them by id
tunables
tunables?: TunableDef[];Numbers of its rules to be tuned while it plays (defineTunable), read with world.tunable(id)
units
units: UnitTypeDef[];The unit types of the game
upgrades
upgrades?: UpgradeDef[];The upgrades of the game; none when left out
upkeep
upkeep?: UpkeepTier[];The tiers of upkeep, by supply used; none when left out
version
version?: string;major.minor.patch, for mods to say which versions of the game they work with. 1.0.0 when left out
victory
victory?: SystemDef | null;Decides who is out and who won. The last team with a building, when left out. Null for a game nobody can lose
withoutCommands beta
withoutCommands?: string[];Types of the engine's own commands, or a pack's, the module does without (coreCommands, heroCommands)
withoutHooks
withoutHooks?: string[];Ids of the engine's own hook handlers the module does without, like bounty (see coreHooks)
withoutOrders beta
withoutOrders?: string[];Types of the engine's own orders, or a pack's, the module does without: a unit is then never given one
withoutSystems
withoutSystems?: string[];Names of the engine's own systems the module does without (see coreSystems)