|
|
@ -2,48 +2,52 @@ import grammar from "./grammar.ohm-bundle"; |
|
|
|
import { |
|
|
|
import { |
|
|
|
Affinity, |
|
|
|
Affinity, |
|
|
|
ElementalType, |
|
|
|
ElementalType, |
|
|
|
|
|
|
|
FailReason, |
|
|
|
MarkdownContext, |
|
|
|
MarkdownContext, |
|
|
|
MarkdownOutput, |
|
|
|
MarkdownOutput, |
|
|
|
MeteredResource, |
|
|
|
MeteredResource, |
|
|
|
NumberSign, |
|
|
|
NumberSign, |
|
|
|
Operands, OperandsFrom, |
|
|
|
Operands, |
|
|
|
|
|
|
|
OperandsFrom, |
|
|
|
ParseContext, |
|
|
|
ParseContext, |
|
|
|
Resource, Source, Target, |
|
|
|
Resource, |
|
|
|
|
|
|
|
Source, |
|
|
|
|
|
|
|
Target, |
|
|
|
UnmeteredResource, |
|
|
|
UnmeteredResource, |
|
|
|
} from "../model/Messages"; |
|
|
|
} from "../model/Messages"; |
|
|
|
import {Iter, IterationNode, Node, NonterminalNode, TerminalNode} from "ohm-js"; |
|
|
|
import {IterationNode, Node, NonterminalNode, TerminalNode} from "ohm-js"; |
|
|
|
import {CharacterPrivacy, CharacterSide} from "../model/Character"; |
|
|
|
import {CharacterPrivacy, CharacterSide} from "../model/Character"; |
|
|
|
import {ClockMode, TimerDirection} from "../model/GameState"; |
|
|
|
import {ClockMode, TimerDirection} from "../model/GameState"; |
|
|
|
|
|
|
|
|
|
|
|
export const parser = grammar.createSemantics() |
|
|
|
export const parser = grammar.createSemantics() |
|
|
|
|
|
|
|
|
|
|
|
export interface ParserNode extends Node { |
|
|
|
export interface ParserNode extends Node { |
|
|
|
element: ElementalType|null |
|
|
|
readonly element: ElementalType|null |
|
|
|
affinity: Affinity |
|
|
|
readonly affinity: Affinity |
|
|
|
sign: NumberSign |
|
|
|
readonly sign: NumberSign |
|
|
|
numberValue: number |
|
|
|
readonly numberValue: number |
|
|
|
identifier: string |
|
|
|
readonly identifier: string |
|
|
|
resource: Resource|null |
|
|
|
readonly resource: Resource|null |
|
|
|
operands: Operands |
|
|
|
readonly operands: Operands |
|
|
|
blockTargets: Operands |
|
|
|
readonly blockTargets: Operands |
|
|
|
blockSources: Operands |
|
|
|
readonly blockSources: Operands |
|
|
|
silenced: boolean |
|
|
|
readonly silenced: boolean |
|
|
|
currentValue: number |
|
|
|
readonly currentValue: number |
|
|
|
maxValue: number |
|
|
|
readonly maxValue: number |
|
|
|
|
|
|
|
readonly failReason: FailReason |
|
|
|
|
|
|
|
readonly side: CharacterSide |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Implement all of the things listed below.
|
|
|
|
// TODO: Implement all of the things listed below.
|
|
|
|
textValue: string |
|
|
|
readonly textValue: string |
|
|
|
failReason: unknown // TODO: create an enum for this
|
|
|
|
|
|
|
|
// TODO: create rules for these to describe clocks/timers/items/statuses/characters and implement them
|
|
|
|
// TODO: create rules for these to describe clocks/timers/items/statuses/characters and implement them
|
|
|
|
nameText: string |
|
|
|
readonly nameText: string |
|
|
|
descriptionText: string |
|
|
|
readonly descriptionText: string |
|
|
|
// TODO: use for portraits, status icons, backdrops, BGM, and SFX
|
|
|
|
// TODO: use for portraits, status icons, backdrops, BGM, and SFX
|
|
|
|
url: string |
|
|
|
readonly url: string |
|
|
|
side: CharacterSide |
|
|
|
readonly privacy: CharacterPrivacy |
|
|
|
privacy: CharacterPrivacy |
|
|
|
readonly clockMode: ClockMode |
|
|
|
clockMode: ClockMode |
|
|
|
readonly timerDirection: TimerDirection |
|
|
|
timerDirection: TimerDirection |
|
|
|
readonly timerDurationMs: number |
|
|
|
timerDurationMs: number |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: add backdrop and music change and sfx commands
|
|
|
|
// TODO: add backdrop and music change and sfx commands
|
|
|
|
// TODO: make sure that FP and UP spent gets saved in the appropriate counters
|
|
|
|
// TODO: make sure that FP and UP spent gets saved in the appropriate counters
|
|
|
@ -783,3 +787,63 @@ parser.addAttribute<number>("maxValue", { |
|
|
|
throw Error(`No idea what to say ${this.ctorName} terminal node's max value is`) |
|
|
|
throw Error(`No idea what to say ${this.ctorName} terminal node's max value is`) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser.addAttribute<FailReason>("failReason", { |
|
|
|
|
|
|
|
avoid(): FailReason.Avoid { |
|
|
|
|
|
|
|
return FailReason.Avoid |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
dodge(): FailReason.Dodge { |
|
|
|
|
|
|
|
return FailReason.Dodge |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
miss(): FailReason.Miss { |
|
|
|
|
|
|
|
return FailReason.Miss |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
resist(): FailReason.Resist { |
|
|
|
|
|
|
|
return FailReason.Resist |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
fail(): FailReason.Fail { |
|
|
|
|
|
|
|
return FailReason.Fail |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
block(): FailReason.Block { |
|
|
|
|
|
|
|
return FailReason.Block |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
parry(): FailReason.Parry { |
|
|
|
|
|
|
|
return FailReason.Parry |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
FailReason(reason: NonterminalNode): FailReason { |
|
|
|
|
|
|
|
return (reason as ParserNode).failReason |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
FailOperation(operands: NonterminalNode, colon: NonterminalNode, reason: NonterminalNode): FailReason { |
|
|
|
|
|
|
|
return (reason as ParserNode).failReason |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
_iter(): never { |
|
|
|
|
|
|
|
throw Error(`No idea what to say ${this.ctorName} iteration node's fail reason is`) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
_nonterminal(): never { |
|
|
|
|
|
|
|
throw Error(`No idea what to say ${this.ctorName} nonterminal node's fail reason is`) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
_terminal(): never { |
|
|
|
|
|
|
|
throw Error(`No idea what to say ${this.ctorName} terminal node's fail reason is`) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser.addAttribute<CharacterSide>("side", { |
|
|
|
|
|
|
|
characterSide(side: NonterminalNode): CharacterSide { |
|
|
|
|
|
|
|
return (side as ParserNode).side |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
enemySide(): CharacterSide.Enemy { |
|
|
|
|
|
|
|
return CharacterSide.Enemy |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
allySide(): CharacterSide.Ally { |
|
|
|
|
|
|
|
return CharacterSide.Ally |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
_iter(): never { |
|
|
|
|
|
|
|
throw Error(`No idea what to say ${this.ctorName} iteration node's loyalties are`) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
_nonterminal(): never { |
|
|
|
|
|
|
|
throw Error(`No idea what to say ${this.ctorName} nonterminal node's loyalties are`) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
_terminal(): never { |
|
|
|
|
|
|
|
throw Error(`No idea what to say ${this.ctorName} terminal node's loyalties are`) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |