-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbattlesystems.cpp
More file actions
128 lines (97 loc) · 2.72 KB
/
Copy pathbattlesystems.cpp
File metadata and controls
128 lines (97 loc) · 2.72 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
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
#include "battlesystems.h"
#include "enemy_class.h"
#include <string>
#include <iostream>
#include <cstdlib>
using namespace std;
srand((unsigned)time(NULL));
void enemies(string& enemy){//see if this is useful
int rng = 1 + (rand() % 5);
switch (rng) {
case 1:
enemy = "sneck1";//change this to use functions
break;
case 2:
enemy = "sneck2";
break;
case 3:
enemy = "sneck3";
break;
case 4:
enemy = "sneck4";
break;
case 5:
enemy = "sneck5";
break;
}
}
void battle(){// place this when needed in the game
string enemy;
int battle = 1 + (rand() % 5);
switch (battle) {
case 1:
cout << "placer holder paragraph 1 " << enemy << endl;
break;
case 2:
cout << "placer holder paragraph 2 " << enemy << endl;
break;
case 3:
cout << "placer holder paragraph 3 " << enemy << endl;
break;
case 4:
cout << "placer holder paragraph 4 " << enemy << endl;
break;
case 5:
cout << "placer holder paragraph 5 " << enemy << endl;
break;
}
}
static void battle_actions(int& enemy_health, int& enemy_defense, int& enemy_attack, int& player_health, int& player_defense,int& player_attack, int& player_agility, int& player_items, string& enemy){//take player health from hero_class
srand((unsigned)time(NULL));
int percent_chance = (rand() % (100)) + 1;
bool isBattleOver = false;
while (!isBattleOver) {
string action;
int enemy_action = 0;
cout << "What do you want to do?" << endl;
cout << "Attack | Use Item | Flee" << endl;
getline(cin, action);
if (action == "attack") {
//use a new variable to take away the damage
enemy_health -= 2;//add calculation to defense
if (enemy_health <= 0) {//change the enemy function in there
cout << "Enemy defeated!" << endl;
isBattleOver = true;
}
}
else if (action == "use item" || action == "item") {
if (player_items > 0) {
player_health += 5;//change this stat based on how it is
player_items--;
cout << "You used an item and restored health!" << endl;
}
else {
cout << "You have no items left!" << endl;
}
}
else if (action == "flee") {//percent chance based on agility
cout << "You fled the battle!" << endl;
isBattleOver = true;
}
else {
cout << "Not a valid answer. Check your spelling and pick again." << endl;
}
if (player_health <= 0) {
cout << "You have been defeated!" << endl;//make this cooler
isBattleOver = true;
}
//enemy attack
while(enemy_action == 0){
if (!(percent_chance > player_agility)) {
cout << "You dodged" << enemy_name << endl;
}
//calculate damage with defense and agility
enemy_action++;
}
}
}