-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cpp
116 lines (94 loc) · 1.82 KB
/
Player.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
#include "stdafx.h"
#include "Player.h"
Player::Player()
{
}
Player::Player(int s, int w, int a)
{
if (s == 0) {
shield = "Red";
}
if (s == 1) {
shield = "Blue";
}
if (s == 2) {
shield = "Yellow";
}
if (s == 3) {
shield = "Green";
}
if (w == 0) {
weapon = "Red";
damage = 80;
}
if (w == 1) {
weapon = "Blue";
damage = 90;
}
if (w == 2) {
weapon = "Yellow";
damage = 100;
}
if (w == 3) {
weapon = "Green";
damage = 60;
}
if (a == 0) {
armor = "Red";
health = 1000;
}
if (a == 1) {
armor = "Blue";
health = 800;
}
if (a == 2) {
armor = "Yellow";
health = 1000;
}
if (a == 3) {
armor = "Green";
health = 600;
}
isPois = false;
isBleed = false;
isStun = false;
damMult = 1.0;
//Placeholder
if (s == 4) {
weapon = "NULL";
shield = "NULL";
armor = "NULL";
}
}
void Player::output()
{
cout << "Shield: " << shield << endl;
cout << "Weapon: " << weapon << endl;
cout << "Armor : " << armor << endl;
}
Player::~Player()
{
}
void Player::attack(Player& rhs)
{
//initial damage calc
int doDam = damage*damMult;
if (shieldColor() == "Red" && turn % 2 == 0) doDam = 0;
if (weaponColor() == "Red" && rand() % 100 < 20) doDam *= 2;
if (weaponColor() == "Yellow" && rand() % 100 < 15) doDam = 0;
//is it dodged
if (rhs.armorColor() == "Blue" && rand()%100 < 15)
{
return;
}
//shield properties
if (rhs.shieldColor() == "Red" && turn % 2 == 0 && weaponColor() != "Yellow") doDam = 0;
if (rhs.shieldColor() == "Blue" && weaponColor() != "Yellow") doDam = doDam*0.8;
if (rhs.shieldColor() == "Green" && weaponColor() != "Yellow") poison();
//status effects
if (weaponColor() == "Blue" && rand() % 100 < 10 && doDam > 0) rhs.stun();
if (weaponColor() == "Green") rhs.bleed();
//deal damage
rhs.hurt(doDam);
if (rhs.armorColor() == "Green") hurt(doDam / 2);
}