-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlueMen.cpp
101 lines (96 loc) · 2.7 KB
/
BlueMen.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
/**********************************************************
** Program name: BlueMen.cpp
** Author: Ben Fridkis
** Date: 5/5/2017
** Description: BlueMen class member function definitions.
Member functions include constructor,
attack, and defense.
***********************************************************/
#include "BlueMen.hpp"
/****************************************
Constructor
Instantiates BlueMen object with 3
armor points and 12 strength points per
assignment specifications.
***************************************/
BlueMen::BlueMen(string sName) : Creature()
{
setArmor(3);
setStartingStrPoints(12);
setStrengthPoints(12);
setName("Blue Men");
setSName(sName);
}
/*******************************************
Constructor (overloaded)
Instantiates a "dead" BlueMen object with
0 strength points. This constructor is
used to transfer a Vampire that is moved
out of the Creature lineup queue and into
the loser stack.
*******************************************/
BlueMen::BlueMen(string sName, int strPoints)
: Creature()
{
setArmor(3);
setStartingStrPoints(12);
setStrengthPoints(strPoints);
setName("Blue Men");
setSName(sName);
}
/******************************************
attack
BlueMen attack is determined by outputting
the result of a random number in the range
of 1 to 20 (i.e. rolling 2 ten-sided
die). Two random numbers between 1 and 10
are added for the return value as such.
******************************************/
int BlueMen::attack()
{
int dieRoll1, dieRoll2;
dieRoll1 = rand() % 10 + 1;
dieRoll2 = rand() % 10 + 1;
return dieRoll1 + dieRoll2;
}
/********************************************
defense
BlueMen defense is determined by outputting
the result of a random number in the range
of 1 to 18 (i.e. rolling 3 six-sided
die) if strength points are greater than 8.
If strength points are between 5 and 8,
the defense result is a random number
between 1 and 12 (i.e. rolling 2 six-sided
die). If strength points are equal to or
less than 4, defense is given by a random
number between 1 and 6 (i.e. rolling 1 six-
sided die). Random numbers are provided
according these criteria for the return
value.
********************************************/
int BlueMen::defense()
{
if (getStrengthPoints() > 8)
{
int dieRoll1, dieRoll2, dieRoll3;
dieRoll1 = rand() % 6 + 1;
dieRoll2 = rand() % 6 + 1;
dieRoll3 = rand() % 6 + 1;
return dieRoll1 + dieRoll2 + dieRoll3;
}
else if (getStrengthPoints() > 4
&& getStrengthPoints() <= 8)
{
int dieRoll1, dieRoll2;
dieRoll1 = rand() % 6 + 1;
dieRoll2 = rand() % 6 + 1;
return dieRoll1 + dieRoll2;
}
else
{
int dieRoll1;
dieRoll1 = rand() % 6 + 1;
return dieRoll1;
}
}