/src/event.ts
import Storable from './storable'; import { ID, generateID } from './id'; import { Script } from './script'; import gs from './gamestate'; export enum GameEventType { Enter, Leave, Random, Action, } export interface GameEventProperties { id: ID type: GameEventType script: string title: string } export class GameEvent extends Storable { id: ID type: GameEventType script: string title: string saveProperties = ['id', 'type', 'script', 'title'] constructor() { super(); this.id = generateID(); this.type = GameEventType.Random; this.script = ''; this.title = ''; } async execute() { const script = new Script(this.script); gs.actions.clear(); await script.execute(); gs.showCellActions(); } getCallback() { return this.execute.bind(this); } store() : GameEventProperties { return <GameEventProperties>super.store() } load(properties: GameEventProperties) { return super.load(properties); } }