· 7 years ago · Feb 17, 2019, 08:06 PM
1<?php
2$__load = array();
3/*
4 'loss_experience' => NULL,
5 'loss_items' => NULL,
6 'guild_info' => NULL,
7 'skull_type' => NULL,
8 'skull_time' => NULL,
9 'blessings' => NULL,
10 'direction' => NULL,
11 'stamina' => NULL,
12 'world_id' => NULL,
13 'online' => NULL,
14 'deletion' => NULL,
15 'promotion' => NULL,
16 'marriage' => NULL
17);*/
18
19/**#@+
20 * @version 0.0.1
21 */
22
23/**
24 * @package POT
25 * @version 0.1.5
26 * @author Wrzasq <wrzasq@gmail.com>
27 * @copyright 2007 - 2008 (C) by Wrzasq
28 * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3
29 */
30
31/**
32 * OTServ character abstraction.
33 *
34 * @package POT
35 * @version 0.1.5
36 * @property string $name Character name.
37 * @property OTS_Account $account Account to which character belongs.
38 * @property OTS_Group $group Group of which character is member.
39 * @property int $sex Gender.
40 * @property int $vocation Vocation.
41 * @property int $experience Experience points.
42 * @property int $level Experience level.
43 * @property int $magLevel Magic level.
44 * @property int $health Hit points.
45 * @property int $healthMax Maximum hit points.
46 * @property int $mana Mana.
47 * @property int $manaMax Maximum mana.
48 * @property int $manaSpent Spent mana.
49 * @property int $soul Soul points.
50 * @property int $direction Looking direction.
51 * @property int $lookBody Body color.
52 * @property int $lookFeet Feet color.
53 * @property int $lookHead Hairs color.
54 * @property int $lookLegs Legs color.
55 * @property int $lookType Outfit type.
56 * @property int $lookAddons Addons.
57 * @property int $posX Spawn X coord.
58 * @property int $posY Spawn Y coord.
59 * @property int $posZ Spawn Z coord.
60 * @property int $cap Capacity.
61 * @property int $lastLogin Last login timestamp.
62 * @property int $lastIP Last login IP number.
63 * @property string $conditions Binary conditions.
64 * @property int $redSkullTime Timestamp for which red skull will last.
65 * @property string $guildNick
66 * @property OTS_GuildRank $rank
67 * @property int $townId
68 * @property int $lossExperience
69 * @property int $lossMana
70 * @property int $lossSkills
71 * @property int $lossItems
72 * @property int $balance Bank balance.
73 * @property bool $save Player save flag.
74 * @property bool $redSkull Player red skull flag.
75 * @property bool $banned Player banned state.
76 * @property-read int $id Player ID.
77 * @property-read bool $loaded Loaded state.
78 * @property-read string $townName Name of town in which player residents.
79 * @property-read OTS_House $house House which player rents.
80 * @property-read OTS_Players_List $vipsList List of VIPs of player.
81 * @property-read string $vocationName String vocation representation.
82 * @property-read array $spellsList List of known spells.
83 * @tutorial POT/Players.pkg
84 */
85class OTS_Player extends OTS_Row_DAO
86{
87/**
88 * Player data.
89 *
90 * @version 0.1.2
91 * @var array
92 */
93 private $data = array('sex' => 0, 'vocation' => 0, 'experience' => 0, 'level' => 1, 'maglevel' => 0, 'health' => 100, 'healthmax' => 100, 'mana' => 100, 'manamax' => 100, 'manaspent' => 0, 'soul' => 0, 'lookbody' => 10, 'lookfeet' => 10, 'lookhead' => 10, 'looklegs' => 10, 'looktype' => 136, 'lookaddons' => 0, 'posx' => 0, 'posy' => 0, 'posz' => 0, 'cap' => 0, 'lastlogin' => 0, 'lastip' => 0, 'save' => true, 'skulltime' => 0, 'skull' => 0, 'balance' => 0, 'lastlogout' => 0, 'blessings' => 0, 'stamina' => 0, 'online' => 0, 'comment' => '', 'created' => 0, 'hidden' => 0);
94
95/**
96 * Player skills.
97 *
98 * @version 0.0.2
99 * @since 0.0.2
100 * @var array
101 */
102 private $skills = array(
103 POT::SKILL_FIST => array('value' => 0, 'tries' => 0),
104 POT::SKILL_CLUB => array('value' => 0, 'tries' => 0),
105 POT::SKILL_SWORD => array('value' => 0, 'tries' => 0),
106 POT::SKILL_AXE => array('value' => 0, 'tries' => 0),
107 POT::SKILL_DIST => array('value' => 0, 'tries' => 0),
108 POT::SKILL_SHIELD => array('value' => 0, 'tries' => 0),
109 POT::SKILL_FISH => array('value' => 0, 'tries' => 0)
110 );
111/**
112 * Magic PHP5 method.
113 *
114 * Allows object serialisation.
115 *
116 * @return array List of properties that should be saved.
117 * @version 0.0.4
118 * @since 0.0.4
119 */
120 public function __sleep()
121 {
122 return array('data', 'skills');
123 }
124
125/**
126 * Loads player with given id.
127 *
128 * @version 0.1.2
129 * @param int $id Player's ID.
130 * @throws PDOException On PDO operation error.
131 */
132 public function load($id, $fields = null, $load_skills = true)
133 {
134 global $__load;
135
136 if(!isset($__load['loss_experience']))
137 {
138 $loss = '';
139 if($this->db->hasColumn('players', 'loss_experience')) {
140 $loss = ', `loss_experience`, `loss_mana`, `loss_skills`';
141 }
142
143 $__load['loss_experience'] = $loss;
144 }
145
146 if(!isset($__load['loss_items']))
147 {
148 $loss_items = '';
149 if($this->db->hasColumn('players', 'loss_items')) {
150 $loss_items = ', `loss_items`, `loss_containers`';
151 }
152
153 $__load['loss_items'] = $loss_items;
154 }
155
156 if(!isset($__load['guild_info']))
157 {
158 $guild_info = '';
159 if(!$this->db->hasTable('guild_members') && $this->db->hasColumn('players', 'guildnick')) {
160 $guild_info = ', `guildnick`, `rank_id`';
161 }
162
163 $__load['guild_info'] = $guild_info;
164 }
165
166 if(!isset($__load['skull_type']))
167 {
168 $skull_type = 'skull';
169 if($this->db->hasColumn('players', 'skull_type')) {
170 $skull_type = 'skull_type';
171 }
172
173 $__load['skull_type'] = $skull_type;
174 }
175
176 if(!isset($__load['skull_time']))
177 {
178 $skull_time = 'skulltime';
179 if($this->db->hasColumn('players', 'skull_time')) {
180 $skull_time = 'skull_time';
181 }
182
183 $__load['skull_time'] = $skull_time;
184 }
185
186 if(!isset($__load['blessings'])) {
187 $__load['blessings'] = $this->db->hasColumn('players', 'blessings');
188 }
189 if(!isset($__load['direction'])) {
190 $__load['direction'] = $this->db->hasColumn('players', 'direction');
191 }
192 if(!isset($__load['stamina'])) {
193 $__load['stamina'] = $this->db->hasColumn('players', 'stamina');
194 }
195 if(!isset($__load['world_id'])) {
196 $__load['world_id'] = $this->db->hasColumn('players', 'world_id');
197 }
198 if(!isset($__load['online'])) {
199 $__load['online'] = $this->db->hasColumn('players', 'online');
200 }
201 if(!isset($__load['deletion'])) {
202 $__load['deletion'] = $this->db->hasColumn('players', 'deletion');
203 }
204 if(!isset($__load['promotion'])) {
205 $__load['promotion'] = $this->db->hasColumn('players', 'promotion');
206 }
207 if(!isset($__load['marriage'])) {
208 $__load['marriage'] = $this->db->hasColumn('players', 'marriage');
209 }
210
211 if(isset($fields)) { // load only what we wish
212 if(in_array('promotion', $fields)) {
213 if(!$this->db->hasColumn('players', 'promotion')) {
214 unset($fields[array_search('promotion', $fields)]);
215 }
216 }
217
218 if(in_array('deleted', $fields)) {
219 if($this->db->hasColumn('players', 'deletion')) {
220 unset($fields[array_search('deleted', $fields)]);
221 $fields[] = 'deletion';
222 }
223 }
224
225 if(in_array('online', $fields)) {
226 if(!$this->db->hasColumn('players', 'online')) {
227 unset($fields[array_search('online', $fields)]);
228 }
229 }
230 $this->data = $this->db->query('SELECT ' . implode(', ', $fields) . ' FROM `players` WHERE `id` = ' . (int)$id)->fetch();
231 }
232 else {
233 // SELECT query on database
234 $this->data = $this->db->query('SELECT `id`, `name`, `account_id`, `group_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, `healthmax`, `mana`, `manamax`, `manaspent`, `soul`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`' . ($this->db->hasColumn('players', 'lookaddons') ? ', `lookaddons`' : '') . ', `posx`, `posy`, `posz`, `cap`, `lastlogin`, `lastlogout`, `lastip`, `save`, `conditions`, `' . $__load['skull_time'] . '` as `skulltime`, `' . $__load['skull_type'] . '` as `skull`' . $__load['guild_info'] . ', `town_id`' . $__load['loss_experience'] . $__load['loss_items'] . ', `balance`' . ($__load['blessings'] ? ', `blessings`' : '') . ($__load['direction'] ? ', `direction`' : '') . ($__load['stamina'] ? ', `stamina`' : '') . ($__load['world_id'] ? ', `world_id`' : '') . ($__load['online'] ? ', `online`' : '') . ', `' . ($__load['deletion'] ? 'deletion' : 'deleted') . '`' . ($__load['promotion'] ? ', `promotion`' : '') . ($__load['marriage'] ? ', `marriage`' : '') . ', `comment`, `created`, `hidden` FROM `players` WHERE `id` = ' . (int)$id)->fetch();
235 }
236
237 if(!isset($this->data['guildnick']) || $this->data['guildnick'])
238 $this->data['guildnick'] = '';
239
240 if(!isset($this->data['rank_id']) || $this->data['rank_id'] == NULL)
241 $this->data['rank_id'] = 0;
242
243 // loads skills
244 if( $this->isLoaded() && $load_skills)
245 {
246 if($this->db->hasColumn('players', 'skill_fist')) {
247
248 $skill_ids = array(
249 'skill_fist' => POT::SKILL_FIST,
250 'skill_club' => POT::SKILL_CLUB,
251 'skill_sword' => POT::SKILL_SWORD,
252 'skill_axe' => POT::SKILL_AXE,
253 'skill_dist' => POT::SKILL_DIST,
254 'skill_shielding' => POT::SKILL_SHIELD,
255 'skill_fishing' => POT::SKILL_FISH
256 );
257
258 $select = '';
259 $i = count($skill_ids);
260 foreach($skill_ids as $name => $id) {
261 $select .= '`' . $name . '`,';
262 $select .= '`' . $name . '_tries`';
263
264 if($id != $i - 1)
265 $select .= ',';
266
267 }
268 //echo $select;
269 $skills = $this->db->query('SELECT ' . $select . ' FROM `players` WHERE `id` = ' . $this->data['id'])->fetch();
270 foreach($skill_ids as $name => $id) {
271 $this->skills[$id] = array('value' => $skills[$name], 'tries' => $skills[$name . '_tries']);
272 }
273 }
274 else if($this->db->hasTable('player_skills')) {
275 foreach( $this->db->query('SELECT ' . $this->db->fieldName('skillid') . ', ' . $this->db->fieldName('value') . ', ' . $this->db->fieldName('count') . ' FROM ' . $this->db->tableName('player_skills') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'])->fetchAll() as $skill)
276 {
277 $this->skills[ $skill['skillid'] ] = array('value' => $skill['value'], 'tries' => $skill['count']);
278 }
279 }
280 }
281 }
282
283/**
284 * Loads player by it's name.
285 *
286 * @version 0.0.5
287 * @since 0.0.2
288 * @param string $name Player's name.
289 * @throws PDOException On PDO operation error.
290 */
291 public function find($name)
292 {
293 // finds player's ID
294 $id = $this->db->query('SELECT `id` FROM `players` WHERE `name` = ' . $this->db->quote($name) )->fetch();
295
296 // if anything was found
297 if( isset($id['id']) )
298 {
299 $this->load($id['id']);
300 }
301 }
302
303/**
304 * Checks if object is loaded.
305 *
306 * @return bool Load state.
307 */
308 public function isLoaded()
309 {
310 return isset($this->data['id']);
311 }
312
313/**
314 * Saves player in database.
315 *
316 * <p>
317 * If player is not loaded to represent any existing group it will create new row for it.
318 * </p>
319 *
320 * @version 0.1.2
321 * @throws PDOException On PDO operation error.
322 */
323 public function save()
324 {
325 $skull_type = 'skull';
326 if($this->db->hasColumn('players', 'skull_type')) {
327 $skull_type = 'skull_type';
328 }
329
330 $skull_time = 'skulltime';
331 if($this->db->hasColumn('players', 'skull_time')) {
332 $skull_time = 'skull_time';
333 }
334
335 if(!isset($this->data['loss_experience']))
336 $this->data['loss_experience'] = 100;
337
338 if(!isset($this->data['loss_mana']))
339 $this->data['loss_mana'] = 100;
340
341 if(!isset($this->data['loss_skills']))
342 $this->data['loss_skills'] = 100;
343
344 if(!isset($this->data['loss_items']))
345 $this->data['loss_items'] = 10;
346
347 if(!isset($this->data['loss_containers']))
348 $this->data['loss_containers'] = 100;
349
350 if(!isset($this->data['guildnick']))
351 $this->data['guildnick'] = '';
352
353 if(!isset($this->data['rank_id']))
354 $this->data['rank_id'] = 0;
355
356 if(!isset($this->data['promotion']))
357 $this->data['promotion'] = 0;
358
359 if(!isset($this->data['direction']))
360 $this->data['direction'] = 0;
361
362 if(!isset($this->data['conditions']))
363 $this->data['conditions'] = '';
364
365 if(!isset($this->data['town_id']))
366 $this->data['town_id'] = 1;
367
368 // updates existing player
369 if( isset($this->data['id']) )
370 {
371 $loss = '';
372 if($this->db->hasColumn('players', 'loss_experience')) {
373 $loss = ', `loss_experience` = ' . $this->data['loss_experience'] . ', `loss_mana` = ' . $this->data['loss_mana'] . ', `loss_skills` = ' . $this->data['loss_skills'];
374 }
375
376 $loss_items = '';
377 if($this->db->hasColumn('players', 'loss_items')) {
378 $loss_items = ', `loss_items` = ' . $this->data['loss_items'] . ', `loss_containers` = ' . $this->data['loss_containers'];
379 }
380
381 $guild_info = '';
382 if(!$this->db->hasTable('guild_members') && $this->db->hasColumn('players', 'guildnick')) {
383 $guild_info = ', `guildnick` = ' . $this->db->quote($this->data['guildnick']) . ', ' . $this->db->fieldName('rank_id') . ' = ' . $this->data['rank_id'];
384 }
385
386 $direction = '';
387 if($this->db->hasColumn('players', 'direction')) {
388 $direction = ', `direction` = ' . $this->db->quote($this->data['direction']);
389 }
390
391 $blessings = '';
392 if($this->db->hasColumn('players', 'blessings')) {
393 $blessings = ', `blessings` = ' . $this->db->quote($this->data['blessings']);
394 }
395
396 $stamina = '';
397 if($this->db->hasColumn('players', 'stamina')) {
398 $stamina = ', `stamina` = ' . $this->db->quote($this->data['stamina']);
399 }
400
401 $lookaddons = '';
402 if($this->db->hasColumn('players', 'lookaddons')) {
403 $lookaddons = ', `lookaddons` = ' . $this->db->quote($this->data['lookaddons']);
404 }
405
406 // UPDATE query on database
407 $this->db->query('UPDATE ' . $this->db->tableName('players') . ' SET ' . $this->db->fieldName('name') . ' = ' . $this->db->quote($this->data['name']) . ', ' . $this->db->fieldName('account_id') . ' = ' . $this->data['account_id'] . ', ' . $this->db->fieldName('group_id') . ' = ' . $this->data['group_id'] . ', ' . $this->db->fieldName('sex') . ' = ' . $this->data['sex'] . ', ' . $this->db->fieldName('vocation') . ' = ' . $this->data['vocation'] . ', ' . $this->db->fieldName('experience') . ' = ' . $this->data['experience'] . ', ' . $this->db->fieldName('level') . ' = ' . $this->data['level'] . ', ' . $this->db->fieldName('maglevel') . ' = ' . $this->data['maglevel'] . ', ' . $this->db->fieldName('health') . ' = ' . $this->data['health'] . ', ' . $this->db->fieldName('healthmax') . ' = ' . $this->data['healthmax'] . ', ' . $this->db->fieldName('mana') . ' = ' . $this->data['mana'] . ', ' . $this->db->fieldName('manamax') . ' = ' . $this->data['manamax'] . ', ' . $this->db->fieldName('manaspent') . ' = ' . $this->data['manaspent'] . ', ' . $this->db->fieldName('soul') . ' = ' . $this->data['soul'] . ', ' . $this->db->fieldName('lookbody') . ' = ' . $this->data['lookbody'] . ', ' . $this->db->fieldName('lookfeet') . ' = ' . $this->data['lookfeet'] . ', ' . $this->db->fieldName('lookhead') . ' = ' . $this->data['lookhead'] . ', ' . $this->db->fieldName('looklegs') . ' = ' . $this->data['looklegs'] . ', ' . $this->db->fieldName('looktype') . ' = ' . $this->data['looktype'] . $lookaddons . ', ' . $this->db->fieldName('posx') . ' = ' . $this->data['posx'] . ', ' . $this->db->fieldName('posy') . ' = ' . $this->data['posy'] . ', ' . $this->db->fieldName('posz') . ' = ' . $this->data['posz'] . ', ' . $this->db->fieldName('cap') . ' = ' . $this->data['cap'] . ', ' . $this->db->fieldName('lastlogin') . ' = ' . $this->data['lastlogin'] . ', ' . $this->db->fieldName('lastlogout') . ' = ' . $this->data['lastlogout'] . ', ' . $this->db->fieldName('lastip') . ' = ' . $this->data['lastip'] . ', ' . $this->db->fieldName('save') . ' = ' . (int) $this->data['save'] . ', ' . $this->db->fieldName('conditions') . ' = ' . $this->db->quote($this->data['conditions']) . ', `' . $skull_time . '` = ' . $this->data['skulltime'] . ', `' . $skull_type . '` = ' . (int) $this->data['skull'] . $guild_info . ', ' . $this->db->fieldName('town_id') . ' = ' . $this->data['town_id'] . $loss . $loss_items . ', ' . $this->db->fieldName('balance') . ' = ' . $this->data['balance'] . $blessings . $stamina . $direction . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
408 }
409 // creates new player
410 else
411 {
412 $loss = '';
413 $loss_data = '';
414 if($this->db->hasColumn('players', 'loss_experience')) {
415 $loss = ', `loss_experience`, `loss_mana`, `loss_skills`';
416 $loss_data = ', ' . $this->data['loss_experience'] . ', ' . $this->data['loss_mana'] . ', ' . $this->data['loss_skills'];
417 }
418
419 $loss_items = '';
420 $loss_items_data = '';
421 if($this->db->hasColumn('players', 'loss_items')) {
422 $loss_items = ', `loss_items`, `loss_containers`';
423 $loss_items_data = ', ' . $this->data['loss_items'] . ', ' . $this->data['loss_containers'];
424 }
425
426 $guild_info = '';
427 $guild_info_data = '';
428 if(!$this->db->hasTable('guild_members') && $this->db->hasColumn('players', 'guildnick')) {
429 $guild_info = ', `guildnick`, `rank_id`';
430 $guild_info_data = ', ' . $this->db->quote($this->data['guildnick']) . ', ' . $this->data['rank_id'];
431 }
432
433 $promotion = '';
434 $promotion_data = '';
435 if($this->db->hasColumn('players', 'promotion')) {
436 $promotion = ', `promotion`';
437 $promotion_data = ', ' . $this->data['promotion'];
438 }
439
440 $direction = '';
441 $direction_data = '';
442 if($this->db->hasColumn('players', 'direction')) {
443 $direction = ', `direction`';
444 $direction_data = ', ' . $this->data['direction'];
445 }
446
447 $blessings = '';
448 $blessings_data = '';
449 if($this->db->hasColumn('players', 'blessings')) {
450 $blessings = ', `blessings`';
451 $blessings_data = ', ' . $this->data['blessings'];
452 }
453
454 $stamina = '';
455 $stamina_data = '';
456 if($this->db->hasColumn('players', 'stamina')) {
457 $stamina = ', `stamina`';
458 $stamina_data = ', ' . $this->data['stamina'];
459 }
460
461 $lookaddons = '';
462 $lookaddons_data = '';
463 if($this->db->hasColumn('players', 'lookaddons')) {
464 $lookaddons = ', `lookaddons`';
465 $lookaddons_data = ', ' . $this->data['lookaddons'];
466 }
467
468 // INSERT query on database
469 $this->db->query('INSERT INTO `players` (`name`, `account_id`, `group_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, `healthmax`, `mana`, `manamax`, `manaspent`, `soul`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`' . $lookaddons . ', `posx`, `posy`, `posz`, `cap`, `lastlogin`, `lastlogout`, `lastip`, `save`, `conditions`, `' . $skull_time . '`, `' . $skull_type . '`' . $guild_info . ', `town_id`' . $loss . $loss_items . ', `balance`' . $blessings . $stamina . $direction . ', `created`' . $promotion . ', `comment`) VALUES (' . $this->db->quote($this->data['name']) . ', ' . $this->data['account_id'] . ', ' . $this->data['group_id'] . ', ' . $this->data['sex'] . ', ' . $this->data['vocation'] . ', ' . $this->data['experience'] . ', ' . $this->data['level'] . ', ' . $this->data['maglevel'] . ', ' . $this->data['health'] . ', ' . $this->data['healthmax'] . ', ' . $this->data['mana'] . ', ' . $this->data['manamax'] . ', ' . $this->data['manaspent'] . ', ' . $this->data['soul'] . ', ' . $this->data['lookbody'] . ', ' . $this->data['lookfeet'] . ', ' . $this->data['lookhead'] . ', ' . $this->data['looklegs'] . ', ' . $this->data['looktype'] . $lookaddons_data . ', ' . $this->data['posx'] . ', ' . $this->data['posy'] . ', ' . $this->data['posz'] . ', ' . $this->data['cap'] . ', ' . $this->data['lastlogin'] . ', ' . $this->data['lastlogout'] . ', ' . $this->data['lastip'] . ', ' . (int) $this->data['save'] . ', ' . $this->db->quote($this->data['conditions']) . ', ' . $this->data['skulltime'] . ', ' . (int) $this->data['skull'] . $guild_info_data . ', ' . $this->data['town_id'] . $loss_data . $loss_items_data . ', ' . $this->data['balance'] . $blessings_data . $stamina_data . $direction_data . ', ' . time() . $promotion_data . ', "")');
470 // ID of new group
471 $this->data['id'] = $this->db->lastInsertId();
472 }
473
474 // updates skills - doesn't matter if we have just created character - trigger inserts new skills
475 if($this->db->hasColumn('players', 'skill_fist')) { // tfs 1.0
476 $set = '';
477
478 $skill_ids = array(
479 'skill_fist' => POT::SKILL_FIST,
480 'skill_club' => POT::SKILL_CLUB,
481 'skill_sword' => POT::SKILL_SWORD,
482 'skill_axe' => POT::SKILL_AXE,
483 'skill_dist' => POT::SKILL_DIST,
484 'skill_shielding' => POT::SKILL_SHIELD,
485 'skill_fishing' => POT::SKILL_FISH
486 );
487
488 $i = count($skill_ids);
489 foreach($skill_ids as $name => $id) {
490 $set .= '`' . $name . '` = ' . $this->skills[$id]['value'] . ',';
491 $set .= '`' . $name . '_tries` = ' . $this->skills[$id]['tries'];
492
493 if($id != $i - 1)
494 $set .= ',';
495 }
496
497 $skills = $this->db->query('UPDATE `players` SET ' . $set . ' WHERE `id` = ' . $this->data['id']);
498 }
499 else if($this->db->hasTable('player_skills')) {
500 foreach($this->skills as $id => $skill)
501 {
502 $this->db->query('UPDATE ' . $this->db->tableName('player_skills') . ' SET ' . $this->db->fieldName('value') . ' = ' . $skill['value'] . ', ' . $this->db->fieldName('count') . ' = ' . $skill['tries'] . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('skillid') . ' = ' . $id);
503 }
504 }
505 }
506
507/**
508 * Player ID.
509 *
510 * <p>
511 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
512 * </p>
513 *
514 * @version 0.0.3
515 * @return int Player ID.
516 * @throws E_OTS_NotLoaded If player is not loaded.
517 */
518 public function getId()
519 {
520 if( !isset($this->data['id']) )
521 {
522 throw new E_OTS_NotLoaded();
523 }
524
525 return $this->data['id'];
526 }
527
528 public function isHidden()
529 {
530 if( !isset($this->data['hidden']) )
531 {
532 throw new E_OTS_NotLoaded();
533 }
534
535 return $this->data['hidden'] == 1;
536 }
537
538 public function setHidden($hidden)
539 {
540 $this->data['hidden'] = (int) $hidden;
541 }
542
543 public function getMarriage()
544 {
545 if(!$this->db->hasColumn('players', 'marriage'))
546 return '';
547
548 if( !isset($this->data['marriage']) )
549 {
550 throw new E_OTS_NotLoaded();
551 }
552
553 return $this->data['marriage'];
554 }
555
556/**
557 * Player name.
558 *
559 * <p>
560 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
561 * </p>
562 *
563 * @version 0.0.3
564 * @return string Player's name.
565 * @throws E_OTS_NotLoaded If player is not loaded.
566 */
567 public function getName()
568 {
569 if( !isset($this->data['name']) )
570 {
571 throw new E_OTS_NotLoaded();
572 }
573
574 return $this->data['name'];
575 }
576
577/**
578 * Sets players's name.
579 *
580 * <p>
581 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
582 * </p>
583 *
584 * @param string $name Name.
585 */
586 public function setName($name)
587 {
588 $this->data['name'] = (string) $name;
589 }
590
591/**
592 * Returns account of this player.
593 *
594 * <p>
595 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
596 * </p>
597 *
598 * @version 0.1.0
599 * @return OTS_Account Owning account.
600 * @throws E_OTS_NotLoaded If player is not loaded.
601 * @throws PDOException On PDO operation error.
602 */
603 public function getAccount()
604 {
605 if( !isset($this->data['account_id']) )
606 {
607 throw new E_OTS_NotLoaded();
608 }
609
610 $account = new OTS_Account();
611 $account->load($this->data['account_id']);
612 return $account;
613 }
614
615 public function getAccountId()
616 {
617 if( !isset($this->data['account_id']) )
618 {
619 throw new E_OTS_NotLoaded();
620 }
621
622 return $this->data['account_id'];
623 }
624/**
625 * Assigns character to account.
626 *
627 * <p>
628 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
629 * </p>
630 *
631 * @param OTS_Account $account Owning account.
632 * @throws E_OTS_NotLoaded If passed <var>$account</var> parameter is not loaded.
633 */
634 public function setAccount(OTS_Account $account)
635 {
636 $this->data['account_id'] = $account->getId();
637 }
638
639 public function setAccountId($account_id)
640 {
641 $this->data['account_id'] = (int)$account_id;
642 }
643
644/**
645 * Returns group of this player.
646 *
647 * <p>
648 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
649 * </p>
650 *
651 * @version 0.1.0
652 * @return OTS_Group Group of which current character is member.
653 * @throws E_OTS_NotLoaded If player is not loaded.
654 * @throws PDOException On PDO operation error.
655 */
656 public function getGroup()
657 {
658 //global $config;
659 //if($path == '')
660 // $path = $config['data_path'].'XML/groups.xml';
661
662 if( !isset($this->data['group_id']) )
663 {
664 throw new E_OTS_NotLoaded();
665 }
666
667 //$groups = new DOMDocument();
668 //$groups->load($path);
669
670 global $groups;
671 $tmp = $groups->getGroup($this->data['group_id']);
672 if($tmp)
673 return $tmp;
674
675 return new OTS_Group();
676 // echo 'error while loading group..';
677/*
678 $_id = $this->data['group_id'];
679 $tmpGroup = new OTS_Group;
680 foreach($groups->getElementsByTagName('group') as $group)
681 {
682 if($group->getAttribute('id') == $_id)
683 {
684 $tmpGroup->load($group);
685 return $tmpGroup;
686 }
687 }*/
688 // $group = new OTS_Group();
689 // $group->load($this->data['group_id']);
690 // return $group;
691 }
692
693/**
694 * Assigns character to group.
695 *
696 * <p>
697 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
698 * </p>
699 *
700 * @param OTS_Group $group Group to be a member.
701 * @throws E_OTS_NotLoaded If passed <var>$group</var> parameter is not loaded.
702 */
703 public function setGroup(OTS_Group $group)
704 {
705 $this->data['group_id'] = $group->getId();
706 }
707
708 public function setGroupId($group_id)
709 {
710 $this->data['group_id'] = $group_id;
711 }
712
713/**
714 * Player's Premium Account expiration timestamp.
715 *
716 * @version 0.1.5
717 * @since 0.0.3
718 * @return int Player PACC expiration timestamp.
719 * @throws E_OTS_NotLoaded If player is not loaded.
720 * @deprecated 0.1.5 Use OTS_Account->getPremiumEnd().
721 */
722 public function getPremiumEnd()
723 {
724 if( !isset($this->data['id']) )
725 {
726 throw new E_OTS_NotLoaded();
727 }
728
729 return $this->getAccount()->getPremiumEnd();
730 }
731
732/**
733 * Player gender.
734 *
735 * <p>
736 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
737 * </p>
738 *
739 * @version 0.0.3
740 * @return int Player gender.
741 * @throws E_OTS_NotLoaded If player is not loaded.
742 */
743 public function getSex()
744 {
745 if( !isset($this->data['sex']) )
746 {
747 throw new E_OTS_NotLoaded();
748 }
749
750 return $this->data['sex'];
751 }
752
753 public function isDeleted()
754 {
755 $field = 'deleted';
756 if($this->db->hasColumn('players', 'deletion'))
757 $field = 'deletion';
758
759 if( !isset($this->data[$field]) )
760 {
761 throw new E_OTS_NotLoaded();
762 }
763
764 return $this->data[$field] > 0;
765 }
766
767 public function setDeleted($deleted)
768 {
769 $this->data['deleted'] = (int) $deleted;
770 }
771
772 public function isOnline()
773 {
774 if($this->db->hasTable('players_online')) // tfs 1.0
775 {
776 $query = $this->db->query('SELECT `player_id` FROM `players_online` WHERE `player_id` = ' . $this->data['id']);
777 return $query->rowCount() > 0;
778 }
779
780 if( !isset($this->data['online']) )
781 {
782 throw new E_OTS_NotLoaded();
783 }
784
785 return $this->data['online'] == 1;
786 }
787
788 public function getCreated()
789 {
790 if( !isset($this->data['created']) )
791 {
792 throw new E_OTS_NotLoaded();
793 }
794
795 return $this->data['created'];
796 }
797
798 public function setCreated($created)
799 {
800 $this->data['created'] = (bool) $created;
801 }
802
803 public function getComment()
804 {
805 if( !isset($this->data['comment']) )
806 {
807 throw new E_OTS_NotLoaded();
808 }
809
810 return $this->data['comment'];
811 }
812
813 public function setComment($comment)
814 {
815 $this->data['comment'] = (string) $comment;
816 }
817
818
819/**
820 * Sets player gender.
821 *
822 * <p>
823 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
824 * </p>
825 *
826 * @param int $sex Player gender.
827 */
828 public function setSex($sex)
829 {
830 $this->data['sex'] = (int) $sex;
831 }
832
833/**
834 * Player proffesion.
835 *
836 * <p>
837 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
838 * </p>
839 *
840 * @version 0.0.3
841 * @return int Player proffesion.
842 * @throws E_OTS_NotLoaded If player is not loaded.
843 */
844 public function getVocation()
845 {
846 if( !isset($this->data['vocation']) )
847 {
848 throw new E_OTS_NotLoaded();
849 }
850
851 if(isset($this->data['promotion'])) {
852 global $config;
853 if((int)$this->data['promotion'] > 0)
854 return ($this->data['vocation'] + ($this->data['promotion'] * $config['vocations_amount']));
855 }
856
857 return $this->data['vocation'];
858 }
859
860
861 public function getPromotion()
862 {
863 if( !isset($this->data['promotion']) )
864 {
865 return false;
866 }
867
868 return $this->data['promotion'];
869 }
870/**
871 * Sets player proffesion.
872 *
873 * <p>
874 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
875 * </p>
876 *
877 * @param int $vocation Player proffesion.
878 */
879 public function setVocation($vocation)
880 {
881 $this->data['vocation'] = (int) $vocation;
882 }
883
884 public function setPromotion($promotion)
885 {
886 $this->data['promotion'] = (int) $promotion;
887 }
888/**
889 * Experience points.
890 *
891 * <p>
892 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
893 * </p>
894 *
895 * @version 0.0.3
896 * @return int Experience points.
897 * @throws E_OTS_NotLoaded If player is not loaded.
898 */
899 public function getExperience()
900 {
901 if( !isset($this->data['experience']) )
902 {
903 throw new E_OTS_NotLoaded();
904 }
905
906 return $this->data['experience'];
907 }
908
909/**
910 * Sets experience points.
911 *
912 * <p>
913 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
914 * </p>
915 *
916 * @param int $experience Experience points.
917 */
918 public function setExperience($experience)
919 {
920 $this->data['experience'] = (int) $experience;
921 }
922
923/**
924 * Experience level.
925 *
926 * <p>
927 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
928 * </p>
929 *
930 * @version 0.0.3
931 * @return int Experience level.
932 * @throws E_OTS_NotLoaded If player is not loaded.
933 */
934 public function getLevel()
935 {
936 if( !isset($this->data['level']) )
937 {
938 throw new E_OTS_NotLoaded();
939 }
940
941 return $this->data['level'];
942 }
943
944/**
945 * Sets experience level.
946 *
947 * <p>
948 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
949 * </p>
950 *
951 * @param int $level Experience level.
952 */
953 public function setLevel($level)
954 {
955 $this->data['level'] = (int) $level;
956 }
957
958/**
959 * Magic level.
960 *
961 * <p>
962 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
963 * </p>
964 *
965 * @version 0.0.3
966 * @return int Magic level.
967 * @throws E_OTS_NotLoaded If player is not loaded.
968 */
969 public function getMagLevel()
970 {
971 if( !isset($this->data['maglevel']) )
972 {
973 throw new E_OTS_NotLoaded();
974 }
975
976 return $this->data['maglevel'];
977 }
978
979/**
980 * Sets magic level.
981 *
982 * <p>
983 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
984 * </p>
985 *
986 * @param int $maglevel Magic level.
987 */
988 public function setMagLevel($maglevel)
989 {
990 $this->data['maglevel'] = (int) $maglevel;
991 }
992
993/**
994 * Current HP.
995 *
996 * <p>
997 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
998 * </p>
999 *
1000 * @version 0.0.3
1001 * @return int Current HP.
1002 * @throws E_OTS_NotLoaded If player is not loaded.
1003 */
1004 public function getHealth()
1005 {
1006 if( !isset($this->data['health']) )
1007 {
1008 throw new E_OTS_NotLoaded();
1009 }
1010
1011 return $this->data['health'];
1012 }
1013
1014/**
1015 * Sets current HP.
1016 *
1017 * <p>
1018 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1019 * </p>
1020 *
1021 * @param int $health Current HP.
1022 */
1023 public function setHealth($health)
1024 {
1025 $this->data['health'] = (int) $health;
1026 }
1027
1028/**
1029 * Maximum HP.
1030 *
1031 * <p>
1032 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1033 * </p>
1034 *
1035 * @version 0.0.3
1036 * @return int Maximum HP.
1037 * @throws E_OTS_NotLoaded If player is not loaded.
1038 */
1039 public function getHealthMax()
1040 {
1041 if( !isset($this->data['healthmax']) )
1042 {
1043 throw new E_OTS_NotLoaded();
1044 }
1045
1046 return $this->data['healthmax'];
1047 }
1048
1049/**
1050 * Sets maximum HP.
1051 *
1052 * <p>
1053 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1054 * </p>
1055 *
1056 * @param int $healthmax Maximum HP.
1057 */
1058 public function setHealthMax($healthmax)
1059 {
1060 $this->data['healthmax'] = (int) $healthmax;
1061 }
1062
1063/**
1064 * Current mana.
1065 *
1066 * <p>
1067 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1068 * </p>
1069 *
1070 * @version 0.0.3
1071 * @return int Current mana.
1072 * @throws E_OTS_NotLoaded If player is not loaded.
1073 */
1074 public function getMana()
1075 {
1076 if( !isset($this->data['mana']) )
1077 {
1078 throw new E_OTS_NotLoaded();
1079 }
1080
1081 return $this->data['mana'];
1082 }
1083
1084/**
1085 * Sets current mana.
1086 *
1087 * <p>
1088 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1089 * </p>
1090 *
1091 * @param int $mana Current mana.
1092 */
1093 public function setMana($mana)
1094 {
1095 $this->data['mana'] = (int) $mana;
1096 }
1097
1098/**
1099 * Maximum mana.
1100 *
1101 * <p>
1102 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1103 * </p>
1104 *
1105 * @version 0.0.3
1106 * @return int Maximum mana.
1107 * @throws E_OTS_NotLoaded If player is not loaded.
1108 */
1109 public function getManaMax()
1110 {
1111 if( !isset($this->data['manamax']) )
1112 {
1113 throw new E_OTS_NotLoaded();
1114 }
1115
1116 return $this->data['manamax'];
1117 }
1118
1119/**
1120 * Sets maximum mana.
1121 *
1122 * <p>
1123 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1124 * </p>
1125 *
1126 * @param int $manamax Maximum mana.
1127 */
1128 public function setManaMax($manamax)
1129 {
1130 $this->data['manamax'] = (int) $manamax;
1131 }
1132
1133/**
1134 * Mana spent.
1135 *
1136 * <p>
1137 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1138 * </p>
1139 *
1140 * @version 0.0.3
1141 * @return int Mana spent.
1142 * @throws E_OTS_NotLoaded If player is not loaded.
1143 */
1144 public function getManaSpent()
1145 {
1146 if( !isset($this->data['manaspent']) )
1147 {
1148 throw new E_OTS_NotLoaded();
1149 }
1150
1151 return $this->data['manaspent'];
1152 }
1153
1154/**
1155 * Sets mana spent.
1156 *
1157 * <p>
1158 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1159 * </p>
1160 *
1161 * @param int $manaspent Mana spent.
1162 */
1163 public function setManaSpent($manaspent)
1164 {
1165 $this->data['manaspent'] = (int) $manaspent;
1166 }
1167
1168/**
1169 * Soul points.
1170 *
1171 * <p>
1172 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1173 * </p>
1174 *
1175 * @version 0.0.3
1176 * @return int Soul points.
1177 * @throws E_OTS_NotLoaded If player is not loaded.
1178 */
1179 public function getSoul()
1180 {
1181 if( !isset($this->data['soul']) )
1182 {
1183 throw new E_OTS_NotLoaded();
1184 }
1185
1186 return $this->data['soul'];
1187 }
1188
1189/**
1190 * Sets soul points.
1191 *
1192 * <p>
1193 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1194 * </p>
1195 *
1196 * @param int $soul Soul points.
1197 */
1198 public function setSoul($soul)
1199 {
1200 $this->data['soul'] = (int) $soul;
1201 }
1202
1203/**
1204 * Looking direction.
1205 *
1206 * <p>
1207 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1208 * </p>
1209 *
1210 * @version 0.0.3
1211 * @return int Looking direction.
1212 * @throws E_OTS_NotLoaded If player is not loaded.
1213 */
1214 public function getDirection()
1215 {
1216 if( !isset($this->data['direction']) )
1217 {
1218 throw new E_OTS_NotLoaded();
1219 }
1220
1221 return $this->data['direction'];
1222 }
1223
1224/**
1225 * Sets looking direction.
1226 *
1227 * <p>
1228 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1229 * </p>
1230 *
1231 * @param int $direction Looking direction.
1232 */
1233 public function setDirection($direction)
1234 {
1235 $this->data['direction'] = (int) $direction;
1236 }
1237
1238/**
1239 * Body color.
1240 *
1241 * <p>
1242 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1243 * </p>
1244 *
1245 * @version 0.0.3
1246 * @return int Body color.
1247 * @throws E_OTS_NotLoaded If player is not loaded.
1248 */
1249 public function getLookBody()
1250 {
1251 if( !isset($this->data['lookbody']) )
1252 {
1253 throw new E_OTS_NotLoaded();
1254 }
1255
1256 return $this->data['lookbody'];
1257 }
1258
1259/**
1260 * Sets body color.
1261 *
1262 * <p>
1263 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1264 * </p>
1265 *
1266 * @param int $lookbody Body color.
1267 */
1268 public function setLookBody($lookbody)
1269 {
1270 $this->data['lookbody'] = (int) $lookbody;
1271 }
1272
1273/**
1274 * Boots color.
1275 *
1276 * <p>
1277 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1278 * </p>
1279 *
1280 * @version 0.0.3
1281 * @return int Boots color.
1282 * @throws E_OTS_NotLoaded If player is not loaded.
1283 */
1284 public function getLookFeet()
1285 {
1286 if( !isset($this->data['lookfeet']) )
1287 {
1288 throw new E_OTS_NotLoaded();
1289 }
1290
1291 return $this->data['lookfeet'];
1292 }
1293
1294/**
1295 * Sets boots color.
1296 *
1297 * <p>
1298 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1299 * </p>
1300 *
1301 * @param int $lookfeet Boots color.
1302 */
1303 public function setLookFeet($lookfeet)
1304 {
1305 $this->data['lookfeet'] = (int) $lookfeet;
1306 }
1307
1308/**
1309 * Hair color.
1310 *
1311 * <p>
1312 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1313 * </p>
1314 *
1315 * @version 0.0.3
1316 * @return int Hair color.
1317 * @throws E_OTS_NotLoaded If player is not loaded.
1318 */
1319 public function getLookHead()
1320 {
1321 if( !isset($this->data['lookhead']) )
1322 {
1323 throw new E_OTS_NotLoaded();
1324 }
1325
1326 return $this->data['lookhead'];
1327 }
1328
1329/**
1330 * Sets hair color.
1331 *
1332 * <p>
1333 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1334 * </p>
1335 *
1336 * @param int $lookhead Hair color.
1337 */
1338 public function setLookHead($lookhead)
1339 {
1340 $this->data['lookhead'] = (int) $lookhead;
1341 }
1342
1343/**
1344 * Legs color.
1345 *
1346 * <p>
1347 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1348 * </p>
1349 *
1350 * @version 0.0.3
1351 * @return int Legs color.
1352 * @throws E_OTS_NotLoaded If player is not loaded.
1353 */
1354 public function getLookLegs()
1355 {
1356 if( !isset($this->data['looklegs']) )
1357 {
1358 throw new E_OTS_NotLoaded();
1359 }
1360
1361 return $this->data['looklegs'];
1362 }
1363
1364/**
1365 * Sets legs color.
1366 *
1367 * <p>
1368 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1369 * </p>
1370 *
1371 * @param int $looklegs Legs color.
1372 */
1373 public function setLookLegs($looklegs)
1374 {
1375 $this->data['looklegs'] = (int) $looklegs;
1376 }
1377
1378/**
1379 * Outfit.
1380 *
1381 * <p>
1382 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1383 * </p>
1384 *
1385 * @version 0.0.3
1386 * @return int Outfit.
1387 * @throws E_OTS_NotLoaded If player is not loaded.
1388 */
1389 public function getLookType()
1390 {
1391 if( !isset($this->data['looktype']) )
1392 {
1393 throw new E_OTS_NotLoaded();
1394 }
1395
1396 return $this->data['looktype'];
1397 }
1398
1399/**
1400 * Sets outfit.
1401 *
1402 * <p>
1403 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1404 * </p>
1405 *
1406 * @param int $looktype Outfit.
1407 */
1408 public function setLookType($looktype)
1409 {
1410 $this->data['looktype'] = (int) $looktype;
1411 }
1412
1413/**
1414 * Addons.
1415 *
1416 * <p>
1417 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1418 * </p>
1419 *
1420 * @version 0.0.3
1421 * @return int Addons.
1422 * @throws E_OTS_NotLoaded If player is not loaded.
1423 */
1424 public function getLookAddons()
1425 {
1426 if( !isset($this->data['lookaddons']) )
1427 {
1428 throw new E_OTS_NotLoaded();
1429 }
1430
1431 return $this->data['lookaddons'];
1432 }
1433
1434/**
1435 * Sets addons.
1436 *
1437 * <p>
1438 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1439 * </p>
1440 *
1441 * @param int $lookaddons Addons.
1442 */
1443 public function setLookAddons($lookaddons)
1444 {
1445 $this->data['lookaddons'] = (int) $lookaddons;
1446 }
1447
1448/**
1449 * X map coordinate.
1450 *
1451 * <p>
1452 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1453 * </p>
1454 *
1455 * @version 0.0.3
1456 * @return int X map coordinate.
1457 * @throws E_OTS_NotLoaded If player is not loaded.
1458 */
1459 public function getPosX()
1460 {
1461 if( !isset($this->data['posx']) )
1462 {
1463 throw new E_OTS_NotLoaded();
1464 }
1465
1466 return $this->data['posx'];
1467 }
1468
1469/**
1470 * Sets X map coordinate.
1471 *
1472 * <p>
1473 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1474 * </p>
1475 *
1476 * @param int $posx X map coordinate.
1477 */
1478 public function setPosX($posx)
1479 {
1480 $this->data['posx'] = (int) $posx;
1481 }
1482
1483/**
1484 * Y map coordinate.
1485 *
1486 * <p>
1487 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1488 * </p>
1489 *
1490 * @version 0.0.3
1491 * @return int Y map coordinate.
1492 * @throws E_OTS_NotLoaded If player is not loaded.
1493 */
1494 public function getPosY()
1495 {
1496 if( !isset($this->data['posy']) )
1497 {
1498 throw new E_OTS_NotLoaded();
1499 }
1500
1501 return $this->data['posy'];
1502 }
1503
1504/**
1505 * Sets Y map coordinate.
1506 *
1507 * <p>
1508 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1509 * </p>
1510 *
1511 * @param int $posy Y map coordinate.
1512 */
1513 public function setPosY($posy)
1514 {
1515 $this->data['posy'] = (int) $posy;
1516 }
1517
1518/**
1519 * Z map coordinate.
1520 *
1521 * <p>
1522 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1523 * </p>
1524 *
1525 * @version 0.0.3
1526 * @return int Z map coordinate.
1527 * @throws E_OTS_NotLoaded If player is not loaded.
1528 */
1529 public function getPosZ()
1530 {
1531 if( !isset($this->data['posz']) )
1532 {
1533 throw new E_OTS_NotLoaded();
1534 }
1535
1536 return $this->data['posz'];
1537 }
1538
1539/**
1540 * Sets Z map coordinate.
1541 *
1542 * <p>
1543 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1544 * </p>
1545 *
1546 * @param int $posz Z map coordinate.
1547 */
1548 public function setPosZ($posz)
1549 {
1550 $this->data['posz'] = (int) $posz;
1551 }
1552
1553/**
1554 * Capacity.
1555 *
1556 * <p>
1557 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1558 * </p>
1559 *
1560 * @version 0.0.3
1561 * @return int Capacity.
1562 * @throws E_OTS_NotLoaded If player is not loaded.
1563 */
1564 public function getCap()
1565 {
1566 if( !isset($this->data['cap']) )
1567 {
1568 throw new E_OTS_NotLoaded();
1569 }
1570
1571 return $this->data['cap'];
1572 }
1573
1574/**
1575 * Sets capacity.
1576 *
1577 * <p>
1578 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1579 * </p>
1580 *
1581 * @param int $cap Capacity.
1582 */
1583 public function setCap($cap)
1584 {
1585 $this->data['cap'] = (int) $cap;
1586 }
1587
1588/**
1589 * Last login timestamp.
1590 *
1591 * <p>
1592 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1593 * </p>
1594 *
1595 * @version 0.0.3
1596 * @return int Last login timestamp.
1597 * @throws E_OTS_NotLoaded If player is not loaded.
1598 */
1599 public function getLastLogin()
1600 {
1601 if( !isset($this->data['lastlogin']) )
1602 {
1603 throw new E_OTS_NotLoaded();
1604 }
1605
1606 return $this->data['lastlogin'];
1607 }
1608
1609 public function getLastLogout()
1610 {
1611 if( !isset($this->data['lastlogout']) )
1612 {
1613 throw new E_OTS_NotLoaded();
1614 }
1615
1616 return $this->data['lastlogout'];
1617 }
1618
1619
1620/**
1621 * Sets last login timestamp.
1622 *
1623 * <p>
1624 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1625 * </p>
1626 *
1627 * @param int $lastlogin Last login timestamp.
1628 */
1629 public function setLastLogin($lastlogin)
1630 {
1631 $this->data['lastlogin'] = (int) $lastlogin;
1632 }
1633
1634 public function setLastLogout($lastlogout)
1635 {
1636 $this->data['lastlogout'] = (int) $lastlogout;
1637 }
1638
1639/**
1640 * Last login IP.
1641 *
1642 * <p>
1643 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1644 * </p>
1645 *
1646 * @version 0.0.3
1647 * @return int Last login IP.
1648 * @throws E_OTS_NotLoaded If player is not loaded.
1649 */
1650 public function getLastIP()
1651 {
1652 if( !isset($this->data['lastip']) )
1653 {
1654 throw new E_OTS_NotLoaded();
1655 }
1656
1657 return $this->data['lastip'];
1658 }
1659
1660/**
1661 * Sets last login IP.
1662 *
1663 * <p>
1664 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1665 * </p>
1666 *
1667 * @param int $lastip Last login IP.
1668 */
1669 public function setLastIP($lastip)
1670 {
1671 $this->data['lastip'] = (int) $lastip;
1672 }
1673
1674/**
1675 * Checks if save flag is set.
1676 *
1677 * <p>
1678 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1679 * </p>
1680 *
1681 * @version 0.0.7
1682 * @return bool PACC days.
1683 * @throws E_OTS_NotLoaded If player is not loaded.
1684 */
1685 public function isSaveSet()
1686 {
1687 if( !isset($this->data['save']) )
1688 {
1689 throw new E_OTS_NotLoaded();
1690 }
1691
1692 return $this->data['save'];
1693 }
1694
1695/**
1696 * Unsets save flag.
1697 *
1698 * <p>
1699 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1700 * </p>
1701 *
1702 * @version 0.0.7
1703 */
1704 public function unsetSave()
1705 {
1706 $this->data['save'] = false;
1707 }
1708
1709/**
1710 * @version 0.0.7
1711 * @since 0.0.6
1712 * @return int Save counter.
1713 * @throws E_OTS_NotLoaded If player is not loaded.
1714 * @deprecated 0.0.7 Save field is back as flag not a counter.
1715 */
1716 public function getSave()
1717 {
1718 if( !isset($this->data['save']) )
1719 {
1720 throw new E_OTS_NotLoaded();
1721 }
1722
1723 return $this->data['save'];
1724 }
1725
1726/**
1727 * Sets save flag.
1728 *
1729 * <p>
1730 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1731 * </p>
1732 *
1733 * @version 0.0.7
1734 * @param int $save Deprecated, unused, optional.
1735 */
1736 public function setSave($save = 1)
1737 {
1738 $this->data['save'] = true;
1739 }
1740
1741/**
1742 * Conditions.
1743 *
1744 * <p>
1745 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1746 * </p>
1747 *
1748 * @version 0.0.3
1749 * @return string Conditions binary string.
1750 * @throws E_OTS_NotLoaded If player is not loaded.
1751 */
1752 public function getConditions()
1753 {
1754 if( !isset($this->data['conditions']) )
1755 {
1756 throw new E_OTS_NotLoaded();
1757 }
1758
1759 return $this->data['conditions'];
1760 }
1761
1762/**
1763 * Sets conditions.
1764 *
1765 * <p>
1766 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1767 * </p>
1768 *
1769 * @param string $conditions Condition binary string.
1770 */
1771 public function setConditions($conditions)
1772 {
1773 $this->data['conditions'] = $conditions;
1774 }
1775
1776/**
1777 * Red skulled time remained.
1778 *
1779 * <p>
1780 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1781 * </p>
1782 *
1783 * @version 0.0.3
1784 * @return int Red skulled time remained.
1785 * @throws E_OTS_NotLoaded If player is not loaded.
1786 */
1787 public function getSkullTime()
1788 {
1789 if( !isset($this->data['skulltime']) )
1790 {
1791 throw new E_OTS_NotLoaded();
1792 }
1793
1794 return $this->data['skulltime'];
1795 }
1796
1797/**
1798 * Sets red skulled time remained.
1799 *
1800 * <p>
1801 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1802 * </p>
1803 *
1804 * @param int $redskulltime Red skulled time remained.
1805 */
1806 public function setSkullTime($skulltime)
1807 {
1808 $this->data['skulltime'] = (int) $skulltime;
1809 }
1810
1811/**
1812 * Checks if player has red skull.
1813 *
1814 * <p>
1815 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1816 * </p>
1817 *
1818 * @version 0.0.3
1819 * @return bool Red skull state.
1820 * @throws E_OTS_NotLoaded If player is not loaded.
1821 */
1822 public function getSkull()
1823 {
1824 if( !isset($this->data['skull']) )
1825 {
1826 throw new E_OTS_NotLoaded();
1827 }
1828
1829 return $this->data['skull'];
1830 }
1831
1832/**
1833 * Unsets red skull flag.
1834 *
1835 * <p>
1836 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1837 * </p>
1838 */
1839 public function unsetRedSkull()
1840 {
1841 $this->data['skull'] = false;
1842 }
1843
1844/**
1845 * Sets red skull flag.
1846 *
1847 * <p>
1848 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1849 * </p>
1850 */
1851 public function setSkull($value)
1852 {
1853 $this->data['skull'] = $value;
1854 }
1855
1856/**
1857 * Guild nick.
1858 *
1859 * <p>
1860 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1861 * </p>
1862 *
1863 * @version 0.0.3
1864 * @return string Guild title.
1865 * @throws E_OTS_NotLoaded If player is not loaded.
1866 */
1867 public function loadRank()
1868 {
1869 $table = 'guild_membership';
1870 if($this->db->hasTable('guild_members'))
1871 $table = 'guild_members';
1872
1873 $ranks = $this->db->query('SELECT `rank_id`, `nick` FROM `' . $table . '` WHERE `player_id` = ' . $this->db->quote($this->getID()))->fetch();
1874 if($ranks)
1875 {
1876 $this->data['rank_id'] = new OTS_GuildRank($ranks['rank_id']);
1877 $this->data['guildnick'] = $ranks['nick'];
1878 }
1879 else
1880 {
1881 $this->data['rank_id'] = null;
1882 $this->data['guildnick'] = '';
1883 }
1884 }
1885
1886 public function getGuildNick()
1887 {
1888 if(!isset($this->data['guildnick']) || !isset($this->data['rank_id']))
1889 $this->loadRank();
1890
1891 return $this->data['guildnick'];
1892 }
1893
1894/**
1895 * Sets guild nick.
1896 *
1897 * <p>
1898 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
1899 * </p>
1900 *
1901 * @param string $guildnick Name.
1902 */
1903 public function setGuildNick($guildnick)
1904 {
1905 $this->data['guildnick'] = (string) $guildnick;
1906 if($this->db->hasTable('guild_members'))
1907 $this->db->query('UPDATE `guild_members` SET `nick` = ' . $this->db->quote($this->data['guildnick']) . ' WHERE `player_id` = ' . $this->getId());
1908 else if($this->db->hasTable('guild_membership'))
1909 $this->db->query('UPDATE `guild_membership` SET `nick` = ' . $this->db->quote($this->data['guildnick']) . ' WHERE `player_id` = ' . $this->getId());
1910 else if($this->db->hasColumn('players', 'guildnick'))
1911 $this->db->query('UPDATE `players` SET `guildnick` = ' . $this->db->quote($this->data['guildnick']) . ' WHERE `id` = ' . $this->getId());
1912 }
1913
1914/**
1915 * @version 0.0.3
1916 * @return int Guild rank ID.
1917 * @throws E_OTS_NotLoaded If player is not loaded.
1918 * @deprecated 0.0.4 Use getRank().
1919 */
1920 public function getRankId()
1921 {
1922 if( !isset($this->data['rank_id']) )
1923 {
1924 throw new E_OTS_NotLoaded();
1925 }
1926
1927 return $this->data['rank_id'];
1928 }
1929
1930/**
1931 * Assigned guild rank.
1932 *
1933 * <p>
1934 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
1935 * </p>
1936 *
1937 * @version 0.1.0
1938 * @return OTS_GuildRank|null Guild rank (null if not member of any).
1939 * @throws E_OTS_NotLoaded If player is not loaded.
1940 * @throws PDOException On PDO operation error.
1941 */
1942 public function getRank()
1943 {
1944 $rank_id = 0;
1945 if($this->db->hasTable('guild_members')) {
1946 $query = $this->db->query('SELECT `rank_id` FROM `guild_members` WHERE `player_id`= ' . $this->data['id'] . ' LIMIT 1;');
1947 if($query->rowCount() == 1) {
1948 $query = $query->fetch();
1949 $rank_id = $query['rank_id'];
1950 }
1951 }
1952 else if($this->db->hasTable('guild_membership')) {
1953 $query = $this->db->query('SELECT `rank_id` FROM `guild_membership` WHERE `player_id`= ' . $this->data['id'] . ' LIMIT 1;');
1954 if($query->rowCount() == 1) {
1955 $query = $query->fetch();
1956 $rank_id = $query['rank_id'];
1957 }
1958 }
1959 else if($this->db->hasColumn('players', 'rank_id')) {
1960 $query = $this->db->query('SELECT `rank_id` FROM `players` WHERE `id`= ' . $this->data['id'] . ';')->fetch();
1961 $rank_id = $query['rank_id'];
1962 }
1963
1964 if($rank_id == 0) {
1965 return new OTS_GuildRank();
1966 }
1967
1968 $guildRank = new OTS_GuildRank();
1969 $guildRank->load($rank_id);
1970 return $guildRank;
1971 }
1972
1973/**
1974 * @param int $rank_id Guild rank ID.
1975 * @deprecated 0.0.4 Use setRank().
1976 */
1977 public function setRankId($rank_id, $guild)
1978 {
1979 if( isset($rank_id) && isset($guild)) {
1980 if($rank_id == 0) {
1981 if($this->db->hasTable('guild_membership')) {
1982 $this->db->query('DELETE FROM `guild_membership` WHERE `player_id` = ' . $this->getId());
1983 }
1984 else if($this->db->hasTable('guild_members')) {
1985 $this->db->query('DELETE FROM `guild_members` WHERE `player_id` = ' . $this->getId());
1986 }
1987 else {
1988 $this->data['rank_id'] = 0;
1989 $this->save();
1990 }
1991 }
1992 else {
1993 if($this->db->hasTable('guild_membership')) {
1994 $query = $this->db->query('SELECT `player_id` FROM `guild_membership` WHERE `player_id` = ' . $this->getId() . ' LIMIT 1;');
1995 if($query->rowCount() == 1)
1996 $this->db->query('UPDATE `guild_membership` SET `guild_id` = ' . (int)$guild . ', `rank_id` = ' . (int)$rank_id . ' WHERE `player_id` = ' . $this->getId());
1997 else {
1998 $this->db->query('INSERT INTO `guild_membership` (`player_id`, `guild_id`, `rank_id`, `nick`) VALUES (' . $this->db->quote($this->getId()) . ', ' . $this->db->quote($guild) . ', ' . $this->db->quote($rank_id) . ', ' . $this->db->quote('') . ')');
1999 }
2000 }
2001 else if($this->db->hasTable('guild_members')) {
2002 $query = $this->db->query('SELECT `player_id` FROM `guild_members` WHERE `player_id` = ' . $this->getId() . ' LIMIT 1;');
2003 if($query->rowCount() == 1)
2004 $this->db->query('UPDATE `guild_members` SET `rank_id` = ' . (int)$rank_id . ' WHERE `player_id` = ' . $this->getId());
2005 else {
2006 $this->db->query('INSERT INTO `guild_members` (`player_id`, `rank_id`, `nick`) VALUES (' . $this->db->quote($this->getId()) . ', ' . $this->db->quote($rank_id) . ', ' . $this->db->quote('') . ')');
2007 }
2008 }
2009 else {
2010 $this->data['rank_id'] = (int) $rank_id;
2011 $this->save();
2012 }
2013 }
2014 }
2015 }
2016
2017/**
2018 * Assigns guild rank.
2019 *
2020 * <p>
2021 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
2022 * </p>
2023 *
2024 * @param OTS_GuildRank|null Guild rank (null to clear assign).
2025 * @throws E_OTS_NotLoaded If passed <var>$guildRank</var> parameter is not loaded.
2026 */
2027 public function setRank(OTS_GuildRank $guildRank = null)
2028 {
2029 if(isset($guildRank))
2030 $this->setRankId($guildRank->getId(), $guildRank->getGuild()->getId());
2031 else
2032 $this->setRankId(0, 0);
2033 }
2034
2035/**
2036 * Residence town's ID.
2037 *
2038 * <p>
2039 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
2040 * </p>
2041 *
2042 * @version 0.0.3
2043 * @return int Residence town's ID.
2044 * @throws E_OTS_NotLoaded If player is not loaded.
2045 */
2046 public function getTownId()
2047 {
2048 if( !isset($this->data['town_id']) )
2049 {
2050 throw new E_OTS_NotLoaded();
2051 }
2052
2053 return $this->data['town_id'];
2054 }
2055
2056/**
2057 * Sets residence town's ID.
2058 *
2059 * <p>
2060 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
2061 * </p>
2062 *
2063 * @param int $town_id Residence town's ID.
2064 */
2065 public function setTownId($town_id)
2066 {
2067 $this->data['town_id'] = (int) $town_id;
2068 }
2069
2070/**
2071 * Percentage of experience lost after dead.
2072 *
2073 * <p>
2074 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
2075 * </p>
2076 *
2077 * @version 0.0.3
2078 * @return int Percentage of experience lost after dead.
2079 * @throws E_OTS_NotLoaded If player is not loaded.
2080 */
2081 public function getLossExperience()
2082 {
2083 if( !isset($this->data['loss_experience']) )
2084 {
2085 throw new E_OTS_NotLoaded();
2086 }
2087
2088 return $this->data['loss_experience'];
2089 }
2090
2091/**
2092 * Sets percentage of experience lost after dead.
2093 *
2094 * <p>
2095 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
2096 * </p>
2097 *
2098 * @param int $loss_experience Percentage of experience lost after dead.
2099 */
2100 public function setLossExperience($loss_experience)
2101 {
2102 $this->data['loss_experience'] = (int) $loss_experience;
2103 }
2104
2105/**
2106 * Percentage of used mana lost after dead.
2107 *
2108 * <p>
2109 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
2110 * </p>
2111 *
2112 * @version 0.0.3
2113 * @return int Percentage of used mana lost after dead.
2114 * @throws E_OTS_NotLoaded If player is not loaded.
2115 */
2116 public function getLossMana()
2117 {
2118 if( !isset($this->data['loss_mana']) )
2119 {
2120 throw new E_OTS_NotLoaded();
2121 }
2122
2123 return $this->data['loss_mana'];
2124 }
2125
2126/**
2127 * Sets percentage of used mana lost after dead.
2128 *
2129 * <p>
2130 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
2131 * </p>
2132 *
2133 * @param int $loss_mana Percentage of used mana lost after dead.
2134 */
2135 public function setLossMana($loss_mana)
2136 {
2137 $this->data['loss_mana'] = (int) $loss_mana;
2138 }
2139
2140/**
2141 * Percentage of skills lost after dead.
2142 *
2143 * <p>
2144 * Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
2145 * </p>
2146 *
2147 * @version 0.0.3
2148 * @return int Percentage of skills lost after dead.
2149 * @throws E_OTS_NotLoaded If player is not loaded.
2150 */
2151 public function getLossSkills()
2152 {
2153 if( !isset($this->data['loss_skills']) )
2154 {
2155 throw new E_OTS_NotLoaded();
2156 }
2157
2158 return $this->data['loss_skills'];
2159 }
2160
2161/**
2162 * Sets percentage of skills lost after dead.
2163 *
2164 * <p>
2165 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
2166 * </p>
2167 *
2168 * @param int $loss_skills Percentage of skills lost after dead.
2169 */
2170 public function setLossSkills($loss_skills)
2171 {
2172 $this->data['loss_skills'] = (int) $loss_skills;
2173 }
2174
2175/**
2176 * Percentage of items lost after dead.
2177 *
2178 * @version 0.1.4
2179 * @since 0.1.4
2180 * @return int Percentage of items lost after dead.
2181 * @throws E_OTS_NotLoaded If player is not loaded.
2182 */
2183 public function getLossItems()
2184 {
2185 if( !isset($this->data['loss_items']) )
2186 {
2187 throw new E_OTS_NotLoaded();
2188 }
2189
2190 return $this->data['loss_items'];
2191 }
2192
2193/**
2194 * Sets percentage of items lost after dead.
2195 *
2196 * @version 0.1.4
2197 * @since 0.1.4
2198 * @param int $loss_items Percentage of items lost after dead.
2199 */
2200 public function setLossItems($loss_items)
2201 {
2202 $this->data['loss_items'] = (int) $loss_items;
2203 }
2204
2205 public function getLossContainers()
2206 {
2207 if( !isset($this->data['loss_containers']) )
2208 {
2209 throw new E_OTS_NotLoaded();
2210 }
2211
2212 return $this->data['loss_containers'];
2213 }
2214 public function setLossContainers($loss_containers)
2215 {
2216 $this->data['loss_containers'] = (int) $loss_containers;
2217 }
2218
2219 public function getBlessings()
2220 {
2221 if( !isset($this->data['blessings']) )
2222 {
2223 throw new E_OTS_NotLoaded();
2224 }
2225
2226 return $this->data['blessings'];
2227 }
2228
2229 public function setBlessings($blessings)
2230 {
2231 $this->data['blessings'] = (int) $blessings;
2232 }
2233
2234 public function countBlessings()
2235 {
2236 if( !isset($this->db) )
2237 {
2238 throw new E_OTS_NotLoaded();
2239 }
2240 for( $i = 8; $i >= 1; $i-- ) {
2241 if ($this->db->hasColumn('players', 'blessings' . $i)) {
2242 break;
2243 }
2244 }
2245 return $i;
2246 }
2247
2248 public function checkBlessings($count)
2249 {
2250 if( !isset($this->data['id']) )
2251 {
2252 throw new E_OTS_NotLoaded();
2253 }
2254
2255 $fields = array();
2256 for( $i = 1; $i <= $count; $i++ ) {
2257 $fields[] = 'blessings'.$i;
2258 }
2259
2260 $value = $this->db->query('SELECT '. implode(', ', $fields) .' FROM ' . $this->db->tableName('players') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id'])->fetch();
2261 return $value;
2262 }
2263
2264 public function getStamina()
2265 {
2266 if( !isset($this->data['stamina']) )
2267 {
2268 throw new E_OTS_NotLoaded();
2269 }
2270
2271 return $this->data['stamina'];
2272 }
2273
2274 public function setStamina($stamina)
2275 {
2276 $this->data['stamina'] = (int) $stamina;
2277 }
2278/**
2279 * Bank balance.
2280 *
2281 * @version 0.1.2
2282 * @since 0.1.2
2283 * @return int Amount of money stored in bank.
2284 * @throws E_OTS_NotLoaded If player is not loaded.
2285 */
2286 public function getBalance()
2287 {
2288 if( !isset($this->data['balance']) )
2289 {
2290 throw new E_OTS_NotLoaded();
2291 }
2292
2293 return $this->data['balance'];
2294 }
2295
2296/**
2297 * Sets bank balance value.
2298 *
2299 * <p>
2300 * This method only updates object state. To save changes in database you need to use {@link OTS_Player::save() save() method} to flush changed to database.
2301 * </p>
2302 *
2303 * @version 0.1.2
2304 * @since 0.1.2
2305 * @param int $balance Amount of money to be set in bank.
2306 */
2307 public function setBalance($balance)
2308 {
2309 $this->data['balance'] = (int) $balance;
2310 }
2311
2312 public function getWorldId()
2313 {
2314 if( !isset($this->data['world_id']) )
2315 {
2316 throw new E_OTS_NotLoaded();
2317 }
2318
2319 return $this->data['world_id'];
2320 }
2321 public function setWorldId($worldId)
2322 {
2323 $this->data['world_id'] = (int) $worldId;
2324 }
2325/**
2326 * Reads custom field.
2327 *
2328 * <p>
2329 * Reads field by it's name. Can read any field of given record that exists in database.
2330 * </p>
2331 *
2332 * <p>
2333 * Note: You should use this method only for fields that are not provided in standard setters/getters (SVN fields). This method runs SQL query each time you call it so it highly overloads used resources.
2334 * </p>
2335 *
2336 * @version 0.0.5
2337 * @since 0.0.3
2338 * @param string $field Field name.
2339 * @return string Field value.
2340 * @throws E_OTS_NotLoaded If player is not loaded.
2341 * @throws PDOException On PDO operation error.
2342 */
2343 public function getCustomField($field)
2344 {
2345 if( !isset($this->data['id']) )
2346 {
2347 throw new E_OTS_NotLoaded();
2348 }
2349
2350 $value = $this->db->query('SELECT ' . $this->db->fieldName($field) . ' FROM ' . $this->db->tableName('players') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id'])->fetch();
2351 return $value[$field];
2352 }
2353
2354/**
2355 * Writes custom field.
2356 *
2357 * <p>
2358 * Write field by it's name. Can write any field of given record that exists in database.
2359 * </p>
2360 *
2361 * <p>
2362 * Note: You should use this method only for fields that are not provided in standard setters/getters (SVN fields). This method runs SQL query each time you call it so it highly overloads used resources.
2363 * </p>
2364 *
2365 * <p>
2366 * Note: Make sure that you pass $value argument of correct type. This method determinates whether to quote field value. It is safe - it makes you sure that no unproper queries that could lead to SQL injection will be executed, but it can make your code working wrong way. For example: $object->setCustomField('foo', '1'); will quote 1 as as string ('1') instead of passing it as a integer.
2367 * </p>
2368 *
2369 * @version 0.0.5
2370 * @since 0.0.3
2371 * @param string $field Field name.
2372 * @param mixed $value Field value.
2373 * @throws E_OTS_NotLoaded If player is not loaded.
2374 * @throws PDOException On PDO operation error.
2375 */
2376 public function setCustomField($field, $value)
2377 {
2378 if( !isset($this->data['id']) )
2379 {
2380 throw new E_OTS_NotLoaded();
2381 }
2382
2383 // quotes value for SQL query
2384 if(!( is_int($value) || is_float($value) ))
2385 {
2386 $value = $this->db->quote($value);
2387 }
2388
2389 $this->db->query('UPDATE `players` SET `' . $field . '` = ' . $value . ' WHERE `id` = ' . $this->data['id']);
2390 }
2391
2392/**
2393 * Returns player's skill.
2394 *
2395 * @version 0.0.2
2396 * @since 0.0.2
2397 * @param int $skill Skill ID.
2398 * @return int Skill value.
2399 * @throws E_OTS_NotLoaded If player is not loaded.
2400 */
2401 public function getSkill($skill)
2402 {
2403 if( !isset($this->skills[$skill]) )
2404 {
2405 throw new E_OTS_NotLoaded();
2406 }
2407
2408 return $this->skills[$skill]['value'];
2409 }
2410
2411/**
2412 * Sets skill value.
2413 *
2414 * @version 0.0.2
2415 * @since 0.0.2
2416 * @param int $skill Skill ID.
2417 * @param int $value Skill value.
2418 */
2419 public function setSkill($skill, $value)
2420 {
2421 $skill_ids = array(
2422 'skill_fist' => POT::SKILL_FIST,
2423 'skill_club' => POT::SKILL_CLUB,
2424 'skill_sword' => POT::SKILL_SWORD,
2425 'skill_axe' => POT::SKILL_AXE,
2426 'skill_dist' => POT::SKILL_DIST,
2427 'skill_shielding' => POT::SKILL_SHIELD,
2428 'skill_fishing' => POT::SKILL_FISH
2429 );
2430 if(Validator::number($skill))
2431 $this->skills[ (int) $skill]['value'] = (int) $value;
2432 else {
2433 $this->skills[ (int) $skill_ids[$skill]]['value'] = (int) $value;
2434 }
2435 }
2436
2437/**
2438 * Returns player's skill's tries for next level.
2439 *
2440 * @version 0.0.2
2441 * @since 0.0.2
2442 * @param int $skill Skill ID.
2443 * @return int Skill tries.
2444 * @throws E_OTS_NotLoaded If player is not loaded.
2445 */
2446 public function getSkillTries($skill)
2447 {
2448 if( !isset($this->skills[$skill]) )
2449 {
2450 throw new E_OTS_NotLoaded();
2451 }
2452
2453 return $this->skills[$skill]['tries'];
2454 }
2455
2456/**
2457 * Sets skill's tries for next level.
2458 *
2459 * @version 0.0.2
2460 * @since 0.0.2
2461 * @param int $skill Skill ID.
2462 * @param int $tries Skill tries.
2463 */
2464 public function setSkillTries($skill, $tries)
2465 {
2466 $skill_ids = array(
2467 'skill_fist' => POT::SKILL_FIST,
2468 'skill_club' => POT::SKILL_CLUB,
2469 'skill_sword' => POT::SKILL_SWORD,
2470 'skill_axe' => POT::SKILL_AXE,
2471 'skill_dist' => POT::SKILL_DIST,
2472 'skill_shielding' => POT::SKILL_SHIELD,
2473 'skill_fishing' => POT::SKILL_FISH
2474 );
2475
2476 if(Validator::number($skill))
2477 $this->skills[ (int) $skill]['tries'] = (int) $tries;
2478 else {
2479 $this->skills[ (int) $skill_ids[$skill]]['tries'] = (int) $tries;
2480 }
2481 }
2482
2483/**
2484 * Returns value of storage record.
2485 *
2486 * @version 0.1.3
2487 * @since 0.1.2
2488 * @param int $key Storage key.
2489 * @return int|null Stored value (null if not set).
2490 * @throws E_OTS_NotLoaded If player is not loaded.
2491 * @throws PDOException On PDO operation error.
2492 */
2493 public function getStorage($key)
2494 {
2495 if( !isset($this->data['id']) )
2496 {
2497 throw new E_OTS_NotLoaded();
2498 }
2499
2500 $value = $this->db->query('SELECT ' . $this->db->fieldName('value') . ' FROM ' . $this->db->tableName('player_storage') . ' WHERE ' . $this->db->fieldName('key') . ' = ' . (int) $key . ' AND ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'])->fetch();
2501
2502 if($value !== false)
2503 {
2504 return null;
2505 }
2506
2507 return $value['value'];
2508 }
2509
2510/**
2511 * Sets value of storage record.
2512 *
2513 * @version 0.1.2
2514 * @since 0.1.2
2515 * @param int $key Storage key.
2516 * @param int $value Stored value.
2517 * @throws E_OTS_NotLoaded If player is not loaded.
2518 * @throws PDOException On PDO operation error.
2519 */
2520 public function setStorage($key, $value)
2521 {
2522 if( !isset($this->data['id']) )
2523 {
2524 throw new E_OTS_NotLoaded();
2525 }
2526
2527 $current = $this->getStorage($key);
2528
2529 // checks if there is any row to be updates
2530 if( isset($current) )
2531 {
2532 $this->db->query('UPDATE ' . $this->db->tableName('player_storage') . ' SET ' . $this->db->fieldName('value') . ' = ' . (int) $value . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('key') . ' = ' . (int) $key);
2533 }
2534 // inserts new storage record
2535 else
2536 {
2537 $this->db->query('INSERT INTO ' . $this->db->tableName('player_storage') . ' (' . $this->db->fieldName('player_id') . ', ' . $this->db->fieldName('key') . ', ' . $this->db->fieldName('value') . ') VALUES (' . $this->data['id'] . ', ' . (int) $key . ', ' . (int) $value . ')');
2538 }
2539 }
2540
2541/**
2542 * Deletes item with contained items.
2543 *
2544 * @version 0.0.5
2545 * @since 0.0.3
2546 * @param int $sid Item unique player's ID.
2547 * @throws PDOException On PDO operation error.
2548 */
2549 private function deleteItem($sid)
2550 {
2551 // deletes all sub-items
2552 foreach( $this->db->query('SELECT ' . $this->db->fieldName('sid') . ' FROM ' . $this->db->tableName('player_items') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('pid') . ' = ' . $sid)->fetchAll() as $item)
2553 {
2554 $this->deleteItem($item['sid']);
2555 }
2556
2557 // deletes item
2558 $this->db->query('DELETE FROM ' . $this->db->tableName('player_items') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('sid') . ' = ' . $sid);
2559 }
2560
2561/**
2562 * Returns items tree from given slot.
2563 *
2564 * <p>
2565 * You need global items list resources loaded in order to use this method.
2566 * </p>
2567 *
2568 * @version 0.1.2
2569 * @since 0.0.3
2570 * @param int $slot Slot to get items.
2571 * @return OTS_Item|null Item in given slot (items tree if in given slot there is a container). If there is no item in slot then null value will be returned.
2572 * @throws E_OTS_NotLoaded If player is not loaded or there is no global items list resource loaded.
2573 * @throws E_OTS_NotAContainer If item which is not of type container contains sub items.
2574 * @throws PDOException On PDO operation error.
2575 */
2576 public function getSlot($slot)
2577 {
2578 if( !isset($this->data['id']) )
2579 {
2580 throw new E_OTS_NotLoaded();
2581 }
2582
2583 // loads current item
2584 $item = $this->db->query('SELECT ' . $this->db->fieldName('itemtype') . ', ' . $this->db->fieldName('sid') . ', ' . $this->db->fieldName('count') . ', ' . $this->db->fieldName('attributes') . ' FROM ' . $this->db->tableName('player_items') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName($slot > POT::SLOT_AMMO ? 'sid' : 'pid') . ' = ' . (int) $slot)->fetch();
2585
2586 if( empty($item) )
2587 {
2588 return null;
2589 }
2590
2591 // checks if there are any items under current one
2592 $items = array();
2593 foreach( $this->db->query('SELECT ' . $this->db->fieldName('sid') . ' FROM ' . $this->db->tableName('player_items') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('pid') . ' = ' . $item['sid'])->fetchAll() as $sub)
2594 {
2595 $items[] = $this->getSlot($sub['sid']);
2596 }
2597
2598 // item type
2599 $slot = POT::getInstance()->getItemsList()->getItemType($item['itemtype'])->createItem();
2600 $slot->setCount($item['count']);
2601 $slot->setAttributes($item['attributes']);
2602
2603 // checks if current item has any contained items
2604 if( !empty($items) )
2605 {
2606 // checks if item is realy a container
2607 if(!$slot instanceof OTS_Container)
2608 {
2609 throw new E_OTS_NotAContainer();
2610 }
2611
2612 // puts items into container
2613 foreach($items as $sub)
2614 {
2615 $slot->addItem($sub);
2616 }
2617 }
2618
2619 return $slot;
2620 }
2621
2622/**
2623 * Sets slot content.
2624 *
2625 * @version 0.1.2
2626 * @since 0.0.3
2627 * @param int $slot Slot to save items.
2628 * @param OTS_Item $item Item (can be a container with content) for given slot. Leave this parameter blank to clear slot.
2629 * @param int $pid Deprecated, not used anymore.
2630 * @throws E_OTS_NotLoaded If player is not loaded.
2631 * @throws PDOException On PDO operation error.
2632 */
2633 public function setSlot($slot, OTS_Item $item = null, $pid = 0)
2634 {
2635 static $sid;
2636
2637 if( !isset($this->data['id']) )
2638 {
2639 throw new E_OTS_NotLoaded();
2640 }
2641
2642 // clears current slot
2643 if($slot <= POT::SLOT_AMMO)
2644 {
2645 $id = $this->db->query('SELECT ' . $this->db->fieldName('sid') . ' FROM ' . $this->db->tableName('player_items') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('pid') . ' = ' . (int) $slot)->fetch();
2646 $this->deleteItem( (int) $id['sid']);
2647 }
2648
2649 // checks if there is any item to insert
2650 if( isset($item) )
2651 {
2652 // current maximum sid (over slot sids)
2653 if( !isset($sid) )
2654 {
2655 $sid = $this->db->query('SELECT MAX(' . $this->db->fieldName('sid') . ') AS `sid` FROM ' . $this->db->tableName('player_items') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'])->fetch();
2656 $sid = $sid['sid'] > POT::SLOT_AMMO ? $sid['sid'] : POT::SLOT_AMMO;
2657 }
2658
2659 $sid++;
2660
2661 // inserts given item
2662 $this->db->query('INSERT INTO ' . $this->db->tableName('player_items') . ' (' . $this->db->fieldName('player_id') . ', ' . $this->db->fieldName('sid') . ', ' . $this->db->fieldName('pid') . ', ' . $this->db->fieldName('itemtype') . ', ' . $this->db->fieldName('count') . ', ' . $this->db->fieldName('attributes') . ') VALUES (' . $this->data['id'] . ', ' . $sid . ', ' . (int) $slot . ', ' . $item->getId() . ', ' . $item->getCount() . ', ' . $this->db->quote( $item->getAttributes() ) . ')');
2663
2664 // checks if this is container
2665 if($item instanceof OTS_Container)
2666 {
2667 $pid = $sid;
2668
2669 // inserts all contained items
2670 foreach($item as $sub)
2671 {
2672 $this->setSlot($pid, $sub);
2673 }
2674 }
2675 }
2676
2677 // clears $sid for next public call
2678 if($slot <= POT::SLOT_AMMO)
2679 {
2680 $sid = null;
2681 }
2682 }
2683
2684/**
2685 * Deletes depot item with contained items.
2686 *
2687 * @version 0.0.5
2688 * @since 0.0.3
2689 * @param int $sid Depot item unique player's ID.
2690 * @throws PDOException On PDO operation error.
2691 */
2692 private function deleteDepot($sid)
2693 {
2694 // deletes all sub-items
2695 foreach( $this->db->query('SELECT ' . $this->db->fieldName('sid') . ' FROM ' . $this->db->tableName('player_depotitems') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('pid') . ' = ' . $sid)->fetchAll() as $item)
2696 {
2697 $this->deleteDepot($item['sid']);
2698 }
2699
2700 // deletes item
2701 $this->db->query('DELETE FROM ' . $this->db->tableName('player_depotitems') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('sid') . ' = ' . $sid);
2702 }
2703
2704/**
2705 * Returns items tree from given depot.
2706 *
2707 * <p>
2708 * You need global items list resources loaded in order to use this method.
2709 * </p>
2710 *
2711 * @version 0.1.2
2712 * @since 0.0.3
2713 * @param int $depot Depot ID to get items.
2714 * @return OTS_Item|null Item in given depot (items tree if in given depot there is a container). If there is no item in depot then null value will be returned.
2715 * @throws E_OTS_NotLoaded If player is not loaded or there is no global items list resource loaded.
2716 * @throws E_OTS_NotAContainer If item which is not of type container contains sub items.
2717 * @throws PDOException On PDO operation error.
2718 */
2719 public function getDepot($depot)
2720 {
2721 if( !isset($this->data['id']) )
2722 {
2723 throw new E_OTS_NotLoaded();
2724 }
2725
2726 // loads current item
2727 $item = $this->db->query('SELECT ' . $this->db->fieldName('itemtype') . ', ' . $this->db->fieldName('sid') . ', ' . $this->db->fieldName('count') . ', ' . $this->db->fieldName('attributes') . ' FROM ' . $this->db->tableName('player_depotitems') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName($depot > POT::DEPOT_SID_FIRST ? 'sid' : 'pid') . ' = ' . (int) $depot)->fetch();
2728
2729 if( empty($item) )
2730 {
2731 return null;
2732 }
2733
2734 // checks if there are any items under current one
2735 $items = array();
2736 foreach( $this->db->query('SELECT ' . $this->db->fieldName('sid') . ' FROM ' . $this->db->tableName('player_depotitems') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('pid') . ' = ' . $item['sid'])->fetchAll() as $sub)
2737 {
2738 $items[] = $this->getDepot($sub['sid']);
2739 }
2740
2741 // item type
2742 $depot = POT::getInstance()->getItemsList()->getItemType($item['itemtype'])->createItem();
2743 $depot->setCount($item['count']);
2744 $depot->setAttributes($item['attributes']);
2745
2746 // checks if current item has any contained items
2747 if( !empty($items) )
2748 {
2749 // checks if item is realy a container
2750 if(!$depot instanceof OTS_Container)
2751 {
2752 throw new E_OTS_NotAContainer();
2753 }
2754
2755 // puts items into container
2756 foreach($items as $sub)
2757 {
2758 $depot->addItem($sub);
2759 }
2760 }
2761
2762 return $depot;
2763 }
2764
2765/**
2766 * Sets depot content.
2767 *
2768 * @version 0.1.2
2769 * @since 0.0.3
2770 * @param int $depot Depot ID to save items.
2771 * @param OTS_Item $item Item (can be a container with content) for given depot. Leave this parameter blank to clear depot.
2772 * @param int $pid Deprecated, not used anymore.
2773 * @param int $depot_id Internal, for further use.
2774 * @throws E_OTS_NotLoaded If player is not loaded.
2775 * @throws PDOException On PDO operation error.
2776 */
2777 public function setDepot($depot, OTS_Item $item = null, $pid = 0, $depot_id = 0)
2778 {
2779 static $sid;
2780
2781 // if no depot_id is specified then it is same as depot slot
2782 if($depot_id == 0)
2783 {
2784 $depot_id = $depot;
2785 }
2786
2787 if( !isset($this->data['id']) )
2788 {
2789 throw new E_OTS_NotLoaded();
2790 }
2791
2792 // clears current depot
2793 if($depot <= POT::DEPOT_SID_FIRST)
2794 {
2795 $id = $this->db->query('SELECT ' . $this->db->fieldName('sid') . ' FROM ' . $this->db->tableName('player_depotitems') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('pid') . ' = ' . (int) $depot)->fetch();
2796 $this->deleteDepot( (int) $id['sid']);
2797 }
2798
2799 // checks if there is any item to insert
2800 if( isset($item) )
2801 {
2802 // current maximum sid (over depot sids)
2803 if( !isset($sid) )
2804 {
2805 $sid = $this->db->query('SELECT MAX(' . $this->db->fieldName('sid') . ') AS `sid` FROM ' . $this->db->tableName('player_depotitems') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'])->fetch();
2806 $sid = $sid['sid'] > POT::DEPOT_SID_FIRST ? $sid['sid'] : POT::DEPOT_SID_FIRST;
2807 }
2808
2809 $sid++;
2810
2811 // inserts given item
2812 $this->db->query('INSERT INTO ' . $this->db->tableName('player_depotitems') . ' (' . $this->db->fieldName('player_id') . ', ' . $this->db->fieldName('depot_id') . ', ' . $this->db->fieldName('sid') . ', ' . $this->db->fieldName('pid') . ', ' . $this->db->fieldName('itemtype') . ', ' . $this->db->fieldName('count') . ', ' . $this->db->fieldName('attributes') . ') VALUES (' . $this->data['id'] . ', ' . $depot_id . ', ' . $sid . ', ' . (int) $depot . ', ' . $item->getId() . ', ' . $item->getCount() . ', ' . $this->db->quote( $item->getAttributes() ) . ')');
2813
2814 // checks if this is container
2815 if($item instanceof OTS_Container)
2816 {
2817 $pid = $sid;
2818
2819 // inserts all contained items
2820 foreach($item as $sub)
2821 {
2822 $this->setDepot($pid, $sub, 0, $depot_id);
2823 }
2824 }
2825 }
2826
2827 // clears $sid for next public call
2828 if($depot <= POT::DEPOT_SID_FIRST)
2829 {
2830 $sid = null;
2831 }
2832 }
2833
2834/**
2835 * @version 0.1.5
2836 * @since 0.0.5
2837 * @param int $time Time for time until expires (0 - forever).
2838 * @throws PDOException On PDO operation error.
2839 * @deprecated 0.1.5 Use OTS_PlayerBan class.
2840 */
2841 public function ban($time = 0)
2842 {
2843 // can't ban nothing
2844 if( !$this->isLoaded() )
2845 {
2846 throw new E_OTS_NotLoaded();
2847 }
2848
2849 // creates ban entry
2850 $ban = new OTS_PlayerBan();
2851 $ban->setValue($this->data['id']);
2852 $ban->setExpires($time);
2853 $ban->setAdded( time() );
2854 $ban->activate();
2855 $ban->save();
2856 }
2857
2858/**
2859 * @version 0.1.5
2860 * @since 0.0.5
2861 * @throws PDOException On PDO operation error.
2862 * @deprecated 0.1.5 Use OTS_PlayerBan class.
2863 */
2864 public function unban()
2865 {
2866 // can't unban nothing
2867 if( !$this->isLoaded() )
2868 {
2869 throw new E_OTS_NotLoaded();
2870 }
2871
2872 // deletes ban entry
2873 $ban = new OTS_PlayerBan();
2874 $ban->find($this->data['id']);
2875 $ban->delete();
2876 }
2877
2878/**
2879 * @version 0.1.5
2880 * @since 0.0.5
2881 * @return bool True if player is banned, false otherwise.
2882 * @throws PDOException On PDO operation error.
2883 * @deprecated 0.1.5 Use OTS_PlayerBan class.
2884 */
2885 public function isBanned()
2886 {
2887 // nothing can't be banned
2888 if( !$this->isLoaded() )
2889 {
2890 throw new E_OTS_NotLoaded();
2891 }
2892 if( !isset($this->data['banned']) )
2893 $this->loadBan();
2894 return ($this->data['banned'] == 1);
2895 }
2896
2897 public function getBanTime()
2898 {
2899 // nothing can't be banned
2900 if( !$this->isLoaded() )
2901 {
2902 throw new E_OTS_NotLoaded();
2903 }
2904 if( !isset($this->data['banned_time']) )
2905 $this->loadBan();
2906 return $this->data['banned_time'];
2907 }
2908
2909 public function loadBan()
2910 {
2911 // nothing can't be banned
2912 if( !$this->isLoaded() )
2913 {
2914 throw new E_OTS_NotLoaded();
2915 }
2916 $ban = $this->db->query('SELECT ' . $this->db->fieldName('active') . ', ' . $this->db->fieldName('expires') . ' FROM ' . $this->db->tableName('bans') . ' WHERE (' . $this->db->fieldName('type') . ' = 3 OR ' . $this->db->fieldName('type') . ' = 5) AND ' . $this->db->fieldName('active') . ' = 1 AND ' . $this->db->fieldName('value') . ' = ' . $this->data['account_id'] . ' AND (' . $this->db->fieldName('expires') . ' > ' . time() .' OR ' . $this->db->fieldName('expires') . ' = -1)')->fetch();
2917 $this->data['banned'] = $ban['active'];
2918 $this->data['banned_time'] = $ban['expires'];
2919 }
2920/**
2921 * Deletes player.
2922 *
2923 * @version 0.0.5
2924 * @since 0.0.5
2925 * @throws E_OTS_NotLoaded If player is not loaded.
2926 * @throws PDOException On PDO operation error.
2927 */
2928 public function delete()
2929 {
2930 if( !isset($this->data['id']) )
2931 {
2932 throw new E_OTS_NotLoaded();
2933 }
2934
2935 // deletes row from database
2936 $this->db->query('UPDATE ' . $this->db->tableName('players') . ' SET ' . $this->db->fieldName('deleted') . ' = 1 WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
2937
2938 // resets object handle
2939 unset($this->data['id']);
2940 }
2941
2942/**
2943 * Player proffesion name.
2944 *
2945 * <p>
2946 * You need global vocations list resource loaded in order to use this method.
2947 * </p>
2948 *
2949 * @version 0.1.0
2950 * @since 0.0.6
2951 * @return string Player proffesion name.
2952 * @throws E_OTS_NotLoaded If player is not loaded or global vocations list is not loaded.
2953 */
2954 public function getVocationName()
2955 {
2956 if( !isset($this->data['vocation']) )
2957 {
2958 throw new E_OTS_NotLoaded();
2959 }
2960
2961 global $config;
2962 $voc = $this->getVocation();
2963 if(!isset($config['vocations'][$voc])) {
2964 return 'Unknown';
2965 }
2966
2967 return $config['vocations'][$voc];
2968 //return POT::getInstance()->getVocationsList()->getVocationName($this->data['vocation']);
2969 }
2970
2971/**
2972 * Player residence town name.
2973 *
2974 * <p>
2975 * You need global map resource loaded in order to use this method.
2976 * </p>
2977 *
2978 * @version 0.1.0
2979 * @since 0.1.0
2980 * @return string Player town name.
2981 * @throws E_OTS_NotLoaded If player is not loaded or global map is not loaded.
2982 */
2983 public function getTownName()
2984 {
2985 if( !isset($this->data['town_id']) )
2986 {
2987 throw new E_OTS_NotLoaded();
2988 }
2989
2990 return POT::getInstance()->getMap()->getTownName($this->data['town_id']);
2991 }
2992
2993/**
2994 * Returns house rented by this player.
2995 *
2996 * <p>
2997 * You need global houses list resource loaded in order to use this method.
2998 * </p>
2999 *
3000 * @version 0.1.0
3001 * @since 0.1.0
3002 * @return OTS_House|null House rented by player.
3003 * @throws E_OTS_NotLoaded If player is not loaded or global houses list is not loaded.
3004 * @throws PDOException On PDO operation error.
3005 */
3006 public function getHouse()
3007 {
3008 if( !isset($this->data['id']) )
3009 {
3010 throw new E_OTS_NotLoaded();
3011 }
3012
3013 // SELECT query on database
3014 $house = $this->db->query('SELECT ' . $this->db->fieldName('id') . ' FROM ' . $this->db->tableName('houses') . ' WHERE ' . $this->db->fieldName('owner') . ' = ' . $this->data['id'])->fetch();
3015
3016 if( !empty($house) )
3017 {
3018 return POT::getInstance()->getHousesList()->getHouse($house['id']);
3019 }
3020
3021 return null;
3022 }
3023
3024/**
3025 * Returns list of VIPs.
3026 *
3027 * <p>
3028 * It means list of players which this player have on his/her list.
3029 * </p>
3030 *
3031 * @version 0.1.3
3032 * @since 0.1.3
3033 * @return OTS_Players_List List of VIPs.
3034 * @throws E_OTS_NotLoaded If player is not loaded.
3035 * @throws PDOException On PDO operation error.
3036 */
3037 public function getVIPsList()
3038 {
3039 if( !isset($this->data['id']) )
3040 {
3041 throw new E_OTS_NotLoaded();
3042 }
3043
3044 $list = new OTS_Players_List();
3045
3046 // foreign table fields identifiers
3047 $field1 = new OTS_SQLField('player_id', 'player_viplist');
3048 $field2 = new OTS_SQLField('vip_id', 'player_viplist');
3049
3050 // creates filter
3051 $filter = new OTS_SQLFilter();
3052 $filter->addFilter($field1, $this->data['id']);
3053 $filter->compareField('id', $field2);
3054
3055 // puts filter onto list
3056 $list->setFilter($filter);
3057
3058 return $list;
3059 }
3060
3061/**
3062 * Adds player to VIP list.
3063 *
3064 * @version 0.1.4
3065 * @since 0.1.3
3066 * @param OTS_Player $player Player to be added.
3067 * @throws E_OTS_NotLoaded If player is not loaded.
3068 * @throws PDOException On PDO operation error.
3069 */
3070 public function addVIP(OTS_Player $player)
3071 {
3072 if( !isset($this->data['id']) )
3073 {
3074 throw new E_OTS_NotLoaded();
3075 }
3076
3077 $this->db->query('INSERT INTO ' . $this->db->tableName('player_viplist') . ' (' . $this->db->fieldName('player_id') . ', ' . $this->db->fieldName('vip_id') . ') VALUES (' . $this->data['id'] . ', ' . $player->getId() . ')');
3078 }
3079
3080/**
3081 * Checks if given player is a VIP for current one.
3082 *
3083 * @version 0.1.5
3084 * @since 0.1.3
3085 * @param OTS_Player $player Player to check.
3086 * @return bool True, if given player is on VIP list.
3087 * @throws E_OTS_NotLoaded If player is not loaded.
3088 * @throws PDOException On PDO operation error.
3089 */
3090 public function isVIP(OTS_Player $player)
3091 {
3092 if( !isset($this->data['id']) )
3093 {
3094 throw new E_OTS_NotLoaded();
3095 }
3096
3097 return $this->db->query('SELECT COUNT(' . $this->db->fieldName('vip_id') . ') FROM ' . $this->db->tableName('player_viplist') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('vip_id') . ' = ' . $player->getId() )->fetchColumn() > 0;
3098 }
3099
3100/**
3101 * Deletes player from VIP list.
3102 *
3103 * @version 0.1.4
3104 * @since 0.1.3
3105 * @param OTS_Player $player Player to be deleted.
3106 * @throws E_OTS_NotLoaded If player is not loaded.
3107 * @throws PDOException On PDO operation error.
3108 */
3109 public function deleteVIP(OTS_Player $player)
3110 {
3111 if( !isset($this->data['id']) )
3112 {
3113 throw new E_OTS_NotLoaded();
3114 }
3115
3116 $this->db->query('DELETE FROM ' . $this->db->tableName('player_viplist') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('vip_id') . ' = ' . $player->getId() );
3117 }
3118
3119/**
3120 * Returns list of known spells.
3121 *
3122 * <p>
3123 * You need global spells list resource loaded in order to use this method.
3124 * </p>
3125 *
3126 * @version 0.1.4
3127 * @since 0.1.4
3128 * @return array List of known spells.
3129 * @throws E_OTS_NotLoaded If player is not loaded.
3130 * @throws PDOException On PDO operation error.
3131 */
3132 public function getSpellsList()
3133 {
3134 if( !isset($this->data['id']) )
3135 {
3136 throw new E_OTS_NotLoaded();
3137 }
3138
3139 $spells = array();
3140 $list = POT::getInstance()->getSpellsList();
3141
3142 // reads all known spells
3143 foreach( $this->db->query('SELECT ' . $this->db->fieldName('name') . ' FROM ' . $this->db->tableName('player_spells') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id']) as $spell)
3144 {
3145 // checks if there is rune, instant or conjure spell with given name
3146
3147 if( $list->hasRune($spell['name']) )
3148 {
3149 $spells[] = $list->getRune($spell['name']);
3150 }
3151
3152 if( $list->hasInstance($spell['name']) )
3153 {
3154 $spells[] = $list->getInstance($spell['name']);
3155 }
3156
3157 if( $list->hasConjure($spell['name']) )
3158 {
3159 $spells[] = $list->getConjure($spell['name']);
3160 }
3161 }
3162
3163 return $spells;
3164 }
3165
3166/**
3167 * Checks if player knows given spell.
3168 *
3169 * @version 0.1.5
3170 * @since 0.1.4
3171 * @param OTS_Spell $spell Spell to be checked.
3172 * @return bool True if player knows given spell, false otherwise.
3173 * @throws E_OTS_NotLoaded If player is not loaded.
3174 * @throws PDOException On PDO operation error.
3175 */
3176 public function hasSpell(OTS_Spell $spell)
3177 {
3178 if( !isset($this->data['id']) )
3179 {
3180 throw new E_OTS_NotLoaded();
3181 }
3182
3183 return $this->db->query('SELECT COUNT(' . $this->db->fieldName('name') . ') FROM ' . $this->db->tableName('player_spells') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('name') . ' = ' . $this->db->quote( $spell->getName() ) )->fetchColumn() > 0;
3184 }
3185
3186/**
3187 * Adds given spell to player's spell book (makes him knowing it).
3188 *
3189 * @version 0.1.4
3190 * @since 0.1.4
3191 * @param OTS_Spell $spell Spell to be learned.
3192 * @throws E_OTS_NotLoaded If player is not loaded.
3193 * @throws PDOException On PDO operation error.
3194 */
3195 public function addSpell(OTS_Spell $spell)
3196 {
3197 if( !isset($this->data['id']) )
3198 {
3199 throw new E_OTS_NotLoaded();
3200 }
3201
3202 $this->db->query('INSERT INTO ' . $this->db->tableName('player_spells') . ' (' . $this->db->fieldName('player_id') . ', ' . $this->db->fieldName('name') . ') VALUES (' . $this->data['id'] . ', ' . $this->db->quote( $spell->getName() ) . ')');
3203 }
3204
3205/**
3206 * Removes given spell from player's spell book.
3207 *
3208 * @version 0.1.4
3209 * @since 0.1.4
3210 * @param OTS_Spell $spell Spell to be removed.
3211 * @throws E_OTS_NotLoaded If player is not loaded.
3212 * @throws PDOException On PDO operation error.
3213 */
3214 public function deleteSpell(OTS_Spell $spell)
3215 {
3216 if( !isset($this->data['id']) )
3217 {
3218 throw new E_OTS_NotLoaded();
3219 }
3220
3221 $this->db->query('DELETE FROM ' . $this->db->tableName('player_spells') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('name') . ' = ' . $this->db->quote( $spell->getName() ) );
3222 }
3223
3224 public static function getPercentLevel($count, $nextLevelCount)
3225 {
3226 if($nextLevelCount > 0)
3227 return min(100, max(0, $count * 100 / $nextLevelCount));
3228
3229 return 0;
3230 }
3231
3232/**
3233 * Magic PHP5 method.
3234 *
3235 * @version 0.1.5
3236 * @since 0.1.0
3237 * @param string $name Property name.
3238 * @return mixed Property value.
3239 * @throws E_OTS_NotLoaded When player is not loaded.
3240 * @throws OutOfBoundsException For non-supported properties.
3241 * @throws PDOException On PDO operation error.
3242 */
3243 public function __get($name)
3244 {
3245 switch($name)
3246 {
3247 case 'id':
3248 return $this->getId();
3249
3250 case 'name':
3251 return $this->getName();
3252
3253 case 'account':
3254 return $this->getAccount();
3255
3256 case 'group':
3257 return $this->getGroup();
3258
3259 case 'sex':
3260 return $this->getSex();
3261
3262 case 'vocation':
3263 return $this->getVocation();
3264
3265 case 'experience':
3266 return $this->getExperience();
3267
3268 case 'level':
3269 return $this->getLevel();
3270
3271 case 'magLevel':
3272 return $this->getMagLevel();
3273
3274 case 'health':
3275 return $this->getHealth();
3276
3277 case 'healthMax':
3278 return $this->getHealthMax();
3279
3280 case 'mana':
3281 return $this->getMana();
3282
3283 case 'manaMax':
3284 return $this->getManaMax();
3285
3286 case 'manaSpent':
3287 return $this->getManaSpent();
3288
3289 case 'soul':
3290 return $this->getSoul();
3291
3292 case 'direction':
3293 return $this->getDirection();
3294
3295 case 'lookBody':
3296 return $this->getLookBody();
3297
3298 case 'lookFeet':
3299 return $this->getLookFeet();
3300
3301 case 'lookHead':
3302 return $this->getLookHead();
3303
3304 case 'lookLegs':
3305 return $this->getLookLegs();
3306
3307 case 'lookType':
3308 return $this->getLookType();
3309
3310 case 'lookAddons':
3311 return $this->getLookAddons();
3312
3313 case 'posX':
3314 return $this->getPosX();
3315
3316 case 'posY':
3317 return $this->getPosY();
3318
3319 case 'posZ':
3320 return $this->getPosZ();
3321
3322 case 'cap':
3323 return $this->getCap();
3324
3325 case 'lastLogin':
3326 return $this->getLastLogin();
3327
3328 case 'lastLogout':
3329 return $this->getLastLogout();
3330
3331 case 'lastIP':
3332 return $this->getLastIP();
3333
3334 case 'save':
3335 return $this->isSaveSet();
3336
3337 case 'conditions':
3338 return $this->getConditions();
3339
3340 case 'skullTime':
3341 return $this->getRedSkullTime();
3342
3343 case 'skull':
3344 return $this->getSkull();
3345
3346 case 'guildNick':
3347 return $this->getGuildNick();
3348
3349 case 'rank':
3350 return $this->getRank();
3351
3352 case 'townId':
3353 return $this->getTownId();
3354
3355 case 'townName':
3356 return $this->getTownName();
3357
3358 case 'house':
3359 return $this->getHouse();
3360
3361 case 'lossExperience':
3362 return $this->getLossExperience();
3363
3364 case 'lossMana':
3365 return $this->getLossMana();
3366
3367 case 'lossSkills':
3368 return $this->getLossSkills();
3369
3370 case 'lossItems':
3371 return $this->getLossItems();
3372
3373 case 'lossContainers':
3374 return $this->getLossContainers();
3375
3376 case 'balance':
3377 return $this->getBalance();
3378
3379 case 'loaded':
3380 return $this->isLoaded();
3381
3382 case 'banned':
3383 return $this->isBanned();
3384
3385 case 'online':
3386 return $this->isOnline();
3387
3388 case 'worldId':
3389 return $this->getWorldId();
3390
3391
3392 case 'vipsList':
3393 return $this->getVIPsList();
3394
3395 case 'vocationName':
3396 return $this->getVocationName();
3397
3398 case 'spellsList':
3399 return $this->getSpellsList();
3400
3401 default:
3402 throw new OutOfBoundsException();
3403 }
3404 }
3405
3406/**
3407 * Magic PHP5 method.
3408 *
3409 * @version 0.1.5
3410 * @since 0.1.0
3411 * @param string $name Property name.
3412 * @param mixed $value Property value.
3413 * @throws E_OTS_NotLoaded When passing object value which represents not-initialised instance.
3414 * @throws OutOfBoundsException For non-supported properties.
3415 */
3416 public function __set($name, $value)
3417 {
3418 switch($name)
3419 {
3420 case 'name':
3421 $this->setName($value);
3422 break;
3423
3424 case 'account':
3425 $this->setAccount($value);
3426 break;
3427
3428 case 'group':
3429 $this->setGroup($value);
3430 break;
3431
3432 case 'sex':
3433 $this->setSex($value);
3434 break;
3435
3436 case 'vocation':
3437 $this->setVocation($value);
3438 break;
3439
3440 case 'experience':
3441 $this->setExperience($value);
3442 break;
3443
3444 case 'level':
3445 $this->setLevel($value);
3446 break;
3447
3448 case 'magLevel':
3449 $this->setMagLevel($value);
3450 break;
3451
3452 case 'health':
3453 $this->setHealth($value);
3454 break;
3455
3456 case 'healthMax':
3457 $this->setHealthMax($value);
3458 break;
3459
3460 case 'mana':
3461 $this->setMana($value);
3462 break;
3463
3464 case 'manaMax':
3465 $this->setManaMax($value);
3466 break;
3467
3468 case 'manaSpent':
3469 $this->setManaSpent($value);
3470 break;
3471
3472 case 'soul':
3473 $this->setSoul($value);
3474 break;
3475
3476 case 'direction':
3477 $this->setDirection($value);
3478 break;
3479
3480 case 'lookBody':
3481 $this->setLookBody($value);
3482 break;
3483
3484 case 'lookFeet':
3485 $this->setLookFeet($value);
3486 break;
3487
3488 case 'lookHead':
3489 $this->setLookHead($value);
3490 break;
3491
3492 case 'lookLegs':
3493 $this->setLookLegs($value);
3494 break;
3495
3496 case 'lookType':
3497 $this->setLookType($value);
3498 break;
3499
3500 case 'lookAddons':
3501 $this->setLookAddons($value);
3502 break;
3503
3504 case 'posX':
3505 $this->setPosX($value);
3506 break;
3507
3508 case 'posY':
3509 $this->setPosY($value);
3510 break;
3511
3512 case 'posZ':
3513 $this->setPosZ($value);
3514 break;
3515
3516 case 'cap':
3517 $this->setCap($value);
3518 break;
3519
3520 case 'lastLogin':
3521 $this->setLastLogin($value);
3522 break;
3523
3524 case 'lastLogout':
3525 $this->setLastLogout($value);
3526 break;
3527
3528 case 'lastIP':
3529 $this->setLastIP($value);
3530 break;
3531
3532 case 'conditions':
3533 $this->setConditions($value);
3534 break;
3535
3536 case 'skull':
3537 $this->setSkull($value);
3538 break;
3539
3540 case 'skullTime':
3541 $this->setSkullTime($value);
3542 break;
3543
3544 case 'guildNick':
3545 $this->setGuildNick($value);
3546 break;
3547
3548 case 'rank':
3549 $this->setRank($value);
3550 break;
3551
3552 case 'townId':
3553 $this->setTownId($value);
3554 break;
3555
3556 case 'lossExperience':
3557 $this->setLossExperience($value);
3558 break;
3559
3560 case 'lossMana':
3561 $this->setLossMana($value);
3562 break;
3563
3564 case 'lossSkills':
3565 $this->setLossSkills($value);
3566 break;
3567
3568 case 'lossItems':
3569 $this->setLossItems($value);
3570 break;
3571
3572 case 'balance':
3573 $this->setBalance($value);
3574 break;
3575
3576 case 'skull':
3577 if($value)
3578 {
3579 $this->setRedSkull();
3580 }
3581 else
3582 {
3583 $this->unsetRedSkull();
3584 }
3585 break;
3586
3587 case 'save':
3588 if($value)
3589 {
3590 $this->setSave();
3591 }
3592 else
3593 {
3594 $this->unsetSave();
3595 }
3596 break;
3597
3598 case 'banned':
3599 if($value)
3600 {
3601 $this->ban();
3602 }
3603 else
3604 {
3605 $this->unban();
3606 }
3607 break;
3608
3609 default:
3610 throw new OutOfBoundsException();
3611 }
3612 }
3613
3614/**
3615 * Returns string representation of object.
3616 *
3617 * <p>
3618 * If any display driver is currently loaded then it uses it's method. Else it returns character name.
3619 * </p>
3620 *
3621 * @version 0.1.3
3622 * @since 0.1.0
3623 * @return string String representation of object.
3624 */
3625 public function __toString()
3626 {
3627 $ots = POT::getInstance();
3628
3629 // checks if display driver is loaded
3630 if( $ots->isDisplayDriverLoaded() )
3631 {
3632 return $ots->getDisplayDriver()->displayPlayer($this);
3633 }
3634
3635 return $this->getName();
3636 }
3637}
3638
3639/**#@-*/
3640
3641?>