-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
66 lines (58 loc) · 1.71 KB
/
main.cpp
File metadata and controls
66 lines (58 loc) · 1.71 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
65
/*
* File: main.cpp
* Author: itcmcgrath
*
* Created on February 13, 2014, 12:09 PM
*/
#include <iostream>
#include <fstream>
#include <cstdlib>
#include "world.h"
/*
*
*/
int main(int argc, char** argv) {
World *world = new World("world.xml");
bool active = true, done;
std::string input;
std::cout << "You awake in: " << world->GetRoomName() << std::endl;
std::cout << world->GetRoomDescription() << std::endl;
while (active) {
done = false;
std::cin >> input;
if (input.compare("quit") == 0)
active = false;
else {
if (input.compare("look") == 0) {
done = true;
std::vector<std::string> directions = world->ListDirections();
for (unsigned long int direction = 0; direction < directions.size(); ++direction) {
std::cout << directions[direction] << std::endl;
}
}
if (input.compare("search") == 0) {
done = true;
std::vector<std::string> items = world->ListRoomItems();
for (unsigned long int index = 0; index < items.size(); ++index) {
std::cout << items[index] << std::endl;
}
}
if (input.compare("review") == 0) {
done = true;
std::vector<std::string> details = world->ListPlayerDetails();
for (unsigned long int index = 0; index < details.size(); ++index) {
std::cout << details[index] << std::endl;
}
}
if (!done) {
done = true;
if (world->DoCommand(input)) {
std::cout << "You are now in " << world->GetRoomName() << std::endl;
std::cout << world->GetRoomDescription() << std::endl;
} else
std::cout << world->GetErrorReason() << std::endl;
}
}
}
return 0;
}