-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVampire.cpp
66 lines (47 loc) · 1.31 KB
/
Vampire.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
#include <string>
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "Vampire.hpp"
using namespace std;
Vampire::Vampire() : Creature::Creature() {
attackRolls = 1;
attackDieSides = 12;
defenseRolls = 1;
defenseDieSides = 6;
armor = 1;
str = 18;
name = "Vampire";
}
int Vampire::attack() {
int attackTotal = 0;
for (int i = 0; i < attackRolls; i++) {
attackTotal+=roll(attackDieSides);
}
cout << name << " attacks for " << attackTotal << endl;
return attackTotal;
/*
int dmg = roll(attackRolls, attackDieSides);
cout << "Vampire attacks for " << dmg << " damage!" << endl;
return dmg;*/
}
int Vampire::defend(int damage) {
int charm = rand() % 2;
int defenseValue = 0;
if (charm == 0) {
cout << "But is charmed by " << name << " during the attack and deals no damage!" << endl;
return 0;
}
else {
for (int i = 0; i < defenseRolls; i++) {
defenseValue = defenseValue + roll(defenseDieSides);
}
cout << name << " defends for " << defenseValue << endl;
if (defenseValue >= damage) {
return 0;
}
else {
return damage - defenseValue;
}
}
}