-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTrain.cpp
More file actions
66 lines (60 loc) · 1.58 KB
/
Train.cpp
File metadata and controls
66 lines (60 loc) · 1.58 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
#include "Train.h"
#include "BasicLib.h"
using namespace BasicLib;
namespace SimpleMUD
{
void Train::Handle(string p_data)
{
p_data = LowerCase(ParseWord(p_data, 0));
Player& p = *m_player;
if (p_data == "quit")
{
PlayerDatabase::SavePlayer(p.ID());
p.Conn()->RemoveHandler();
return;
}
char n = p_data[0];
if (n >= '1' && n <= '3')
{
if (p.StatPoints() > 0)
{
p.StatPoints()--;
p.AddToBaseAttr(n - '1', 1);
}
}
PrintStats(true);
}
void Train::Enter()
{
Player& p = *m_player;
p.Active() = false;
if (p.Newbie())
{
p.SendString(magenta + bold +
"Welcome to SimpleMUD, " + p.Name() + "!\r\n" +
"You must train your character with your desired stats,\r\n" +
"before you enter the realm.\r\n\r\n");
p.Newbie() = false;
}
PrintStats(false);
}
void Train::PrintStats(bool p_clear)
{
Player& p = *m_player;
if (p_clear)
{
p.SendString(clearscreen);
}
p.SendString(white + bold +
"--------------------------------- Your Stats ----------------------------------\r\n" +
"Player: " + p.Name() + "\r\n" +
"Level: " + tostring(p.Level()) + "\r\n" +
"Stat Points Left: " + tostring(p.StatPoints()) + "\r\n" +
"1) Strength: " + tostring(p.GetAttr(STRENGTH)) + "\r\n" +
"2) Health: " + tostring(p.GetAttr(HEALTH)) + "\r\n" +
"3) Agility: " + tostring(p.GetAttr(AGILITY)) + "\r\n" +
bold +
"-------------------------------------------------------------------------------\r\n" +
"Enter 1, 2, or 3 to add a stat point, or \"quit\" to enter the realm: ");
}
}