-
Notifications
You must be signed in to change notification settings - Fork 0
/
pcdata.cpp
170 lines (157 loc) · 4.65 KB
/
pcdata.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.diku' as well the Merc *
* license in 'license.merc'. In particular, you may not remove either *
* of these copyright notices. *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
/*
MurkMUD++ - A Windows compatible, C++ compatible Merc 2.2 Mud.
\author Jon A. Lambert
\date 08/30/2006
\version 1.4
\remarks
This source code copyright (C) 2005, 2006 by Jon A. Lambert
All rights reserved.
Use governed by the MurkMUD++ public license found in license.murk++
*/
#include "os.hpp"
#include "config.hpp"
#include "utils.hpp"
#include "io.hpp"
#include "pcdata.hpp"
PCData::PCData() :
perm_str(13), perm_int(13), perm_wis(13), perm_dex(13), perm_con(13),
mod_str(0), mod_int(0), mod_wis(0), mod_dex(0), mod_con(0), pagelen(20) {
memset(condition, 0, sizeof condition);
memset(learned, 0, sizeof learned);
}
void PCData::set_prime(sh_int prime)
{
switch (prime) {
case APPLY_STR:
perm_str = 16;
break;
case APPLY_INT:
perm_int = 16;
break;
case APPLY_WIS:
perm_wis = 16;
break;
case APPLY_DEX:
perm_dex = 16;
break;
case APPLY_CON:
perm_con = 16;
break;
}
}
std::string PCData::trainable_list(void)
{
std::string str;
if (perm_str < 18)
str.append(" str");
if (perm_int < 18)
str.append(" int");
if (perm_wis < 18)
str.append(" wis");
if (perm_dex < 18)
str.append(" dex");
if (perm_con < 18)
str.append(" con");
return str;
}
void PCData::set_perm(std::string attr, int value)
{
if (!str_cmp (attr, "str")) {
perm_str = value;
} else if (!str_cmp (attr, "int")) {
perm_int = value;
} else if (!str_cmp (attr, "wis")) {
perm_wis = value;
} else if (!str_cmp (attr, "dex")) {
perm_dex = value;
} else if (!str_cmp (attr, "con")) {
perm_con = value;
} else {
bug_printf("Invalid argument to PCData::set_perm: %s", attr.c_str());
}
return;
}
sh_int PCData::get_perm(std::string attr)
{
if (!str_cmp (attr, "str")) {
return perm_str;
} else if (!str_cmp (attr, "int")) {
return perm_int;
} else if (!str_cmp (attr, "wis")) {
return perm_wis;
} else if (!str_cmp (attr, "dex")) {
return perm_dex;
} else if (!str_cmp (attr, "con")) {
return perm_con;
} else {
bug_printf("Invalid argument to PCData::get_perm: %s", attr.c_str());
return 0;
}
}
void PCData::set_mod(std::string attr, int value)
{
if (!str_cmp (attr, "str")) {
mod_str = value;
} else if (!str_cmp (attr, "int")) {
mod_int = value;
} else if (!str_cmp (attr, "wis")) {
mod_wis = value;
} else if (!str_cmp (attr, "dex")) {
mod_dex = value;
} else if (!str_cmp (attr, "con")) {
mod_con = value;
} else {
bug_printf("Invalid argument to PCData::set_mod: %s", attr.c_str());
}
return;
}
sh_int PCData::get_mod(std::string attr)
{
if (!str_cmp (attr, "str")) {
return mod_str;
} else if (!str_cmp (attr, "int")) {
return mod_int;
} else if (!str_cmp (attr, "wis")) {
return mod_wis;
} else if (!str_cmp (attr, "dex")) {
return mod_dex;
} else if (!str_cmp (attr, "con")) {
return mod_con;
} else {
bug_printf("Invalid argument to PCData::get_mod: %s", attr.c_str());
return 0;
}
}
sh_int PCData::get_curr(std::string attr)
{
if (!str_cmp (attr, "str")) {
return perm_str + mod_str;
} else if (!str_cmp (attr, "int")) {
return perm_int + mod_int;
} else if (!str_cmp (attr, "wis")) {
return perm_wis + mod_wis;
} else if (!str_cmp (attr, "dex")) {
return perm_dex + mod_dex;
} else if (!str_cmp (attr, "con")) {
return perm_con + mod_con;
} else {
bug_printf("Invalid argument to PCData::get_perm: %s", attr.c_str());
return 0;
}
}