-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMedusa.cpp
More file actions
80 lines (64 loc) · 1.69 KB
/
Copy pathMedusa.cpp
File metadata and controls
80 lines (64 loc) · 1.69 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
/*********************************************************************
** Program name: Project4
** Author: James Scanlon
** Date: March 3, 2019
** Description: Implementation for the Medusa class. Inherits from character and deals 99 damage whenever a 12 is rolled, but the 99 damage does not beat Harry or Vampire abilities. *********************************************************************/
#include "Medusa.hpp"
#include <cstdlib>
#include "Character.hpp"
#include <iostream>
using namespace std;
Medusa::Medusa() : Character::Character(){
attackValue = 6;
defenseValue = 6;
armor = 3;
strength = 8;
attackDice = 2;
defendDice = 1;
type = "Medusa";
specialMessage = false;
}
int Medusa::attack(){
int damage = 0;
for (int i = 0; i < attackDice; i++)
{
damage += ((rand() % attackValue) + 1);
}
if (damage == 12) // glare ability
{
damage = 99;
specialMessage = true;
}
currentAttack = damage;
return damage;
}
void Medusa::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;
}
}
currentDefend = roll;
}
void Medusa::recovery()
{
strength += .5 * (baseStrength - strength);
}
// glare special message
void Medusa::specialNotice(){
if (specialMessage){
cout << "Medusa used glare to turn the opponent to stone!" << endl;
specialMessage = false;
}
}
Medusa::~Medusa()
{
}