/
character.cpp
282 lines (207 loc) · 4.32 KB
/
character.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/*
This is OpenSource Project;
It's licensed on GPL/ LGPL public license;
It's written by Daniel (dmilith) Dettlaff since August 2oo8.
You can redistribute this project only with this header.
*/
#include "character.h"
Ccharacter::Ccharacter( std::string new_name ) {
name = new_name; // creature name
race = human; //(0)
for ( int i = 0; i < 50; ++i ) {
items[ i ] = NULL;
}
for ( int i = 0; i < 250; ++i ) {
private_box[ i ] = NULL;
}
health = ( rand() % 125 ) - 75;
dead = false;
intelligence = ( ( rand() % 50 ) - ( race * 20 ) ) + 100 ;
age = 10;
strength = ( race * 2 ) + ( rand() % 10 ) + 3;
dexterity = 0;
luck = ( rand() % 21 ) - 10;
mind_strength = 0; // creature properties
} // creature properties
Ccharacter::Ccharacter( Eraces born_race, std::string new_name ) {
name = new_name;
race = born_race; //(0)
for ( int i = 0; i < 50; ++i ) {
items[ i ] = NULL;
}
for ( int i = 0; i < 250; ++i ) {
private_box[ i ] = NULL;
}
health = ( rand() % 125 ) - 75 ;
dead = false;
intelligence = ( ( rand() % 50 ) - ( race * 20 ) ) + 100 ;
age = 10 + ( rand() % 75 ); // it's poor to be old ;}
strength = ( race * 2 ) + ( rand() % 10 ) + 3;
dexterity = 0;
luck = ( rand() % 21 ) - 10;
switch( race ) {
case annimal:
mind_strength = ( rand() % 10 ) + ( rand() % 3 ); //cechy postaci
break;
case human:
mind_strength = ( rand() % 35 ) + ( rand() % 3 ); //cechy postaci
break;
case elve:
mind_strength = ( rand() % 55) + ( rand() % 7 ); //cechy postaci
break;
case dwarf:
mind_strength = ( rand() % 45 ) + ( rand() % 3 ); //cechy postaci
break;
case cave_troll:
mind_strength = 120 + ( rand() % 75 ); //cechy postaci
break;
case grizzly:
mind_strength = 60 + ( rand() % 15 ); //cechy postaci
break;
default:
mind_strength = 100; //cechy postaci
break;
}
}
Ccharacter::~Ccharacter() {
}
void
Ccharacter::kill() {
#ifdef DEBUG
std::cout << "Killed.";
std::cout.flush();
#endif
this->name = this->name + "(dead)";
this->dead = true;
// let character to stay in this world as living dead ;}
}
int32_t
Ccharacter::get_health() {
return health;
}
std::string
Ccharacter::get_name() {
return name;
}
uint32_t
Ccharacter::get_intelligence() {
return intelligence;
}
uint32_t
Ccharacter::get_strength() {
return strength;
}
uint32_t
Ccharacter::get_dexterity() {
return dexterity;
}
int32_t
Ccharacter::get_mind_strength() {
return mind_strength;
}
int64_t
Ccharacter::get_gold() {
return gold;
}
uint32_t
Ccharacter::get_age() {
return age;
}
int16_t
Ccharacter::get_luck() {
return luck;
}
Ccoordinates
Ccharacter::get_position() {
return position;
}
void
Ccharacter::set_position( Ccoordinates position_ ) {
position = position_;
}
Csoul*
Ccharacter::get_soul() {
return soul;
}
void
Ccharacter::set_soul( Csoul* soul_ ) {
soul = soul_;
}
Eraces
Ccharacter::get_race() {
return race;
}
// TODO complete item getting/ putting
Citem
Ccharacter::get_item( uint8_t item_number_ ) {
}
void
Ccharacter::throw_item( Citem* item_ ) { // player is throwing away an item
}
void
Ccharacter::gain_item( Citem* item_ ) { // player is taking an item
}
void
Ccharacter::gain_health( int32_t damage_ ) { // get hurt or get heal
health += damage_;
}
void
Ccharacter::gain_gold( int64_t gold_amount_ ) { // could be negative
gold += gold_amount_;
}
void
Ccharacter::gain_dexterity( int64_t dexterity_ ) {
dexterity += dexterity_;
}
void
Ccharacter::gain_strength( int64_t strength_ ) {
strength += strength_;
}
void
Ccharacter::gain_intelligence( int64_t intelligence_ ) {
intelligence += intelligence_;
}
void
Ccharacter::gain_luck( int16_t luck_ ) {
luck += luck_;
}
bool
Ccharacter::is_dead() {
return dead;
}
int32_t
Ccharacter::get_combat_ability() {
return combat_ability;
}
int32_t
Ccharacter::get_armor() {
return armor;
}
void
Ccharacter::gain_armor( int32_t armor_ ) {
armor += armor_;
}
int32_t
Ccharacter::get_speed() {
return speed;
}
void
Ccharacter::gain_speed( int32_t speed_ ) {
speed += speed_;
}
void
Ccharacter::set_age( int16_t age_ ) {
age = age_;
}
int32_t
Ccharacter::get_max_load() {
return max_load;
}
void
Ccharacter::set_max_load( int32_t max_load_ ) {
max_load = max_load_;
}
void
Ccharacter::set_name( std::string name_ ) {
name = name_;
}