commit:c4de3b83ead3354ea5c50de85c78b73623c3bf86
author:Chip Black
committer:Chip Black
date:Thu Aug 6 01:49:34 2020 -0500
parents:0cbf22bc7a16549a69e184fd6e7e5f47bcbbcccb
Add exits property to Cell
diff --git a/src/cell.ts b/src/cell.ts
line changes: +8/-1
index f237571..d8afced
--- a/src/cell.ts
+++ b/src/cell.ts
@@ -3,6 +3,7 @@ import { ID, generateID } from './id';
 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
@@ -26,6 +27,7 @@ export interface CellProperties {
     description: string
     events: GameEventProperties[]
     objects: ID[]
+    exits: [boolean, boolean, boolean, boolean]
     // agents are not saved
 }
 
@@ -35,12 +37,13 @@ export class Cell extends Storable {
     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();
@@ -82,6 +85,10 @@ export class Cell extends Storable {
         }
     }
 
+    canMove(d: Direction): boolean {
+        return this.exits[d];
+    }
+
     store() {
         return Object.assign(<CellProperties>super.store(), {
             objects: Array.from(this.objects).map( ([id, obj]) => id),