-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapDriver.cpp
More file actions
64 lines (62 loc) · 2.43 KB
/
mapDriver.cpp
File metadata and controls
64 lines (62 loc) · 2.43 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
56
57
58
59
60
61
62
63
64
#include "Map.cpp"
#include <cassert>
#include <iostream>
#include <string>
using namespace std;
int main()
{
Map map;
cout << "Initial map: " << endl;
map.displayMap(); // starting point
cout << "Default constructor: " << endl;
cout << "Room #: " << map.getRoomCount() << endl;
cout << "Let's add some rooms: " << endl;
assert(map.addRoom(2, 3));
assert(map.addRoom(8, 11));
assert(map.addRoom(2, 7));
assert(map.addRoom(8, 2));
assert(!map.addRoom(15, 15)); // should not show on map nor error out, out of bounds
assert(!map.addRoom(2, 3)); // will not do anything since space is occupied
assert(map.addRoom(5, 7));
assert(!map.addRoom(3, 7)); // will fail due to exceeding max_rooms_
map.displayMap();
cout << "Spawning some NPCs: " << endl;
assert(map.addNPC(4, 4));
assert(map.addNPC(1, 2));
assert(map.addNPC(7, 2));
assert(map.addNPC(10, 4));
assert(!map.addNPC(2, 7)); // should fail due to space being occupied
assert(map.addNPC(9, 0));
assert(!map.addNPC(10, 0)); // should fail due to max number of NPCs == 5
map.displayMap();
cout << "Let's move a little. First, down:" << endl;
map.move('s'); // go down
map.displayMap();
cout << "Now, right:" << endl;
map.move('d'); // go right
map.displayMap();
cout << "On an NPC space? ..." << map.isNPCLocation(map.getPlayerRow(), map.getPlayerCol()) << endl;
cout << "Moving onto an NPC space that was previously hidden:" << endl;
map.move('d'); // go right
map.displayMap();
cout << "On NPC space now?..." << map.isNPCLocation(map.getPlayerRow(), map.getPlayerCol()) << endl;
cout << "Let's move off it, should be updated as visible:" << endl;
map.move('d'); // go right
map.displayMap();
cout << "On room right now?..." << map.isRoomLocation(map.getPlayerRow(), map.getPlayerCol()) << endl;
cout << "Okay, let's move onto the room:" << endl;
map.move('s');
map.displayMap();
cout << "On room right now? " << map.isRoomLocation(map.getPlayerRow(), map.getPlayerCol()) << endl;
cout << "... and move left off" << endl;
map.move('a');
map.displayMap();
cout << "Let's remove that room" << endl;
assert(map.removeRoom(2, 3));
map.displayMap();
cout << "Let's explore the current space, then move down." << endl;
map.exploreSpace(map.getPlayerRow(), map.getPlayerCol());
map.move('s');
map.displayMap();
return 0;
}