/
character.h
83 lines (68 loc) · 1.97 KB
/
character.h
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
#ifndef CHARACTER_H_INCLUDED
#define CHARACTER_H_INCLUDED
void clearScreen() //function to "refresh the screen"
{
std::cout << std::string( 500, '\n' );
}
class Character
{
friend void descend(Character player);
friend class foe;
friend class Game;
int FP,HP,FS, HPmax, FPmax;
public:
int location;
void enterDungeon();
Character(int strength, int health, int ability, int intelligence)
{
HP = health * 4;
FS = (strength + ability) * 2 + intelligence;
FP = (strength + health) * 2;
HPmax = HP;
FPmax = FP;
}
};
void descend(Character player);
void Character::enterDungeon()
{
clearScreen();
std::cout <<"Before you is a very dangerous dungeon ... Do you (q)uit or (d)escend ...";
char choice;
do
{
std::cin >> choice;
if (choice == 'q')
return;
else if (choice == 'd')
{
Character::location = -1;
descend(*this);
}
}while (!(choice == 'q' || choice == 'd'));
}
Character createCharacter() // function rolls random values until the player enters c and presses enter
{
srand(time(nullptr));
int health, strength, ability, intelligence;
char choice;
do
{
clearScreen();
health = (rand() % 5 )+ 8;
strength = (rand() % 5 )+ 8;
ability = (rand() % 5 )+ 8;
intelligence =(rand() % 5 )+ 8;
std::cout << "Health: " << health << std::endl
<< "Strength: " << strength <<std::endl
<< "Ability: " << ability << std::endl
<< "Intelligence: " << intelligence << std::endl
<< std::endl << std::endl
<< "Enter (c) to continue or enter another key to reroll: ";
std::cin >> choice;
if (choice == 'q')
break;
}while(choice != 'c');
Character player(strength, health, ability, intelligence);
return player;
}
#endif // CHARACTER_H_INCLUDED