-
Notifications
You must be signed in to change notification settings - Fork 0
/
Barbarian.cpp
72 lines (68 loc) · 2 KB
/
Barbarian.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
/**********************************************************
** Program name: Barbarian.cpp
** Author: Ben Fridkis
** Date: 5/3/2017
** Description: Barbarian class member function definitions.
Member functions include constructor,
attack, and defense.
***********************************************************/
#include "Barbarian.hpp"
/**********************************************
Constructor
Instantiates Barbarian object with 0 armor
points and 12 strength points per assignment
specifications.
**********************************************/
Barbarian::Barbarian(string sName) : Creature()
{
setArmor(0);
setStartingStrPoints(12);
setStrengthPoints(12);
setName("Barbarian");
setSName(sName);
}
/*******************************************
Constructor (overloaded)
Instantiates a "dead" Barbarian 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.
*******************************************/
Barbarian::Barbarian(string sName, int strPoints)
: Creature()
{
setArmor(0);
setStartingStrPoints(12);
setStrengthPoints(strPoints);
setName("Barbarian");
setSName(sName);
}
/******************************************
attack
Barbarian attack is determined by summing
the roll of 2 six-sided "die". Two random
numbers are generated and added together
to provide the return value as such.
******************************************/
int Barbarian::attack()
{
int dieRoll1, dieRoll2;
dieRoll1 = rand() % 6 + 1;
dieRoll2 = rand() % 6 + 1;
return dieRoll1 + dieRoll2;
}
/******************************************
defense
Barbarian defense is determined by summing
the roll of 2 six-sided "die". Two random
numbers are generated and added together
to provide the return value as such.
******************************************/
int Barbarian::defense()
{
int dieRoll1, dieRoll2;
dieRoll1 = rand() % 6 + 1;
dieRoll2 = rand() % 6 + 1;
return dieRoll1 + dieRoll2;
}