|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* PlayerRanking |
|
5
|
|
|
* |
|
6
|
|
|
* @author Jacky Casas |
|
7
|
|
|
* @copyright Asylamba |
|
8
|
|
|
* |
|
9
|
|
|
* @package Atlas |
|
10
|
|
|
* @update 04.06.14 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Asylamba\Modules\Atlas\Model; |
|
14
|
|
|
|
|
15
|
|
|
use Asylamba\Classes\Library\Format; |
|
16
|
|
|
use Asylamba\Modules\Demeter\Resource\ColorResource; |
|
17
|
|
|
|
|
18
|
|
|
use Asylamba\Modules\Zeus\Model\Player; |
|
19
|
|
|
|
|
20
|
|
|
class PlayerRanking { |
|
21
|
|
|
# set number of player before you (remove 1) in rank view |
|
22
|
|
|
const PREV = 4; |
|
23
|
|
|
# set number of player after you in rank view |
|
24
|
|
|
const NEXT = 8; |
|
25
|
|
|
# PREV + NEXT |
|
26
|
|
|
const STEP = 12; |
|
27
|
|
|
# set number of player on ajax load page |
|
28
|
|
|
const PAGE = 10; |
|
29
|
|
|
|
|
30
|
|
|
# attributes |
|
31
|
|
|
public $id; |
|
32
|
|
|
public $rRanking; |
|
33
|
|
|
public $rPlayer; |
|
34
|
|
|
|
|
35
|
|
|
/** @var Player **/ |
|
36
|
|
|
protected $player; |
|
37
|
|
|
|
|
38
|
|
|
public $general; # pts des bases + flottes + commandants |
|
39
|
|
|
public $generalPosition; |
|
40
|
|
|
public $generalVariation; |
|
41
|
|
|
|
|
42
|
|
|
public $experience; # experience |
|
43
|
|
|
public $experiencePosition; |
|
44
|
|
|
public $experienceVariation; |
|
45
|
|
|
|
|
46
|
|
|
public $butcher; # destroyedPEV - lostPEV |
|
47
|
|
|
public $butcherDestroyedPEV; |
|
48
|
|
|
public $butcherLostPEV; |
|
49
|
|
|
public $butcherPosition; |
|
50
|
|
|
public $butcherVariation; |
|
51
|
|
|
|
|
52
|
|
|
public $trader; # revenu total des routes |
|
53
|
|
|
public $traderPosition; |
|
54
|
|
|
public $traderVariation; |
|
55
|
|
|
|
|
56
|
|
|
public $fight; # victoires - défaites |
|
57
|
|
|
public $victories; |
|
58
|
|
|
public $defeat; |
|
59
|
|
|
public $fightPosition; |
|
60
|
|
|
public $fightVariation; |
|
61
|
|
|
|
|
62
|
|
|
public $armies; # nb de pev total flotte + hangar |
|
63
|
|
|
public $armiesPosition; |
|
64
|
|
|
public $armiesVariation; |
|
65
|
|
|
|
|
66
|
|
|
public $resources; # production de ressources par relève (on peut ajouter les recyclages p-e) |
|
67
|
|
|
public $resourcesPosition; |
|
68
|
|
|
public $resourcesVariation; |
|
69
|
|
|
|
|
70
|
|
|
# additional attributes |
|
71
|
|
|
public $color; |
|
72
|
|
|
public $name; |
|
73
|
|
|
public $avatar; |
|
74
|
|
|
public $status; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param int $id |
|
78
|
|
|
* @return PlayerRanking |
|
79
|
|
|
*/ |
|
80
|
|
|
public function setId($id) |
|
81
|
|
|
{ |
|
82
|
|
|
$this->id = $id; |
|
83
|
|
|
|
|
84
|
|
|
return $this; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function getId() { return $this->id; } |
|
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param Player $player |
|
91
|
|
|
* @return PlayerRanking |
|
92
|
|
|
*/ |
|
93
|
|
|
public function setPlayer(Player $player) |
|
94
|
|
|
{ |
|
95
|
|
|
$this->player = $player; |
|
96
|
|
|
|
|
97
|
|
|
return $this; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @return Player |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getPlayer() |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->player; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @param int $general |
|
110
|
|
|
* @return PlayerRanking |
|
111
|
|
|
*/ |
|
112
|
|
|
public function setGeneral($general) |
|
113
|
|
|
{ |
|
114
|
|
|
$this->general = $general; |
|
115
|
|
|
|
|
116
|
|
|
return $this; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @return int |
|
121
|
|
|
*/ |
|
122
|
|
|
public function getGeneral() |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->general; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function commonRender($playerId, $type) { |
|
128
|
|
|
$r = ''; |
|
129
|
|
|
$status = ColorResource::getInfo($this->color, 'status'); |
|
130
|
|
|
|
|
131
|
|
|
$plus = null; |
|
|
|
|
|
|
132
|
|
|
$minus = null; |
|
|
|
|
|
|
133
|
|
|
|
|
134
|
|
|
switch ($type) { |
|
135
|
|
|
case 'general': |
|
136
|
|
|
$pos = $this->generalPosition; |
|
137
|
|
|
$var = $this->generalVariation; break; |
|
|
|
|
|
|
138
|
|
|
case 'xp': |
|
139
|
|
|
$pos = $this->experiencePosition; |
|
140
|
|
|
$var = $this->experienceVariation; break; |
|
|
|
|
|
|
141
|
|
|
case 'butcher': |
|
142
|
|
|
$pos = $this->butcherPosition; |
|
143
|
|
|
$plus = $this->butcherDestroyedPEV; |
|
|
|
|
|
|
144
|
|
|
$minus = $this->butcherLostPEV; |
|
|
|
|
|
|
145
|
|
|
$var = $this->butcherVariation; break; |
|
|
|
|
|
|
146
|
|
|
case 'trader': |
|
147
|
|
|
$pos = $this->traderPosition; |
|
148
|
|
|
$var = $this->traderVariation; break; |
|
|
|
|
|
|
149
|
|
|
case 'fight': |
|
150
|
|
|
$pos = $this->fightPosition; |
|
151
|
|
|
$plus = $this->victories; |
|
|
|
|
|
|
152
|
|
|
$minus = $this->defeat; |
|
|
|
|
|
|
153
|
|
|
$var = $this->fightVariation; break; |
|
|
|
|
|
|
154
|
|
|
case 'armies': |
|
155
|
|
|
$pos = $this->armiesPosition; |
|
156
|
|
|
$var = $this->armiesVariation; break; |
|
|
|
|
|
|
157
|
|
|
case 'resources': |
|
158
|
|
|
$pos = $this->resourcesPosition; |
|
159
|
|
|
$var = $this->resourcesVariation; break; |
|
|
|
|
|
|
160
|
|
|
default: $var = ''; $pos = ''; break; |
|
|
|
|
|
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
$r .= '<div class="player color' . $this->color . ' ' . ($playerId == $this->rPlayer ? 'active' : NULL) . '">'; |
|
164
|
|
|
$r .= '<a href="' . APP_ROOT . 'embassy/player-' . $this->rPlayer . '">'; |
|
165
|
|
|
$r .= '<img src="' . MEDIA . 'avatar/small/' . $this->avatar . '.png" alt="' . $this->name . '" class="picto" />'; |
|
166
|
|
|
$r .= '</a>'; |
|
167
|
|
|
|
|
168
|
|
|
$r .= '<span class="title">' . $status[$this->status - 1] . '</span>'; |
|
169
|
|
|
$r .= '<strong class="name">' . $this->name . '</strong>'; |
|
170
|
|
|
|
|
171
|
|
|
$r .= '<span class="experience">'; |
|
172
|
|
|
switch ($type) { |
|
173
|
|
|
case 'general': $r .= Format::numberFormat($this->general) . ' point' . Format::addPlural($this->general); break; |
|
|
|
|
|
|
174
|
|
|
case 'xp': $r .= Format::numberFormat($this->experience) . ' xp'; break; |
|
|
|
|
|
|
175
|
|
|
case 'butcher': |
|
176
|
|
|
$r .= Format::numberFormat($this->butcher) . ' point' . Format::addPlural($this->butcher); |
|
177
|
|
|
break; |
|
178
|
|
|
case 'trader': $r .= Format::numberFormat($this->trader) . ' <img src="' . MEDIA . 'resources/credit.png" class="icon-color" alt="crédits" />'; break; |
|
|
|
|
|
|
179
|
|
|
case 'fight': |
|
180
|
|
|
$r .= Format::numberFormat($this->fight) . ' point' . Format::addPlural($this->fight); |
|
181
|
|
|
break; |
|
182
|
|
|
# case 'armies': $r .= Format::numberFormat($this->armies) . ' <img src="' . MEDIA . 'resources/pev.png" class="icon-color" alt="pev" />'; break; |
|
183
|
|
|
case 'resources': $r .= Format::numberFormat($this->resources) . ' <img src="' . MEDIA . 'resources/resource.png" class="icon-color" alt="ressources" />'; break; |
|
|
|
|
|
|
184
|
|
|
default: break; |
|
|
|
|
|
|
185
|
|
|
} |
|
186
|
|
|
$r .= '</span>'; |
|
187
|
|
|
|
|
188
|
|
|
$r .= '<span class="position">' . $pos . '</span>'; |
|
189
|
|
|
|
|
190
|
|
|
if (intval($var) != 0) { |
|
191
|
|
|
$r .= '<span class="variance ' . ($var > 0 ? ' upper' : ' lower') . '">'; |
|
192
|
|
|
$r .= ($var > 0 ? '+' : '–') . abs($var); |
|
193
|
|
|
$r .='</span>'; |
|
194
|
|
|
} |
|
195
|
|
|
$r .= '</div>'; |
|
196
|
|
|
|
|
197
|
|
|
return $r; |
|
198
|
|
|
} |
|
199
|
|
|
} |
|
200
|
|
|
|