-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmazegame.ts
More file actions
33 lines (29 loc) · 1.01 KB
/
mazegame.ts
File metadata and controls
33 lines (29 loc) · 1.01 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
import Maze from './maze'
import Room from './room'
import Door from './door'
import Direction from './direction';
import Wall from './wall';
class MazeGame {
public makeMaze() : Maze { return new Maze(); }
public makeRoom() : Room { return new Room(); }
public makeWall() : Wall { return new Wall(); }
public makeDoor(r1: Room, r2: Room) : Door { return new Door(r1, r2); }
public createMaze(): Maze {
var theMaze = this.makeMaze();
var r1 = this.makeRoom();
var r2 = this.makeRoom();
var theDoor = this.makeDoor(r1, r2);
theMaze.addRoom(r1);
theMaze.addRoom(r2);
r1.setSide(Direction.North, this.makeWall());
r1.setSide(Direction.East, theDoor);
r1.setSide(Direction.South, this.makeWall());
r1.setSide(Direction.West, this.makeWall());
r2.setSide(Direction.North, this.makeWall());
r2.setSide(Direction.East, this.makeWall());
r2.setSide(Direction.South, this.makeWall());
r2.setSide(Direction.West, theDoor);
return theMaze;
}
}
export default MazeGame