import {TopLevelStatement, TopLevelStatementType} from "./TopLevelStatement"; import {ScriptExpression} from "./ScriptExpression"; export interface BattlerDeclaration { readonly type: TopLevelStatementType.BATTLER readonly id: string readonly contents: readonly BattlerStatement[] } export function battlerDeclaration(id: string, contents: readonly BattlerStatement[]): BattlerDeclaration { return { type: TopLevelStatementType.BATTLER, id, contents, } } export function isBattlerDeclaration(statement: TopLevelStatement): statement is BattlerDeclaration { return statement.type === TopLevelStatementType.BATTLER } export enum BattlerStatementType { ATTRIBUTE = "attribute", } export enum BattlerAttributeType { HEALTH = "health", CONFIDENCE = "confidence", STAMINA = "stamina", } export function battlerAttributeType(text: string): BattlerAttributeType { switch (text) { case "health": return BattlerAttributeType.HEALTH case "confidence": return BattlerAttributeType.CONFIDENCE case "stamina": return BattlerAttributeType.STAMINA default: throw Error(`Unrecognized attribute for battler: ${text}`) } } export interface BattlerAttribute { readonly type: BattlerStatementType.ATTRIBUTE readonly attribute: BattlerAttributeType readonly value: ScriptExpression } export function battlerAttribute(attribute: BattlerAttributeType, value: ScriptExpression): BattlerAttribute { return { type: BattlerStatementType.ATTRIBUTE, attribute, value } } export function isBattlerAttribute(statement: BattlerStatement): statement is BattlerAttribute { return statement.type === BattlerStatementType.ATTRIBUTE } export type BattlerStatement = BattlerAttribute