Add exits property to Cell
import { GameEvent, GameEventProperties, GameEventType } from './event';
import { GameObject, GameObjectProperties, GameObjectType } from './object';
import { GameAgent } from './agent';
+import { Direction } from './direction';
import gs from './gamestate';
/* Cell
description: string
events: GameEventProperties[]
objects: ID[]
+ exits: [boolean, boolean, boolean, boolean]
// agents are not saved
}
y: number
title: string
description: string
+ exits = [true, true, true, true];
events: Map<ID, GameEvent>
objects: Map<ID, GameObject>
agents: Map<ID, GameAgent>
navigable: boolean
- saveProperties = ['x', 'y', 'id', 'title', 'description']
+ saveProperties = ['x', 'y', 'id', 'title', 'description', 'exits']
constructor(x: number, y: number) {
super();
}
}
+ canMove(d: Direction): boolean {
+ return this.exits[d];
+ }
+
store() {
return Object.assign(<CellProperties>super.store(), {
objects: Array.from(this.objects).map( ([id, obj]) => id),