-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevelChest.cpp
104 lines (75 loc) · 2.69 KB
/
LevelChest.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
//
// Created by td on 3/18/18.
//
#include "LevelChest.h"
LevelChest::LevelChest() : Level('C'){
}
void LevelChest::startEvent(Player *player) {
std::cout << "You have come across a chest in the dungeon and open it" << std::endl;
srand(time(NULL));
int rng = rand() % 9 + 1;
int dmgrng;
int healthrng;
int posrng;
int goldrng;
switch (rng) {
case 1:
healthrng = rand() % 20 + 1;
posrng = rand() % 2;
if (posrng == 0) {
healthrng = -healthrng;
}
std::cout << "The chest contains a relic.....Players health is affected " << healthrng <<std::endl;
player->addHealth(healthrng);
break;
case 2:
goldrng = rand() % 20 + 1;
posrng = rand() % 2;
if (posrng == 0) {
goldrng = -goldrng;
}
std::cout << "The chest contains a relic.....Players gold is affected " << goldrng <<std::endl;
player->addGold(goldrng);
break;
case 3:
dmgrng = rand() % 5 + 1;
posrng = rand() % 2;
if (posrng == 0) {
dmgrng= -dmgrng;
}
std::cout << "The chest contains a relic.....Players damage is affected " << dmgrng<< std::endl;
player->addDamage(dmgrng);
break;
case 4:
healthrng = rand() % 13 + 1;
std::cout << "The chest contains a trophy.....health stat boost! " << healthrng <<std::endl;
player->addHealth(healthrng);
break;
case 5:
goldrng = rand() % 25 + 1;
std::cout << "The chest contains a trophy.....gold stat boost! " << goldrng <<std::endl;
player->addGold(goldrng);
break;
case 6:
dmgrng = rand() % 7 + 1;
std::cout << "The chest contains a trophy.....damage stat boost! " << dmgrng<< std::endl;
player->addDamage(dmgrng);
break;
case 7:
healthrng = rand() % 14 + 1;
std::cout << "The chest contains a curse.....health stat loss... " << -healthrng <<std::endl;
player->addHealth(-healthrng);
break;
case 8:
goldrng = rand() % 14 + 1;
std::cout << "The chest contains a curse.....gold stat loss... " << -goldrng <<std::endl;
player->addGold(-goldrng);
break;
case 9:
dmgrng = rand() % 5 + 1;
std::cout << "The chest contains a curse.....damage stat loss... " << -dmgrng<< std::endl;
player->addDamage(-dmgrng);
break;
}
this->setCompleted();
}