RaceDef
Interface of @v12-engine/engine
export interface RaceDefA side a player can play, with a roster of its own: melee's humans and undead. Optional: a game that lists none (Rules.races) has no race anywhere, no choice of one in the lobby and nothing kept from anyone. A unit type or an upgrade of a race (UnitTypeDef.race, UpgradeDef.race) is only its players' to make; one of none, everyone's. Each player has one (raceOf): chosen in the lobby (a seat setting the server offers by itself, seatSettingsOf), given to the world as it is made (PlayerInit.race, MapWorldOptions.races), or changed by the rules (setRace)
Members
basedOn
basedOn?: string;The definition this one is a copy of, made from the data (copyOf in a data.json, the editor's Copy as new): what it is drawn, heard and pictured as where the game gives it no look of its own
description
description?: string;What it is like, for a tooltip
hooks
hooks?: RaceHookDef[];Hook handlers of its own, run only for what is of its players (RaceHookDef): how it gathers, where it may build. With these a race plays differently with no test of the race in the game's code
icon
icon?: string;Its picture, by the id the game's view knows icons by
id
id: string;The race's id, shared by every game: referenced by PlayerInit.race, UnitTypeDef.race and UpgradeDef.race
inherits
inherits?: {
hooks?: boolean;
onStart?: boolean;
};What a race made as a copy of another (basedOn: copyOf in a data.json, the editor's Copy as new) keeps of the original's code: its hooks and its onStart, each kept unless said false here. A copy keeps both when this is left out, so a race copied from the undead gathers at a cursed mine and builds on blight as they do; one that says hooks: false plays by the game's rules alone. Its start is data, the copy's own to change; a start in code is kept whole. Two toggles in the Data panel, on a copy
name
name: string;What players are shown: in the lobby, on the scores
onStart
onStart?(world: World, player: PlayerId): void;Run for each of its players once a world is made from a map, after everything the map puts down and the starts: what its players begin with that is not a unit (a ground of its own around its halls, a state)
resources
resources?: Partial<Record<ResourceId, number>>;What its players start with of each resource, by resource id, over what the game starts everyone with (ResourceDef.start). Not for a player given resources of their own (PlayerInit.resources, a map's)
startingBase
startingBase?: StartingBase;What its players get at the start of a game on a map, in place of the game's (Rules.startingBase): its own hall and workers, as data (StartingBaseData: what a race made in the Data panel has, start.hall and the rest editable there) or as code (StartingBaseCode)