-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicPlayer.h
107 lines (101 loc) · 3.51 KB
/
BasicPlayer.h
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "Player.h"
using namespace std;
class Basic : public Player{
public:
int isGameOver(){
if (currentLocation->info.getID() == 1){
return 2;
}
else if(currentLocation->info.getGoal() == 1){
return 1;
}
else if(currentLocation->info.getID() == 0 && currentLocation->info.getGoal() == 0){
return 0;
}
else{
return 0;
}
};
void resetPlayerStats(){
// No Use
};
void reportStats(){
cout<<"No player statistics to report."<<endl;
};
virtual void armor(Map* mapptr){}
virtual void consume(Map* mapptr){
cout<<"What would you like to consume?"<<endl;
string n;
getline(cin, n);
nodeType<Item*>* temp = NULL;
temp = items.getFirst();
if(temp == NULL){
cout<<"You have no items in your inventory."<<endl;
}
else{
bool found = false;
while(temp != NULL && !found){
if(n == temp->info->getName()){
found = true;
if(temp->info->getType()!="consume"){
cout<<"That proves impossible"<<endl;
return;
}
}
else{
temp = temp->link;
}
}
if(found){
if(mapptr->reverseLookUp(currentLocation) == temp->info->getActiveArea()||temp->info->getActiveArea() == 0){
cout<<temp->info->getActiveMessage()<<endl;
}else{
cout<<"You cannot consume the "<<temp->info->getName()<<" here."<<endl;
}
}
else{
cout<<"No item by that name in your inventory."<<endl;
}
}
}
virtual void use(Map* mapptr){
cout<<"What would you like to use?"<<endl;
string item;
getline(cin, item);
nodeType<Item*>* temp = NULL;
temp = items.getFirst();
if(temp == NULL){
cout<<"You have no items in your inventory."<<endl;
}
else{
bool found = false;
while(temp != NULL && !found){
if(item == temp->info->getName()){
found = true;
}
else{
temp = temp->link;
}
}
if(found){
if(temp->info->getType()!="use"){
cout<<"There's no way to use this item."<<endl;
return;
}
if(mapptr->reverseLookUp(currentLocation) == temp->info->getActiveArea()||temp->info->getActiveArea() == 0){
cout<<temp->info->getActiveMessage()<<endl;
vector<Rule*> vec = temp->info->getItemUseRules();
// cout<<"Size of vec: "<<vec.size()<<endl;
for(int i=0;i<vec.size();i++){
mapptr->setNewLinks(vec[i]->beginRm, vec[i]->destRm, vec[i]->direction);
}
}else{
cout<<"You cannot use the "<<temp->info->getName()<<" here."<<endl;
}
}
else{
cout<<"No item by that name in your inventory."<<endl;
}
}
}
};