-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathroom.ts
More file actions
55 lines (51 loc) · 1.34 KB
/
room.ts
File metadata and controls
55 lines (51 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import Direction from "./direction";
import IMazeElement from "./imazeelement";
class Room implements IMazeElement {
private static roomCounter: number = 1;
private roomID: number;
private northSide: IMazeElement;
private southSide: IMazeElement;
private eastSide: IMazeElement;
private westSide: IMazeElement;
constructor() {
this.roomID = Room.roomCounter++;
console.log("creating Room #" + this.roomID)
}
enter(): void { }
public setSide(d: Direction, site: IMazeElement) {
switch (d) {
case Direction.North:
this.northSide = site;
break;
case Direction.South:
this.southSide = site;
break;
case Direction.East:
this.eastSide = site;
break
case Direction.West:
this.westSide = site;
}
console.log("setting " + d +
" side of " +
this.toString() +
" to " +
site.toString());
}
public getSide(d: Direction): IMazeElement {
switch (d) {
case Direction.North:
return this.northSide;
case Direction.South:
return this.southSide;
case Direction.East:
return this.eastSide;
case Direction.West:
return this.westSide;
}
}
public toString(): string {
return "Room #" + this.roomID;
}
}
export default Room