-
Notifications
You must be signed in to change notification settings - Fork 0
/
Knight.cpp
119 lines (80 loc) · 2.88 KB
/
Knight.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**************************************************
Project: The Tamer, the Arigamo and the Fuhai Gem
Task: Assignment 2 + 3
Author: Sean Lee
Purpose: Dark Knight Class Definition File
The Definition file for the Dark Knight class Hazard.
**************************************************/
#include "Knight.h"
//-------------------------------------//
// constructors and destructors //
//-------------------------------------//
Knight::Knight() {
damageAmount = 0;
}
Knight::Knight(string name, HazardType type, string hint, vector<string> description, bool roaming, bool conscious, int damage) : Hazard(name, type, hint, description, roaming, conscious) {
damageAmount = damage;
}
Knight::~Knight() {
}
//-------------------------------------//
// accessor methods //
//-------------------------------------//
int Knight::getDamageAmount() {
return damageAmount;
}
string Knight::getDetails() {
// returns details of the knight as formatted string
stringstream hazardDetails;
hazardDetails << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
hazardDetails << " Hazard ID: " << getID() << "\n";
hazardDetails << " Hazard Name: " << getName() << "\n";
hazardDetails << " Hazard Type: " << getTypeAsString() << "\n";
hazardDetails << " Current Room: " << getCurrentRoom() << "\n";
hazardDetails << " Hint: " << getHint() << "\n";
hazardDetails << " Event Descriptions: " << getDescriptionsAsString() << "\n";
hazardDetails << " Is Roaming Type: " << isRoaming() << "\n";
hazardDetails << " Is Conscious: " << conscious() << "\n";
hazardDetails << " Is Dead: " << hasDied() << "\n";
hazardDetails << " Has Interacted: " << interacted() << "\n";
hazardDetails << " Damage: " << getDamageAmount() << "\n";
hazardDetails << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
return hazardDetails.str();
}
//-------------------------------------//
// mutator methods //
//-------------------------------------//
void Knight::setDamageAmount(int damage) {
if (damage > 0) {
damageAmount = damage;
}
else {
displayString(" You have not entered a valid amount of damage to set.\n");
}
}
//-------------------------------------//
// hazard turn update methods //
//-------------------------------------//
vector<string> Knight::updateInteraction(Player& player) {
// the Dark Knight's interaction with the player
vector<string> results;
setHasInteracted(true);
if (!hasDied()) {
if (conscious()) {
player.updateHealth(-damageAmount);
setIsConscious(false);
results.push_back(eventDescriptions[0]);
results.push_back(eventDescriptions[1]);
if (player.getHealthCurrent() == 0) {
results.push_back("$");
}
}
else {
results.push_back(eventDescriptions[4]);
}
}
else {
results.push_back(eventDescriptions[3]);
}
return results;
}