Beginnings of verb hooks and rules engine
parent
5f9c76ba72
commit
3f37dd087d
@ -1,4 +1,12 @@
|
|||||||
|
import { ValidCommandDetails } from "./types/ParsedCommand";
|
||||||
|
|
||||||
|
// This class allows for hooking up "global events" for things such as checking
|
||||||
|
// victory conditions, acting when play begins, or other such things. These
|
||||||
|
// event types are different from player actions, which are all considered
|
||||||
|
// "command" events
|
||||||
export default class RulesEngine {
|
export default class RulesEngine {
|
||||||
// constructor() {
|
|
||||||
// }
|
runCommand(action: ValidCommandDetails) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
import Verb, { VerbAction } from "./Verb"
|
||||||
|
|
||||||
|
export default class VerbBuilder {
|
||||||
|
private verb : Verb
|
||||||
|
|
||||||
|
constructor(verb : Verb) {
|
||||||
|
this.verb = verb
|
||||||
|
}
|
||||||
|
|
||||||
|
as(template : string) : VerbBuilder {
|
||||||
|
this.verb.understand(template)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
before(callback : VerbAction) : VerbBuilder {
|
||||||
|
this.verb.on('before', callback)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
carryOut(callback : VerbAction) : VerbBuilder {
|
||||||
|
this.verb.on('carryOut', callback)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
after(callback : VerbAction) : VerbBuilder {
|
||||||
|
this.verb.on('after', callback)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue