1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by Gorlum 03.09.2016 15:41 |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Planet; |
7
|
|
|
|
8
|
|
|
use \classSupernova; |
9
|
|
|
use \classLocale; |
10
|
|
|
use Common\GlobalContainer; |
11
|
|
|
use DBStatic\DBStaticFleetACS; |
12
|
|
|
use DBStatic\DBStaticNote; |
13
|
|
|
use DBStatic\DBStaticPlanet; |
14
|
|
|
|
15
|
|
|
class PlanetRenderer { |
16
|
|
|
|
17
|
|
|
public function __construct(GlobalContainer $c) { |
|
|
|
|
18
|
|
|
|
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param array $playerRow |
23
|
|
|
* @param array $planetRow |
24
|
|
|
* |
25
|
|
|
* @return array |
26
|
|
|
*/ |
27
|
|
|
// TODO - redo to unit/unitlist renderer |
28
|
|
|
public function renderAvailableShips($playerRow, $planetRow) { |
29
|
|
|
$record_index = 0; |
30
|
|
|
$ship_list = array(); |
31
|
|
|
foreach (classSupernova::$gc->groupFleet as $n => $unit_id) { |
|
|
|
|
32
|
|
|
$unit_level = mrc_get_level($playerRow, $planetRow, $unit_id, false, true); |
33
|
|
|
if ($unit_level <= 0) { |
34
|
|
|
continue; |
35
|
|
|
} |
36
|
|
|
$ship_data = get_ship_data($unit_id, $playerRow); |
37
|
|
|
$ship_list[$unit_id] = array( |
38
|
|
|
'__INDEX' => $record_index++, |
39
|
|
|
'ID' => $unit_id, |
40
|
|
|
'NAME' => classLocale::$lang['tech'][$unit_id], |
41
|
|
|
'AMOUNT' => $unit_level, |
42
|
|
|
'AMOUNT_TEXT' => pretty_number($unit_level), |
43
|
|
|
'CONSUMPTION' => $ship_data['consumption'], |
44
|
|
|
'CONSUMPTION_TEXT' => pretty_number($ship_data['consumption']), |
45
|
|
|
'SPEED' => $ship_data['speed'], |
46
|
|
|
'SPEED_TEXT' => pretty_number($ship_data['speed']), |
47
|
|
|
'CAPACITY' => $ship_data['capacity'], |
48
|
|
|
'CAPACITY_TEXT' => pretty_number($ship_data['capacity']), |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
sortUnitRenderedList($ship_list, classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT], classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE]); |
53
|
|
|
|
54
|
|
|
return $ship_list; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function renderPlanetButton(&$planetRow) { |
58
|
|
|
global $note_priority_classes; |
59
|
|
|
|
60
|
|
|
$result = array( |
61
|
|
|
'NAME' => $planetRow['name'], |
62
|
|
|
'GALAXY' => $planetRow['galaxy'], |
63
|
|
|
'SYSTEM' => $planetRow['system'], |
64
|
|
|
'PLANET' => $planetRow['planet'], |
65
|
|
|
'TYPE' => $planetRow['planet_type'], |
66
|
|
|
'TYPE_PRINT' => classLocale::$lang['fl_shrtcup'][$planetRow['planet_type']], |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
if (isset($planetRow['priority'])) { |
70
|
|
|
$result += array( |
71
|
|
|
'PRIORITY' => $planetRow['priority'], |
72
|
|
|
'PRIORITY_CLASS' => $note_priority_classes[$planetRow['priority']], |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if (isset($planetRow['id'])) { |
77
|
|
|
$result += array( |
78
|
|
|
'ID' => $planetRow['id'], |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $result; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return array |
87
|
|
|
*/ |
88
|
|
|
public function renderACSList(array $dbOwnerRow) { |
89
|
|
|
$result = array(); |
90
|
|
|
|
91
|
|
|
$query = DBStaticFleetACS::db_acs_get_list(); |
92
|
|
|
while ($row = db_fetch($query)) { |
93
|
|
|
$members = explode(',', $row['eingeladen']); |
94
|
|
|
foreach ($members as $memberId) { |
95
|
|
|
if ($memberId == $dbOwnerRow['id']) { |
96
|
|
|
$result[] = classSupernova::$gc->planetRenderer->renderPlanetButton($row); |
|
|
|
|
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
return $result; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return array |
106
|
|
|
*/ |
107
|
|
|
// TODO - move to Notes |
108
|
|
|
public function renderPlanetShortcuts(array $dbOwnerRow) { |
109
|
|
|
$result = array(); |
110
|
|
|
|
111
|
|
|
// Building list of shortcuts |
112
|
|
|
$query = DBStaticNote::db_note_list_select_by_owner_and_planet($dbOwnerRow); |
113
|
|
|
while ($planetRow = db_fetch($query)) { |
114
|
|
|
$result[] = classSupernova::$gc->planetRenderer->renderPlanetButton($planetRow); |
|
|
|
|
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
return $result; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Building list of own planets & moons |
122
|
|
|
* |
123
|
|
|
* @return array |
124
|
|
|
*/ |
125
|
|
|
public function renderOwnPlanets(array $dbOwnerRow, array $dbSourcePlanetRow) { |
126
|
|
|
$result = array(); |
127
|
|
|
|
128
|
|
|
$colonies = DBStaticPlanet::db_planet_list_sorted($dbOwnerRow); |
129
|
|
|
if (count($colonies) <= 1) { |
130
|
|
|
return $result; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
foreach ($colonies as $planetRow) { |
134
|
|
|
if ($planetRow['id'] == $dbSourcePlanetRow['id']) { |
135
|
|
|
continue; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
$result[] = classSupernova::$gc->planetRenderer->renderPlanetButton($planetRow); |
|
|
|
|
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
return $result; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
} |
145
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.