|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* FactionRanking |
|
5
|
|
|
* |
|
6
|
|
|
* @author Jacky Casas |
|
7
|
|
|
* @copyright Asylamba |
|
8
|
|
|
* |
|
9
|
|
|
* @package Atlas |
|
10
|
|
|
* @update 04.06.14 |
|
11
|
|
|
*/ |
|
12
|
|
|
namespace Asylamba\Modules\Atlas\Model; |
|
13
|
|
|
|
|
14
|
|
|
use Asylamba\Classes\Library\Format; |
|
15
|
|
|
use Asylamba\Modules\Demeter\Resource\ColorResource; |
|
16
|
|
|
|
|
17
|
|
|
class FactionRanking { |
|
18
|
|
|
|
|
19
|
|
|
# attributes |
|
20
|
|
|
public $id; |
|
21
|
|
|
public $rRanking; |
|
22
|
|
|
public $rFaction; |
|
23
|
|
|
|
|
24
|
|
|
public $points; # accumulated points |
|
25
|
|
|
public $pointsPosition; |
|
26
|
|
|
public $pointsVariation; |
|
27
|
|
|
public $newPoints; |
|
28
|
|
|
|
|
29
|
|
|
public $general; # sum of general ranking of the players |
|
30
|
|
|
public $generalPosition; |
|
31
|
|
|
public $generalVariation; |
|
32
|
|
|
|
|
33
|
|
|
public $wealth; # credits |
|
34
|
|
|
public $wealthPosition; |
|
35
|
|
|
public $wealthVariation; |
|
36
|
|
|
|
|
37
|
|
|
public $territorial; # sectors owned |
|
38
|
|
|
public $territorialPosition; |
|
39
|
|
|
public $territorialVariation; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param int $id |
|
43
|
|
|
* @return FactionRanking |
|
44
|
|
|
*/ |
|
45
|
|
|
public function setId($id) |
|
46
|
|
|
{ |
|
47
|
|
|
$this->id = $id; |
|
48
|
|
|
|
|
49
|
|
|
return $this; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return int |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getId() |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->id; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param int $rankingId |
|
62
|
|
|
* @return FactionRanking |
|
63
|
|
|
*/ |
|
64
|
|
|
public function setRankingId($rankingId) |
|
65
|
|
|
{ |
|
66
|
|
|
$this->rRanking = $rankingId; |
|
67
|
|
|
|
|
68
|
|
|
return $this; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return int |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getRankingId() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->rRanking; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param int $factionId |
|
81
|
|
|
* @return FactionRanking |
|
82
|
|
|
*/ |
|
83
|
|
|
public function setFactionId($factionId) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->rFaction = $factionId; |
|
86
|
|
|
|
|
87
|
|
|
return $this; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @return int |
|
92
|
|
|
*/ |
|
93
|
|
|
public function getFactionId() |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->rFaction; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @param int $points |
|
100
|
|
|
* @return FactionRanking |
|
101
|
|
|
*/ |
|
102
|
|
|
public function setPoints($points) |
|
103
|
|
|
{ |
|
104
|
|
|
$this->points = $points; |
|
105
|
|
|
|
|
106
|
|
|
return $this; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return int |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getPoints() |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->points; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @param int $pointsPosition |
|
119
|
|
|
* @return FactionRanking |
|
120
|
|
|
*/ |
|
121
|
|
|
public function setPointsPosition($pointsPosition) |
|
122
|
|
|
{ |
|
123
|
|
|
$this->pointsPosition = $pointsPosition; |
|
124
|
|
|
|
|
125
|
|
|
return $this; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* @return int |
|
130
|
|
|
*/ |
|
131
|
|
|
public function getPointsPosition() |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->pointsPosition; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @param int $pointsVariation |
|
138
|
|
|
* @return FactionRanking |
|
139
|
|
|
*/ |
|
140
|
|
|
public function setPointsVariation($pointsVariation) |
|
141
|
|
|
{ |
|
142
|
|
|
$this->pointsVariation = $pointsVariation; |
|
143
|
|
|
|
|
144
|
|
|
return $this; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* @return int |
|
149
|
|
|
*/ |
|
150
|
|
|
public function getPointsVariation() |
|
151
|
|
|
{ |
|
152
|
|
|
return $this->pointsVariation; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @param int $newPoints |
|
157
|
|
|
* @return FactionRanking |
|
158
|
|
|
*/ |
|
159
|
|
|
public function setNewPoints($newPoints) |
|
160
|
|
|
{ |
|
161
|
|
|
$this->newPoints = $newPoints; |
|
162
|
|
|
|
|
163
|
|
|
return $this; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @return int |
|
168
|
|
|
*/ |
|
169
|
|
|
public function getNewPoints() |
|
170
|
|
|
{ |
|
171
|
|
|
return $this->newPoints; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* @param int $general |
|
176
|
|
|
* @return FactionRanking |
|
177
|
|
|
*/ |
|
178
|
|
|
public function setGeneral($general) |
|
179
|
|
|
{ |
|
180
|
|
|
$this->general = $general; |
|
181
|
|
|
|
|
182
|
|
|
return $this; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* @return int |
|
187
|
|
|
*/ |
|
188
|
|
|
public function getGeneral() |
|
189
|
|
|
{ |
|
190
|
|
|
return $this->general; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @param int $generalPosition |
|
195
|
|
|
* @return FactionRanking |
|
196
|
|
|
*/ |
|
197
|
|
|
public function setGeneralPosition($generalPosition) |
|
198
|
|
|
{ |
|
199
|
|
|
$this->generalPosition = $generalPosition; |
|
200
|
|
|
|
|
201
|
|
|
return $this; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* @return int |
|
206
|
|
|
*/ |
|
207
|
|
|
public function getGeneralPosition() |
|
208
|
|
|
{ |
|
209
|
|
|
return $this->generalPosition; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @param int $generalVariation |
|
214
|
|
|
* @return FactionRanking |
|
215
|
|
|
*/ |
|
216
|
|
|
public function setGeneralVariation($generalVariation) |
|
217
|
|
|
{ |
|
218
|
|
|
$this->generalVariation = $generalVariation; |
|
219
|
|
|
|
|
220
|
|
|
return $this; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* @return int |
|
225
|
|
|
*/ |
|
226
|
|
|
public function getGeneralVariation() |
|
227
|
|
|
{ |
|
228
|
|
|
return $this->generalVariation; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* @param int $wealth |
|
233
|
|
|
* @return FactionRanking |
|
234
|
|
|
*/ |
|
235
|
|
|
public function setWealth($wealth) |
|
236
|
|
|
{ |
|
237
|
|
|
$this->wealth = $wealth; |
|
238
|
|
|
|
|
239
|
|
|
return $this; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* @return int |
|
244
|
|
|
*/ |
|
245
|
|
|
public function getWealth() |
|
246
|
|
|
{ |
|
247
|
|
|
return $this->wealth; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
/** |
|
251
|
|
|
* @param int $wealthPosition |
|
252
|
|
|
* @return FactionRanking |
|
253
|
|
|
*/ |
|
254
|
|
|
public function setWealthPosition($wealthPosition) |
|
255
|
|
|
{ |
|
256
|
|
|
$this->wealthPosition = $wealthPosition; |
|
257
|
|
|
|
|
258
|
|
|
return $this; |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
/** |
|
262
|
|
|
* @return int |
|
263
|
|
|
*/ |
|
264
|
|
|
public function getWealthPosition() |
|
265
|
|
|
{ |
|
266
|
|
|
return $this->wealthPosition; |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
/** |
|
270
|
|
|
* @param int $wealthVariation |
|
271
|
|
|
* @return FactionRanking |
|
272
|
|
|
*/ |
|
273
|
|
|
public function setWealthVariation($wealthVariation) |
|
274
|
|
|
{ |
|
275
|
|
|
$this->wealthVariation = $wealthVariation; |
|
276
|
|
|
|
|
277
|
|
|
return $this; |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* @return int |
|
282
|
|
|
*/ |
|
283
|
|
|
public function getWealthVariation() |
|
284
|
|
|
{ |
|
285
|
|
|
return $this->wealthVariation; |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
/** |
|
289
|
|
|
* @param int $territorial |
|
290
|
|
|
* @return FactionRanking |
|
291
|
|
|
*/ |
|
292
|
|
|
public function setTerritorial($territorial) |
|
293
|
|
|
{ |
|
294
|
|
|
$this->territorial = $territorial; |
|
295
|
|
|
|
|
296
|
|
|
return $this; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
/** |
|
300
|
|
|
* @return int |
|
301
|
|
|
*/ |
|
302
|
|
|
public function getTerritorial() |
|
303
|
|
|
{ |
|
304
|
|
|
return $this->territorial; |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* @param int $territorialPosition |
|
309
|
|
|
* @return FactionRanking |
|
310
|
|
|
*/ |
|
311
|
|
|
public function setTerritorialPosition($territorialPosition) |
|
312
|
|
|
{ |
|
313
|
|
|
$this->territorialPosition = $territorialPosition; |
|
314
|
|
|
|
|
315
|
|
|
return $this; |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
/** |
|
319
|
|
|
* @return int |
|
320
|
|
|
*/ |
|
321
|
|
|
public function getTerritorialPosition() |
|
322
|
|
|
{ |
|
323
|
|
|
return $this->territorialPosition; |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
/** |
|
327
|
|
|
* @param int $territorialVariation |
|
328
|
|
|
* @return FactionRanking |
|
329
|
|
|
*/ |
|
330
|
|
|
public function setTerritorialVariation($territorialVariation) |
|
331
|
|
|
{ |
|
332
|
|
|
$this->territorialVariation = $territorialVariation; |
|
333
|
|
|
|
|
334
|
|
|
return $this; |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
/** |
|
338
|
|
|
* @return int |
|
339
|
|
|
*/ |
|
340
|
|
|
public function getTerritorialVariation() |
|
341
|
|
|
{ |
|
342
|
|
|
return $this->territorialVariation; |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
public function commonRender($playerInfo, $type = 'general') { |
|
346
|
|
|
$r = ''; |
|
347
|
|
|
|
|
348
|
|
|
switch ($type) { |
|
349
|
|
|
case 'points': |
|
350
|
|
|
$pos = $this->pointsPosition; |
|
351
|
|
|
$var = $this->pointsVariation; break; |
|
|
|
|
|
|
352
|
|
|
case 'general': |
|
353
|
|
|
$pos = $this->generalPosition; |
|
354
|
|
|
$var = $this->generalVariation; break; |
|
|
|
|
|
|
355
|
|
|
case 'wealth': |
|
356
|
|
|
$pos = $this->wealthPosition; |
|
357
|
|
|
$var = $this->wealthVariation; break; |
|
|
|
|
|
|
358
|
|
|
case 'territorial': |
|
359
|
|
|
$pos = $this->territorialPosition; |
|
360
|
|
|
$var = $this->territorialVariation; break; |
|
|
|
|
|
|
361
|
|
|
default: $var = ''; $pos = ''; break; |
|
|
|
|
|
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
$r .= '<div class="player faction color' . $this->rFaction . ' ' . ($playerInfo->get('color') == $this->rFaction ? 'active' : NULL) . '">'; |
|
365
|
|
|
$r .= '<img src="' . MEDIA . 'faction/flag/flag-' . $this->rFaction . '.png" alt="' . $this->rFaction . '" class="picto" />'; |
|
366
|
|
|
|
|
367
|
|
|
$r .= '<span class="title">' . ColorResource::getInfo($this->rFaction, 'government') . '</span>'; |
|
368
|
|
|
$r .= '<strong class="name">' . ColorResource::getInfo($this->rFaction, 'popularName') . '</strong>'; |
|
369
|
|
|
$r .= '<span class="experience">'; |
|
370
|
|
|
switch ($type) { |
|
371
|
|
|
case 'points': |
|
372
|
|
|
$r .= Format::number($this->points, -1) . ' points'; |
|
373
|
|
|
if ($this->newPoints > 0) { |
|
374
|
|
|
$r .= ' (+' . Format::number($this->newPoints, -1) . ' points)'; |
|
375
|
|
|
} |
|
376
|
|
|
break; |
|
377
|
|
|
case 'general': $r .= Format::number($this->general, -1) . ' points'; break; |
|
|
|
|
|
|
378
|
|
|
case 'wealth': $r .= Format::number($this->wealth, -1) . ' crédits'; break; |
|
|
|
|
|
|
379
|
|
|
case 'territorial': $r .= Format::number($this->territorial, -1) . ' points'; break; |
|
|
|
|
|
|
380
|
|
|
default: break; |
|
|
|
|
|
|
381
|
|
|
} |
|
382
|
|
|
$r .= '</span>'; |
|
383
|
|
|
|
|
384
|
|
|
$r .= '<span class="position'; |
|
385
|
|
|
$r .= intval($var) == 0 |
|
386
|
|
|
? NULL |
|
387
|
|
|
: ($var > 0 |
|
388
|
|
|
? ' upper' |
|
389
|
|
|
: ' lower' |
|
390
|
|
|
) |
|
391
|
|
|
; |
|
392
|
|
|
$r .= '">' . $pos . '</span>'; |
|
393
|
|
|
$r .= '</div>'; |
|
394
|
|
|
|
|
395
|
|
|
return $r; |
|
396
|
|
|
} |
|
397
|
|
|
} |
|
398
|
|
|
|
As per the PSR-2 coding standard, the
break(or other terminating) statement must be on a line of its own.To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.