-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlueMen.cpp
More file actions
100 lines (82 loc) · 2.07 KB
/
Copy pathBlueMen.cpp
File metadata and controls
100 lines (82 loc) · 2.07 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
/*********************************************************************
** Program name: Project4
** Author: James Scanlon
** Date: March 3, 2019
** Description: Implementation for the BlueMen class. Inherits from character and has the amount of defendDice changee with its strength.
*********************************************************************/
#include "BlueMen.hpp"
#include <cstdlib>
#include "Character.hpp"
#include <iostream>
using namespace std;
BlueMen::BlueMen() : Character::Character(){
attackValue = 10;
defenseValue = 6;
armor = 3;
strength = 12;
attackDice = 2;
defendDice = 3; // Changes with number of Blue Men
type = "Blue Men";
specialMessage = false;
}
int BlueMen::attack(){
int damage = 0;
for (int i = 0; i < attackDice; i++)
{
damage += ((rand() % attackValue) + 1);
}
currentAttack = damage;
return damage;
}
void BlueMen::defense(int damage){
int roll = 0;
for (int i = 0; i < defendDice; i++)
{
roll += ((rand() % defenseValue) + 1);
}
if (damage > (roll + armor))
{
strength -= (damage - roll - armor);
if (strength <= 0)
{
strength = 0;
}
else if (strength <= 4)
{
defendDice = 1; // only one blue man left
specialMessage = true;
}
else if (strength <= 8)
{
defendDice = 2; // two blue men left
specialMessage = true;
}
}
currentDefend = roll;
}
void BlueMen::recovery()
{
strength += .5 * (baseStrength - strength);
if (strength <= 4)
{
defendDice = 1;
}
else if (strength <= 8)
{
defendDice = 2;
}
else
{
defendDice = 3;
}
}
// special message
void BlueMen::specialNotice(){
if (specialMessage){
cout << "The mob of blue men has gotten smaller! They now roll with less die for defense." << endl;
specialMessage = false;
}
}
BlueMen::~BlueMen()
{
}