-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.h
150 lines (137 loc) · 4.25 KB
/
Game.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include "MapV2.h"
#include "Combat.h"
//#include "Player.h"
#ifndef ullItem
#define ullItem
#include "ull.h"
#include "Item.h"
#endif
class Game{
protected:
MapV2* map = new MapV2;
Player* player1;
/************************************
COMBAT SYSTEM: NEW COMBAT OBJECT
************************************/
Combat* combat;
public:
Game(){
player1 = map->getPlayer();
player1->setCurrent(map->getStart());
}
void play()
{
string userInput = "u";
while(true)
{
//check game status
if(player1->isGameOver() != 0){
player1->getCurrent()->info->displayArea();
return; // END THE GAME HERE
}
//CHECK FOR COMBAT HERE
//if combatID == 1
/****************************************
COMBAT SYSTEM: CHECK FOR COMBAT ID
****************************************/
if(player1->getCurrent()->info->getCombatID() == 1) //If there is combat
{
combat->displayCombatMessage(); //display message
combat->engageCombat(player1); //starty combat event
}
//display area data
if(player1->playerMoved() && (userInput == "u" || userInput == "d" || userInput == "l" || userInput == "r")){
player1->getCurrent()->info->displayArea();
}
else{
if(userInput == "u" || userInput == "d" || userInput == "l" || userInput == "r"){
cout<<"There appears to be no way to go that direction."<<endl;
}
}
//get movement selection
cout<<"Which way would you like to go? Enter u, d, l, or r"<<endl;
getline(cin, userInput);
//update area
if(userInput == "u"){
player1->setCurrent(player1->getCurrent()->u);
}
else if(userInput == "d"){
player1->setCurrent(player1->getCurrent()->d);
}
else if(userInput == "l"){
player1->setCurrent(player1->getCurrent()->l);
}
else if(userInput == "r"){
player1->setCurrent(player1->getCurrent()->r);
}
else if(userInput == "iseedeadpeople"){ //issdeadpeople cheat code to reveal map
cout<<map;
}
else if(userInput == "reset"){
resetGame();
}
else if(userInput == "exit"){
cout<<"Good bye!"<<endl;
return;
}
else if(userInput == "search"){
player1->getCurrent()->info->search();
}
else if(userInput == "inventory"){
player1->inventory();
}
else if(userInput == "take"){
player1->take();
}
else if(userInput == "leave"){
player1->leave();
}
else if(userInput == "examine"){
player1->examine();
}
else if(userInput == "use")
{
player1->use(map);
}
else if(userInput == "consume")
{
player1->consume(map);
}
else if(userInput == "stats")
{
player1->reportStats();
}
else if(userInput == "help"){
cout<<"You may type: "<<endl;
cout<<"\t u, d, l, or r: to move up, down, left or right on the map,"<<endl;
cout<<"\t search: to search for items in current area,"<<endl;
cout<<"\t take: to attempt to take an item,"<<endl;
cout<<"\t leave: to attempt to leave an item,"<<endl;
cout<<"\t examine: to examine an item in your inventory,"<<endl;
cout<<"\t use: to use an item in your inventory,"<<endl;
cout<<"\t consume: to consume an item in your inventory,"<<endl;
cout<<"\t stats: to report players stats,"<<endl;
cout<<"\t reset: to reset the game,"<<endl;
cout<<"\t exit: to exit the game."<<endl;
cout << endl << endl;
cout << "Combat Rules: " << endl;
cout << "You are given 3 options to type (1, 2, or 3)." << endl;
cout << "At random, if you choose the correct number, you will deal damage to the enemy." << endl;
cout << "However, if you choose the wrong number, you take damage." << endl;
cout<<endl;
}
else{
cout<<"I do not understand: "<<userInput<<endl<<endl;
}
}//end while
}//end play()
void resetGame(){
player1->setCurrent(map->getStart());
//remove item from player list
player1->items.destroyList();
//remove item from each area in turn
player1->resetPlayerStats();
map->resetItems();
map->resetCombat(); //added comat reset!!!
}
};