-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAquamentus.cpp
85 lines (65 loc) · 1.98 KB
/
Aquamentus.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
/**********************************************************************
Author: Shane
Purpose: Implementation of the Aquamentus class
Date: Monday March 12th 2018
***********************************************************************/
#include "Aquamentus.h"
#include <iostream>
using std::cout;
using std::endl;
/**********************************************************************
CONSTRUCTORS AND DESTRUCTOR
***********************************************************************/
Aquamentus::Aquamentus(Space* s) : Character(aquamentus) {
numOfAttackDice = 3;
numOfDefenseDice = 3;
attackDiceSides = 5;
defendDiceSides = 5;
armor = 3;
health = 20;
representation = 'A';
currentSpace = s;
Character::initializeDice();
}
Aquamentus::~Aquamentus() {
//does nothing for now
}
/**********************************************************************
COMBAT FUNCTIONS
***********************************************************************/
int Aquamentus::attack() {
int roll = 0;
bool fireBall = false;
for(int i = 0; i < numOfAttackDice; i++) //for each attack dice
{
roll += attackDice[i]->roll(); //roll the dice and add it to the total
}
fireBall = static_cast<bool>(rand() % 2);
if(fireBall)
{
cout << "Aquamentus attacked with fireball";
roll+=3; //add 3 to the roll
} else {
cout << "Aquamentus attacked";
}
return roll;
}
void Aquamentus::defense(int a) {
int roll = 0;
int damage = 0;
for(int i = 0; i < numOfDefenseDice; i++) //for each attack dice
{
roll += defenseDice[i]->roll(); //roll the dice and add it to the total
}
damage = a - roll - armor; //calculate the damage
if(damage <= 0)
{
damage = 0;
}
cout << " and Aquamentus defended but took " << damage << " points of damage." << endl;
health -= damage; //decrement health accordingly
if(health <= 0)
{
cout << "Aquamentus died." << endl;
}
}