-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gorg.cpp
45 lines (41 loc) · 1.08 KB
/
Gorg.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
#include "Gorg.h"
Gorg::Gorg()
: Competitor("George", 30, 5),
maxShield(5)
{
//nothing here...
}
void Gorg::getsAttacked()
{
int roll = rand() % 100; //value from 0 - 99
if (roll < 15)
{
//0-14
if (++shield > maxShield)
{
--shield;
}
}
//int roll = rand() % 100;
if (roll < 65)
{
//0-64
shield -= (1 + (rand() % 2));
if (shield < 0)
{
health -= (5 + (rand() % 6));
}
}
}
/*
The first action is to check if the shield will regen slightly
15% of the time, add 1 to the shiled value, and also make sure this new shield is clamped to its max val
85% of the time, no regen will occur (we don't need to do anything for this)
the 2nd action is to check if health damage is going to be done
35% of the time, the attack misses and does 0 dmg
65% of the time, the following occurs:
shield takes 1-2 random damage
if the modified shield value is now less than zero, attack does random 5-10 health damage
Think of this as an actual physical shield that can be damaged with use
If the shield value is reduced to zero or negative value, that means it has been destroyed
*/