-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacterCreation.cpp
79 lines (72 loc) · 1.86 KB
/
CharacterCreation.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
#include "CharacterCreation.h"
/*
Rolls values for each stat.
*/
void CharacterCreation::RollAll() {
numberOfStats = 5;
srand(time(NULL));
for(int i = 0; i < numberOfStats; i++) {
stats[i] = rand() % 100 + 1;
//cout << "Rolled: " << stats[i] << ".\n";
}
}
/*
Sets a value to a stat, given the index and the value.
Returns the set value. Used to manually set a specific value.
*/
int CharacterCreation::SetStat(int statIndex, int value) {
if(value > -1 && value < 101) {
stats[statIndex] = value;
}
return stats[statIndex];
}
/*
Increments a stat by value.
*/
int CharacterCreation::IncrementStat(int statIndex, int value) {
if(value < 0) {
cout << "Error: Negative Value. Please use DecrementStat().\n";
} else if(stats[statIndex] + value > 100) {
stats[statIndex] = 100;
} else {
stats[statIndex] += value;
}
return stats[statIndex];
}
/*
Decrements a stat by value.
*/
int CharacterCreation::DecrementStat(int statIndex, int value) {
if(value < 0) {
cout << "Error: Negative Value. Please use IncrementStat().\n";
} else if(stats[statIndex] - value < 0) {
stats[statIndex] = 0;
} else {
stats[statIndex] -= value;
}
return stats[statIndex];
}
/*
Returns the value of a single stat.
*/
int CharacterCreation::GetStat(int statIndex) {
return stats[statIndex];
}
/*
Prints all stat values.
*/
void CharacterCreation::ShowAllStats() {
numberOfStats = 5;
for(int i = 0; i < numberOfStats; i++) {
cout << "Stat " << i << ": " << stats[i] << ".\n";
}
cout << "Name: " << characterName << "\n";
}
/*
Lets player set the name of their character.
Note: MakeChoices or HandleInput will handle the input of the name.
*/
void CharacterCreation::SetName(string name) {
//cout << name << "\n";
characterName = name;
}