-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharacter.cpp
More file actions
103 lines (95 loc) · 2.9 KB
/
character.cpp
File metadata and controls
103 lines (95 loc) · 2.9 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/***************************************************************
* Name : Character
* Author : Evan Bunnell
* Created : 5/4/2023
***************************************************************/
#include "character.h"
#include <algorithm>
/**************************************************************
* Name: Character
* Description: Default no-arg constructor
* Input parameters: none
***************************************************************/
Character::Character() {
name = "No Name";
Class = "No Class";
role = "No Role";
}
/***************************************************************
* Class Functions
***************************************************************/
string Character::getName() {
return name;
}
void Character::setName(string input){
name = input;
}
string Character::getClass() {
return Class;
}
void Character::setClass(string input){
Class = input;
}
string Character::getRole() {
return role;
}
void Character::setRole(string input){
role = input;
}
/**************************************************************
* Name: build
* Description: Builds a full object for the Character class
* Input: string, string, string, string, double
* Output: n/a
***************************************************************/
void Character::build(string newName, string newClass, string newRole) {
name = newName;
Class = newClass;
role = newRole;
priority = setPrio();
}
/**************************************************************
* Name: print
* Description: Prints object information on display
* Input: n/a
* Output: Object attributes via cout
***************************************************************/
void Character::print() {
Class[0] = toupper(Class[0]);
role[0] = toupper(role[0]);
if (name.length() > 5) {
cout << "Name: " << name << "\tClass: " << Class << "\tRole: " << role;
if (priority >= 4) {
cout << " [Backup]" << endl;
}
else cout << endl;
//cout << "Priority: " << priority << endl; //FOR TESTING ONLY
}
else {
cout << "Name: " << name << "\t\tClass: " << Class << "\tRole: " << role;
if (priority >= 4) {
cout << " [Backup]" << endl;
}
else cout << endl;
//cout << "Priority: " << priority << endl; //FOR TESTING ONLY
}
}
/**************************************************************
* Name: setPrio
* Description: Sets attribute priority based on role attribute
* value
* Input: n/a
* Output: n/a
***************************************************************/
int Character::setPrio() {
if (getRole() == "tank") {
return 1;
}
if (getRole() == "healer") {
return 2;
}
if (getRole() == "dps") {
return 3;
}
return 0;
}