-
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.27 KB
/
room.ts
File metadata and controls
55 lines (51 loc) · 1.27 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 MapSite from "./mapsite";
class Room extends MapSite {
constructor() {
super();
this.roomNr = Room.roomCnt++;
console.log("creating Room#" + this.roomNr)
}
public setSide(d: Direction, site: MapSite) {
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): MapSite {
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.roomNr;
}
private static roomCnt: number = 1;
private roomNr: number;
private northSide: MapSite;
private southSide: MapSite;
private eastSide: MapSite;
private westSide: MapSite;
}
export default Room