15
15
16
16
/**
17
17
* Wrapper for monsters files DOMDocument.
18
- *
18
+ *
19
19
* <p>
20
20
* Note: as this class extends {@link http://www.php.net/manual/en/ref.dom.php DOMDocument class} and contains exacly file XML tree you can work on it as on normal DOM tree.
21
21
* </p>
22
- *
22
+ *
23
23
* @package POT
24
24
* @version 0.1.3
25
25
* @property-read string $name Monster name.
@@ -44,14 +44,14 @@ public function loadXML($source , $options = 0)
44
44
{
45
45
$ this ->loaded = parent ::loadXML ($ source , $ options );
46
46
}
47
-
47
+
48
48
public function loaded ()
49
49
{
50
50
return $ this ->loaded ;
51
51
}
52
52
/**
53
53
* Returns monster name.
54
- *
54
+ *
55
55
* @return string Name.
56
56
* @throws DOMException On DOM operation error.
57
57
*/
@@ -62,7 +62,7 @@ public function getName()
62
62
63
63
/**
64
64
* Returns monster race.
65
- *
65
+ *
66
66
* @return string Race.
67
67
* @throws DOMException On DOM operation error.
68
68
*/
@@ -73,7 +73,7 @@ public function getRace()
73
73
74
74
/**
75
75
* Returns amount of experience for killing this monster.
76
- *
76
+ *
77
77
* @return int Experience points.
78
78
* @throws DOMException On DOM operation error.
79
79
*/
@@ -84,7 +84,7 @@ public function getExperience()
84
84
85
85
/**
86
86
* Returns monster speed.
87
- *
87
+ *
88
88
* @return int Speed.
89
89
* @throws DOMException On DOM operation error.
90
90
*/
@@ -95,7 +95,7 @@ public function getSpeed()
95
95
96
96
/**
97
97
* Returns amount of mana required to summon this monster.
98
- *
98
+ *
99
99
* @return int|bool Mana required (false if not possible).
100
100
* @throws DOMException On DOM operation error.
101
101
*/
@@ -114,7 +114,7 @@ public function getManaCost()
114
114
115
115
/**
116
116
* Returns monster HP.
117
- *
117
+ *
118
118
* @return int Hit points.
119
119
* @throws DOMException On DOM operation error.
120
120
*/
@@ -125,28 +125,29 @@ public function getHealth()
125
125
126
126
/**
127
127
* Returns all monster flags (in format flagname => value).
128
- *
128
+ *
129
129
* @return array Flags.
130
130
* @throws DOMException On DOM operation error.
131
131
*/
132
- public function getFlags ()
133
- {
134
- $ flags = array ();
132
+ public function getFlags ()
133
+ {
134
+ $ flags = array ();
135
135
136
- // read all flags
137
- foreach ( $ this ->documentElement ->getElementsByTagName ('flags ' )->item (0 )->getElementsByTagName ('flag ' ) as $ flag )
138
- {
139
- $ flag = $ flag ->attributes ->item (0 );
136
+ if ( $ this -> documentElement -> getElementsByTagName ( ' flags ' )-> item ( 0 )) {
137
+ foreach ( $ this ->documentElement ->getElementsByTagName ('flags ' )->item (0 )->getElementsByTagName ('flag ' ) as $ flag )
138
+ {
139
+ $ flag = $ flag ->attributes ->item (0 );
140
140
141
- $ flags [$ flag ->nodeName ] = (int ) $ flag ->nodeValue ;
142
- }
141
+ $ flags [$ flag ->nodeName ] = (int ) $ flag ->nodeValue ;
142
+ }
143
+ }
143
144
144
- return $ flags ;
145
- }
145
+ return $ flags ;
146
+ }
146
147
147
148
/**
148
149
* Returns specified flag value.
149
- *
150
+ *
150
151
* @param string $flag Flag.
151
152
* @return int|bool Flag value (false if not set).
152
153
* @throws DOMException On DOM operation error.
@@ -169,7 +170,7 @@ public function getFlag($flag)
169
170
170
171
/**
171
172
* Returns voices that monster can sound.
172
- *
173
+ *
173
174
* @return array List of voices.
174
175
* @throws DOMException On DOM operation error.
175
176
*/
@@ -214,17 +215,17 @@ public function getLoot()
214
215
$ chance = 100000 ;
215
216
}
216
217
}
217
-
218
+
218
219
$ count = $ item ->getAttribute ('countmax ' );
219
220
if (empty ($ count )) {
220
221
$ count = 1 ;
221
222
}
222
-
223
+
223
224
$ id = $ item ->getAttribute ('id ' );
224
225
if (empty ($ id )) {
225
226
$ id = $ item ->getAttribute ('name ' );
226
227
}
227
-
228
+
228
229
$ loot [] = array ('id ' => $ id , 'count ' => $ count , 'chance ' => $ chance );
229
230
}
230
231
}
@@ -234,11 +235,11 @@ public function getLoot()
234
235
235
236
/**
236
237
* Returns all possible loot.
237
- *
238
+ *
238
239
* <p>
239
240
* In order to use this method you have to have global items list loaded.
240
241
* </p>
241
- *
242
+ *
242
243
* @version 0.1.0
243
244
* @since 0.1.0
244
245
* @return array List of item types.
@@ -275,7 +276,7 @@ public function getItems()
275
276
276
277
/**
277
278
* Returns all monster immunities.
278
- *
279
+ *
279
280
* @return array Immunities.
280
281
* @throws DOMException On DOM operation error.
281
282
*/
@@ -306,7 +307,7 @@ public function getImmunities()
306
307
307
308
/**
308
309
* Checks if monster has given immunity.
309
- *
310
+ *
310
311
* @param string $name Immunity to check.
311
312
* @return bool Immunity state.
312
313
* @throws DOMException On DOM operation error.
@@ -334,7 +335,7 @@ public function hasImmunity($name)
334
335
335
336
/**
336
337
* Returns monster defense rate.
337
- *
338
+ *
338
339
* @return int Defense rate.
339
340
* @throws DOMException On DOM operation error.
340
341
*/
@@ -353,7 +354,7 @@ public function getDefense()
353
354
354
355
/**
355
356
* Returns monster armor.
356
- *
357
+ *
357
358
* @return int Armor rate.
358
359
* @throws DOMException On DOM operation error.
359
360
*/
@@ -372,7 +373,7 @@ public function getArmor()
372
373
373
374
/**
374
375
* Returns list of special defenses.
375
- *
376
+ *
376
377
* @return array List of defense effects.
377
378
* @throws DOMException On DOM operation error.
378
379
*/
@@ -396,7 +397,7 @@ public function getDefenses()
396
397
397
398
/**
398
399
* Returns list of monster attacks.
399
- *
400
+ *
400
401
* @return array List of attafck effects.
401
402
* @throws DOMException On DOM operation error.
402
403
*/
@@ -420,7 +421,7 @@ public function getAttacks()
420
421
421
422
/**
422
423
* Magic PHP5 method.
423
- *
424
+ *
424
425
* @version 0.1.0
425
426
* @since 0.1.0
426
427
* @param string $name Property name.
@@ -481,11 +482,11 @@ public function __get($name)
481
482
482
483
/**
483
484
* Returns string representation of XML.
484
- *
485
+ *
485
486
* <p>
486
487
* If any display driver is currently loaded then it uses it's method. Otherwise just returns monster XML content.
487
488
* </p>
488
- *
489
+ *
489
490
* @version 0.1.3
490
491
* @since 0.1.0
491
492
* @return string String representation of object.
0 commit comments