-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lirael.cpp
205 lines (191 loc) · 6.59 KB
/
Lirael.cpp
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/************************************************************************************
** Program name: 162 Final Project
** Author: Kristin Wood
** Date: 3/14/2018
** Description: This class is the main character of the game. It defines enums for
** items she can carry in her pack, as well as the 7 bells in her bandolier.
** Within the class definition, there are variables for strength, maximum
** strength, a vector of PackItems, a pointer to her location, and bools for
** if she has bells, a dark mirror, and the Disreputable Dog. She also has get
** and set functions, functions to add, remove and display her items, and use
** her bells.
************************************************************************************/
#include <iostream>
#include "Lirael.hpp"
#include "ClayrGlacier.hpp"
Lirael::Lirael() {
maxStrength = 50;
strength = 50;
location = nullptr;
hasBells = false;
hasMirror = false;
hasDog = false;
}
/************************************************************************************
* This function takes a PackItems variable as a parameter and adds it to the pack.
* It updates bools for certain items that will be used in the game and allows the
* user to remove one of the items already in the pack to make room if there is not
* enough space.
************************************************************************************/
void Lirael::addItem(PackItems item) {
if (pack.size() < 5) {
pack.push_back(item);
if (item == BELLS) {
hasBells = true;
}
else if (item == MIRROR) {
hasMirror = true;
}
else if (item == DOG) {
hasDog = true;
}
}
else {
std::cout << "\nLirael's pack is too full. Do you want to remove an item to make room?\n\n";
std::cout << "Y for yes, N for no: ";
char userChoice;
std::cin >> userChoice;
if (userChoice == 'Y' || userChoice == 'y') {
std::cout << "\nPlease enter the number of the item you would like to remove.\n";
displayItems();
std::string userString;
std::cin >> userString;
int userInt = isInt(userString, 1, 5);
removeItem(userInt-1);
pack.push_back(item);
//Reset bools and go through pack to see what is there.
hasBells = false;
hasMirror = false;
hasDog = false;
for (auto i : pack) {
if (i == BELLS) {
hasBells = true;
}
else if (i == MIRROR) {
hasMirror = true;
}
else if (i == DOG) {
hasDog = true;
}
}
}
}
}
/************************************************************************************
* This function displays the items in Lirael's pack.
************************************************************************************/
void Lirael::displayItems() {
for (int i = 0; i < pack.size(); i++) {
std::cout << i+1 << ". ";
if (pack[i] == BELLS) {
std::cout << "Bell Bandolier\n";
}
else if (pack[i] == SWORD) {
std::cout << "Sword\n";
}
else if (pack[i] == DOG) {
std::cout << "Disreputable Dog\n";
}
else if (pack[i] == MIRROR) {
std::cout << "Dark Mirror\n";
}
else if (pack[i] == SKIN) {
std::cout << "Charter Skin\n";
}
else if (pack[i] == BOOK) {
std::cout << "Book of Remembrance and Forgetting\n";
}
else if (pack[i] == MOUSE) {
std::cout << "Emergency Mouse\n";
}
}
}
/************************************************************************************
* This function takes an int as a parameter and removes the item at that index from
* the pack.
************************************************************************************/
void Lirael::removeItem(int itemIndex) {
if (itemIndex <= pack.size()) {
pack.erase(pack.begin() + itemIndex);
}
else {
std::cout << "The item could not be removed.\n";
}
}
/************************************************************************************
* This function displays the bells in Lirael's bandolier and returns a Bell of the
* user's choice.
************************************************************************************/
Bells Lirael::useBell() {
std::string bellChoice;
std::cout << "\nWhich bell would you like to use?\n";
std::cout << "1. Ranna, the Sleeper\n";
std::cout << "2. Mosrael, the Waker\n";
std::cout << "3. Kibeth, the Walker\n";
std::cout << "4. Dyrim, the Speaker\n";
std::cout << "5. Belgaer, the Thinker\n";
std::cout << "6. Saraneth, the Binder\n";
std::cout << "7. Astarael, the Sorrowful\n";
std::cin >> bellChoice;
int bell = isInt(bellChoice, 1, 7);
if (bell == 1) {
return RANNA;
}
else if (bell == 2) {
return MOSRAEL;
}
else if (bell == 3) {
return KIBETH;
}
else if (bell == 4) {
return DYRIM;
}
else if (bell == 5) {
return BELGAER;
}
else if (bell == 6) {
return SARANETH;
}
else if (bell == 7) {
return ASTARAEL;
}
}
/************************************************************************************
* This function changes the maxStrength variable and is used to change the capacity
* of Lirael's strength/health.
************************************************************************************/
void Lirael::setMaxStrength(int maxStrength){
this->maxStrength = maxStrength;
} //When upper limit needs to be increased.
int Lirael::getMaxStrength() {
return maxStrength;
}
/************************************************************************************
* This function takes a positive or negative int as a parameter and adds it to
* Lirael's current strength. If the strength is greater than her maxStrength, then
* strength is set to maxStrength.
************************************************************************************/
void Lirael::addStrength(int str) {
strength += str;
if (strength > maxStrength) {
strength = maxStrength;
}
}
int Lirael::getStrength() {
return strength;
}
void Lirael::setLocation(Space* location) {
this->location = location;
}
Space* Lirael::getLocation() {
return location;
}
bool Lirael::getBells() {
return hasBells;
}
bool Lirael::getMirror() {
return hasMirror;
}
bool Lirael::getDog() {
return hasDog;
}