|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Created by Gorlum 03.09.2016 16:40 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
use Common\GlobalContainer; |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
class FleetRenderer { |
|
11
|
|
|
|
|
12
|
|
|
public function __construct(GlobalContainer $c) { |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @param Fleet $fleet |
|
18
|
|
|
*/ |
|
19
|
|
|
public function renderParamCoordinates(Fleet $fleet) { |
|
20
|
|
|
global $template_result; |
|
21
|
|
|
$template_result += array( |
|
22
|
|
|
'thisgalaxy' => $fleet->dbSourcePlanetRow['galaxy'], |
|
23
|
|
|
'thissystem' => $fleet->dbSourcePlanetRow['system'], |
|
24
|
|
|
'thisplanet' => $fleet->dbSourcePlanetRow['planet'], |
|
25
|
|
|
'thisplanet_type' => $fleet->dbSourcePlanetRow['planet_type'], |
|
26
|
|
|
|
|
27
|
|
|
'galaxy' => $fleet->targetVector->galaxy, |
|
28
|
|
|
'system' => $fleet->targetVector->system, |
|
29
|
|
|
'planet' => $fleet->targetVector->planet, |
|
30
|
|
|
'planet_type' => $fleet->targetVector->type, |
|
31
|
|
|
'target_mission' => $fleet->mission_type, |
|
32
|
|
|
'MISSION_NAME' => $fleet->mission_type ? classLocale::$lang['type_mission'][$fleet->mission_type] : '', |
|
33
|
|
|
|
|
34
|
|
|
'MT_COLONIZE' => MT_COLONIZE, |
|
35
|
|
|
); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param Fleet $fleet |
|
40
|
|
|
* @param int $missionStartTimeStamp |
|
41
|
|
|
* @param int $timeMissionJob |
|
42
|
|
|
* |
|
43
|
|
|
* @return array |
|
44
|
|
|
* |
|
45
|
|
|
* @throws Exception |
|
46
|
|
|
*/ |
|
47
|
|
|
public function renderFleet(Fleet $fleet, $missionStartTimeStamp = SN_TIME_NOW, $timeMissionJob = 0) { |
|
48
|
|
|
$unitList = $fleet->getUnitList(); |
|
49
|
|
|
if ($unitList->unitsCount() <= 0) { |
|
50
|
|
|
message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$timeToReturn = $fleet->travelData['duration'] * 2 + $timeMissionJob; |
|
54
|
|
|
$result = array( |
|
55
|
|
|
'ID' => 1, |
|
56
|
|
|
'START_TYPE_TEXT_SH' => classLocale::$lang['sys_planet_type_sh'][$fleet->dbSourcePlanetRow['planet_type']], |
|
57
|
|
|
'START_COORDS' => uni_render_coordinates($fleet->dbSourcePlanetRow), |
|
58
|
|
|
'START_NAME' => $fleet->dbSourcePlanetRow['name'], |
|
59
|
|
|
'START_TIME_TEXT' => date(FMT_DATE_TIME, $missionStartTimeStamp + $timeToReturn + SN_CLIENT_TIME_DIFF), |
|
60
|
|
|
'START_LEFT' => floor($timeToReturn), |
|
61
|
|
|
'END_TYPE_TEXT_SH' => |
|
62
|
|
|
!empty($fleet->targetVector->type) |
|
63
|
|
|
? classLocale::$lang['sys_planet_type_sh'][$fleet->targetVector->type] |
|
64
|
|
|
: '', |
|
65
|
|
|
'END_COORDS' => uniRenderVector($fleet->targetVector), |
|
66
|
|
|
'END_NAME' => !empty($fleet->dbTargetRow['name']) ? $fleet->dbTargetRow['name'] : '', |
|
67
|
|
|
'END_TIME_TEXT' => date(FMT_DATE_TIME, $missionStartTimeStamp + $fleet->travelData['duration'] + SN_CLIENT_TIME_DIFF), |
|
68
|
|
|
'END_LEFT' => floor($fleet->travelData['duration']), |
|
69
|
|
|
); |
|
70
|
|
|
$result['.']['ships'] = $unitList->unitsRender(); |
|
71
|
|
|
|
|
72
|
|
|
return $result; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return array |
|
78
|
|
|
*/ |
|
79
|
|
|
public function renderAllowedMissions(array $allowed_missions) { |
|
80
|
|
|
$result = array(); |
|
81
|
|
|
|
|
82
|
|
|
foreach ($allowed_missions as $key => $value) { |
|
83
|
|
|
$result[] = array( |
|
84
|
|
|
'ID' => $key, |
|
85
|
|
|
'NAME' => classLocale::$lang['type_mission'][$key], |
|
86
|
|
|
); |
|
87
|
|
|
}; |
|
88
|
|
|
|
|
89
|
|
|
return $result; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param $mission_type |
|
94
|
|
|
* @param $max_duration |
|
95
|
|
|
* |
|
96
|
|
|
* @return array |
|
97
|
|
|
*/ |
|
98
|
|
|
public function renderDuration($mission_type, $max_duration) { |
|
99
|
|
|
$result = array(); |
|
100
|
|
|
|
|
101
|
|
|
if (!$max_duration) { |
|
102
|
|
|
return $result; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
$config_game_speed_expedition = ($mission_type == MT_EXPLORE && classSupernova::$config->game_speed_expedition ? classSupernova::$config->game_speed_expedition : 1); |
|
106
|
|
|
for ($i = 1; $i <= $max_duration; $i++) { |
|
107
|
|
|
$result[] = array( |
|
108
|
|
|
'ID' => $i, |
|
109
|
|
|
'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)), |
|
110
|
|
|
); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
return $result; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @return array |
|
118
|
|
|
*/ |
|
119
|
|
|
public function renderAllowedPlanetTypes($allowed_planet_types) { |
|
120
|
|
|
$result = array(); |
|
121
|
|
|
|
|
122
|
|
|
foreach ($allowed_planet_types as $possible_planet_type_id) { |
|
123
|
|
|
$result[] = array( |
|
124
|
|
|
'ID' => $possible_planet_type_id, |
|
125
|
|
|
'NAME' => classLocale::$lang['sys_planet_type'][$possible_planet_type_id], |
|
126
|
|
|
'NAME_SHORT' => classLocale::$lang['sys_planet_type_sh'][$possible_planet_type_id], |
|
127
|
|
|
); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
return $result; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @param array $planetResources |
|
135
|
|
|
* |
|
136
|
|
|
* @return array |
|
137
|
|
|
*/ |
|
138
|
|
|
// TODO - REDO to resource_id |
|
139
|
|
|
public function renderPlanetResources(&$planetResources) { |
|
140
|
|
|
$result = array(); |
|
141
|
|
|
|
|
142
|
|
|
$i = 0; |
|
143
|
|
|
foreach ($planetResources as $resource_id => $resource_amount) { |
|
144
|
|
|
$result[] = array( |
|
145
|
|
|
'ID' => $i++, // $resource_id, |
|
146
|
|
|
'ON_PLANET' => $resource_amount, |
|
147
|
|
|
'TEXT' => pretty_number($resource_amount), |
|
148
|
|
|
'NAME' => classLocale::$lang['tech'][$resource_id], |
|
149
|
|
|
); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
return $result; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @param $template_result |
|
157
|
|
|
*/ |
|
158
|
|
|
public function renderShipSortOptions(&$template_result) { |
|
159
|
|
|
foreach (classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
160
|
|
|
$template_result['.']['ship_sort_list'][] = array( |
|
161
|
|
|
'VALUE' => $sort_id, |
|
162
|
|
|
'TEXT' => $sort_text, |
|
163
|
|
|
); |
|
164
|
|
|
} |
|
165
|
|
|
$template_result += array( |
|
166
|
|
|
'FLEET_SHIP_SORT' => classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT], |
|
167
|
|
|
'FLEET_SHIP_SORT_INVERSE' => classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE], |
|
168
|
|
|
); |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
|
|
172
|
|
|
} |
|
173
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.