-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevelBoss.cpp
169 lines (137 loc) · 5.2 KB
/
LevelBoss.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
//
// Created by td on 3/19/18.
//
#include "LevelBoss.h"
LevelBoss::LevelBoss() : Level('B') {
enemAmount = 1;
std::string names[] = {"GIANT WORM WTF WOW", "CUBONES MOM WITH BONES", "RAT WITH 7 HEADS", "CUBONES MOM's MOM", "Shaggy(from scooby doo ok)", "Shaggy(The rapper) AHHHH"};
int rng = rand() % 6;
enemies.push_back(new Enemy(rand() % 250+80,rand() % 45 + 20,names[rng]));
}
void LevelBoss::startEvent(Player *player) {
std::cout << "Encountered BOSS BATTLE. ITS " << enemies[0]->getName() << " OMG" << std::endl;
while (player->getHealth() > 0 && enemAmount > 0 && !this->isCompleted()) {
std::cout << "Player Health : " << player->getHealth() << std::endl;
for (auto &en : enemies) {
std::cout << en->getName() << " Health: " << en->getHealth() << ", ";
}
std::cout << std::endl;
playerOptions(player);
if (this->isCompleted()) break;
enemyAttack(player);
}
this->setCompleted();
}
void LevelBoss::enemyAttack(Player *player) {
for (auto &ene : enemies) {
int rng = rand() % 9;
if (rng < 7) {
ene->attack(player);
} else {
std::cout << ene->getName() << " Missed!" << std::endl;
}
}
}
void LevelBoss::playerOptions(Player *player) {
std::string topOptions[] = {"Attack", "Item", "Run"};
std::string attackOptions[] = {"Bash", "Strike", "Heavy"};
std::string option;
bool found = false;
while (!found) {
std::cout << "Actions: Attack, Item, Run" << std::endl;
std::getline(std::cin, option);
for (auto &str : topOptions) {
if (option == str) {
found = true;
break;
}
}//could use std find but being annoying
if (!found) {
std::cout << "Enter valid option" << std::endl;
}
}
if (option == "Attack") {
found = false;
while (!found) {
std::cout << "Attack Actions: Bash, Strike, Heavy" << std::endl;
std::getline(std::cin, option);
for (auto &str : attackOptions) {
if (option == str) {
found = true;
break;
}
}
if (!found) {
std::cout << "Enter valid option" << std::endl;
}
}
//if (enemAmount == 1) {
//use that attack on them
// }
//else {
//pick target
std::cout << "Which enemy to attack? ";
for (int i = 1; i <= enemAmount; i++) {
std::cout << i << " ";
}
std::cout << std::endl;
std::string attackChoice;
found = false;
while (!found) {
std::getline(std::cin, attackChoice);
for (int i = 1; i <= enemAmount; i++) {
if (attackChoice == std::to_string(i)) {
found = true;
break;
}
}
if (!found) {
std::cout << "Enter valid option" << std::endl;
}
}
int attackindex = std::stoi(attackChoice);
if (option == "Bash") {
player->attack(enemies[attackindex - 1]);
} else if (option == "Heavy") {
player->heavyAttack(enemies[attackindex - 1]);
} else if (option == "Strike") {
player->strikeAttackMultiple(enemies);
}
} else if (option == "Item") {
found = false;
int itemCount = player->getItems().size();
if (itemCount > 0) {
std::cout << "Which item?:" << std::endl;
int i = 1;
for (auto &item : player->getItems()) {
std::cout << i << ": " << item->getName() << std::endl;
i++;
}
std::getline(std::cin, option);
for (int i = 1; i <= itemCount; i++) {
if (option == std::to_string(i)) {
found = true;
break;
}
}
if (!found) {
std::cout << "Enter valid option" << std::endl;
}
int potionindex = std::stoi(option);
player->getItems()[potionindex - 1]->useItem(player);
player->itemList.erase(player->itemList.begin() + potionindex - 1);
} else {
std::cout << "No items!" << std::endl;
}
} else if (option == "Run") {
std::cout << "Can't Escape!" << std::endl;
}
for (auto &enem : enemies) {
if (enem->getHealth() <= 0) {
std::cout << enem->getName() << " fainted!!!!AAHHHH." << std::endl;
this->setCompleted();
player->setBeat();
enemAmount -= 1;
}
}
}