-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer_Ninja.cpp
More file actions
73 lines (63 loc) · 1.46 KB
/
Player_Ninja.cpp
File metadata and controls
73 lines (63 loc) · 1.46 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
// Ninja class implementation
// By Nick Verrochi
// Last Modified: 5/6/15
#include "Player_Ninja.h"
using namespace std;
Ninja::Ninja(const string &playerName) : Player(playerName) {
attack = 25;
defense = 15;
hpMax = 100;
hp = hpMax;
mpMax = 25;
mp = mpMax;
magicPower = 20;
speed = 25;
setID(NINJA);
setPlayerClass("Ninja");
}
void Ninja::levelUp() {
if (level != LEVEL_CAP) {
srand(static_cast<unsigned int>(time(0)));
++level;
attack += 15 + (rand() % 5);
defense += 10 + (rand() % 5);
hpMax += 25 + (rand() % 5);
mpMax += 10 + (rand() % 5);
magicPower += 10 + (rand() % 10);
speed += 15 + (rand() % 5);
exp = exp - expToNext;
expToNext = static_cast<int>(expToNext * 1.5);
cout << name << " has leveled up! \n";
if (exp >= expToNext) levelUp(); // recursion!
}
}
void Ninja::printMenu() {
cout << "\t 1. Attack \n"
<< "\t 2. Double Attack (10 mp) \n"
<< "\t 3. Escape \n";
}
void Ninja::action(const int &choice, Entity *target) {
switch (choice) {
case 1:
launchAttack(target, NONE);
cout << name << " attacks! \n";
break;
case 2:
if (mp >= 10) {
launchAttack(target, NONE);
launchAttack(target, NONE);
mp -= 10;
cout << name << " attacks twice! \n";
}
else {
cout << "Not enough mp! \n";
}
break;
case 3:
setEscaping(true);
cout << name << " escapes! \n";
break;
default:
throw Player::ChoiceOutOfRangeException;
}
}