Skip to content

Roles beta ​

Class of @v12-engine/engine/ai

ts
export declare class Roles

What the unit types of a game are for (AiView.roles): the inferred roles (inferRoles, or a game's own finder in its place) with what the game declares on a type over them (UnitTypeDef.ai), and the queries over them

Members ​

constructor ​

ts
constructor(
    table: RoleTable, registry: Registry);

Constructs a new instance of the Roles class

explain ​

ts
explain(type: string): string;

Why a type has the roles it has, in words, for the report: declared: worker for what the game said, a line per inferred role otherwise

has ​

ts
has(type: string, role: AiRole): boolean;

Whether a unit type has a role

hasTag ​

ts
hasTag(type: string, tag: string): boolean;

Whether a unit type has a tag

hints ​

ts
hints(type: string): AiHints | undefined;

What a game declared of a type (UnitTypeDef.ai): nothing where it declared nothing

of ​

ts
of(type: string): readonly AiRole[];

The roles of a unit type: none for one that has none, or is not a unit type at all

report ​

ts
report(): Record<string, string[]>;

Every role and the types that have it, for the report (the debug tools)

table ​

ts
readonly table: RoleTable;

Every unit type's roles and tags, by id

tagged ​

ts
tagged(tag: string): readonly UnitTypeDef[];

The unit types with a tag, in the game's order

tags ​

ts
tags(type: string): readonly string[];

The tags of a unit type: the kit's (ranged, melee, hitsAir) and the game's (UnitTypeDef.ai.tags)

types ​

ts
types(role: AiRole): readonly UnitTypeDef[];

The unit types with a role, in the game's order (the first of a kind is the one meant first)