forked from gplanchat/wootook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fleet.php
285 lines (259 loc) · 12.1 KB
/
fleet.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
define('INSIDE' , true);
define('INSTALL' , false);
require_once dirname(__FILE__) .'/application/bootstrap.php';
//Compteur de flotte en expéditions et nombre d'expédition maximum
$maxExpedition = $user->getElement(Legacies_Empire::ID_RESEARCH_EXPEDITION_TECHNOLOGY);
$ExpeditionEnCours = 0;
$EnvoiMaxExpedition = 0;
if ($maxExpedition >= 1) {
$maxexpde = doquery("SELECT 1 FROM {{table}} WHERE `fleet_owner` = '".$user['id']."' AND `fleet_mission` = '15';", 'fleets');
$ExpeditionEnCours = $maxexpde->rowCount();
$maxexpde->closeCursor();
$EnvoiMaxExpedition = 1 + floor($maxExpedition / 3);
}
$MaxFlottes = 1 + $user->getElement(Legacies_Empire::ID_RESEARCH_COMPUTER_TECHNOLOGY);
includeLang('fleet');
$missionTypes = array(
Legacies_Empire::ID_MISSION_ATTACK => $lang['type_mission'][Legacies_Empire::ID_MISSION_ATTACK],
Legacies_Empire::ID_MISSION_GROUP_ATTACK => $lang['type_mission'][Legacies_Empire::ID_MISSION_GROUP_ATTACK],
Legacies_Empire::ID_MISSION_TRANSPORT => $lang['type_mission'][Legacies_Empire::ID_MISSION_TRANSPORT],
Legacies_Empire::ID_MISSION_STATION => $lang['type_mission'][Legacies_Empire::ID_MISSION_STATION],
Legacies_Empire::ID_MISSION_STATION_ALLY => $lang['type_mission'][Legacies_Empire::ID_MISSION_STATION_ALLY],
Legacies_Empire::ID_MISSION_SPY => $lang['type_mission'][Legacies_Empire::ID_MISSION_SPY],
Legacies_Empire::ID_MISSION_SETTLE_COLONY => $lang['type_mission'][Legacies_Empire::ID_MISSION_SETTLE_COLONY],
Legacies_Empire::ID_MISSION_RECYCLE => $lang['type_mission'][Legacies_Empire::ID_MISSION_RECYCLE],
Legacies_Empire::ID_MISSION_DESTROY => $lang['type_mission'][Legacies_Empire::ID_MISSION_DESTROY],
Legacies_Empire::ID_MISSION_EXPEDITION => $lang['type_mission'][Legacies_Empire::ID_MISSION_EXPEDITION]
);
// Histoire de recuperer les infos passées par galaxy
$galaxy = isset($_GET['galaxy']) ? intval($_GET['galaxy']) : 0;
$system = isset($_GET['system']) ? intval($_GET['system']) : 0;
$position = isset($_GET['planet']) ? intval($_GET['planet']) : 0;
$planetType = isset($_GET['planettype']) ? intval($_GET['planettype']) : 0;
$targetMission = isset($_GET['target_mission']) ? intval($_GET['target_mission']) : 0;
$user = Wootook_Empire_Model_User::getSingleton();
$planet = $user->getCurrentPlanet();
$MaxFlyingFleets = $user->getFleetCount();
if ($galaxy <= 0 || $galaxy > Wootook::getGameConfig('engine/universe/galaxies')) {
$galaxy = $planet['galaxy'];
}
if ($system <= 0 || $system > Wootook::getGameConfig('engine/universe/systems')) {
$system = $planet['system'];
}
if ($position <= 0 || $position > Wootook::getGameConfig('engine/universe/positions')) {
$position = $planet['planet'];
}
$allowedPlanetTypes = array(
Wootook_Empire_Model_Planet::TYPE_PLANET,
Wootook_Empire_Model_Planet::TYPE_DEBRIS,
Wootook_Empire_Model_Planet::TYPE_MOON
);
if (!in_array($planetType, $allowedPlanetTypes)) {
$planetType = $planet['planet_type'];
}
$page = "<script type=\"text/javascript\" src=\"scripts/flotten.js\"></script>\n";
$page .= "<script language=\"JavaScript\" src=\"scripts/ocnt.js\"></script>\n";
$page .= "<br><center>";
$page .= "<table width='519' border='0' cellpadding='0' cellspacing='1'>";
$page .= "<tr height='20'>";
$page .= "<td colspan='9' class='c'>";
$page .= "<table border=\"0\" width=\"100%\">";
$page .= "<tbody><tr>";
$page .= "<td style=\"background-color: transparent;\">";
$page .= $lang['fl_title']." ".$MaxFlyingFleets." ".$lang['fl_sur']." ".$MaxFlottes;
$page .= "</td><td style=\"background-color: transparent;\" align=\"right\">";
$page .= $ExpeditionEnCours."/".$EnvoiMaxExpedition." ".$lang['fl_expttl'];
$page .= "</td>";
$page .= "</tr></tbody></table>";
$page .= "</td>";
$page .= "</tr><tr height='20'>";
$page .= "<th>".$lang['fl_id']."</th>";
$page .= "<th>".$lang['fl_mission']."</th>";
$page .= "<th>".$lang['fl_count']."</th>";
$page .= "<th>".$lang['fl_from']."</th>";
$page .= "<th>".$lang['fl_start_t']."</th>";
$page .= "<th>".$lang['fl_dest']."</th>";
$page .= "<th>".$lang['fl_dest_t']."</th>";
//$page .= "<th>".$lang['fl_back_t']."</th>";
$page .= "<th>".$lang['fl_back_in']."</th>";
$page .= "<th>".$lang['fl_order']."</th>";
$page .= "</tr>";
$i = 0;
foreach ($user->getFleetCollection() as $f) {
$i++;
$page .= "<tr height=20>";
// (01) Fleet ID
$page .= "<th>".$i."</th>";
// (02) Fleet Mission
$page .= "<th>";
$page .= "<a>". $missionTypes[$f['fleet_mission']] ."</a>";
if (($f['fleet_start_time'] + 1) == $f['fleet_end_time']) {
$page .= "<br><a title=\"".$lang['fl_back_to_ttl']."\">".$lang['fl_back_to']."</a>";
} else {
$page .= "<br><a title=\"".$lang['fl_get_to_ttl']."\">".$lang['fl_get_to']."</a>";
}
$page .= "</th>";
// (03) Fleet Mission
$page .= "<th><a title=\"";
// Fleet details (commentaire)
$fleet = explode(";", $f['fleet_array']);
$e = 0;
foreach ($fleet as $a => $b) {
if ($b != '') {
$e++;
$a = explode(",", $b);
$page .= $lang['tech'][$a[0]]. ":". $a[1] ."\n";
if ($e > 1) {
$page .= "\t";
}
}
}
$page .= "\">". pretty_number($f['fleet_amount']) ."</a></th>";
// (04) Fleet From (Planete d'origine)
$page .= "<th>[".$f[fleet_start_galaxy].":".$f['fleet_start_system'].":".$f['fleet_start_planet']."]</th>";
// (05) Fleet Start Time
$page .= "<th>". gmdate("d. M Y H:i:s", $f['fleet_start_time']) ."</th>";
// (06) Fleet Target (Planete de destination)
$page .= "<th>[".$f['fleet_end_galaxy'].":".$f['fleet_end_system'].":".$f['fleet_end_planet']."]</th>";
// (07) Fleet Target Time
$page .= "<th>". gmdate("d. M Y H:i:s", $f['fleet_end_time']) ."</th>";
// (08) Fleet Back Time
// $page .= "<th><font color=\"lime\"><div id=\"time_0\"><font>". pretty_time(floor($f['fleet_end_time'] + 1 - time())) ."</font></th>";
// (09) Fleet Back In
$page .= "<th><font color=\"lime\"><div id=\"time_0\"><font>". pretty_time(floor($f['fleet_end_time'] + 1 - time())) ."</font></th>";
// (10) Orders
$page .= "<th>";
if ($f['fleet_mess'] == 0) {
$page .= "<form action=\"fleetback.php\" method=\"post\">";
$page .= "<input name=\"fleetid\" value=\"". $f['fleet_id'] ."\" type=\"hidden\">";
$page .= "<input value=\" ".$lang['fl_back_to_ttl']." \" type=\"submit\" name=\"send\">";
$page .= "</form>";
if ($f[fleet_mission] == 1) {
$page .= "<form action=\"verband.php\" method=\"post\">";
$page .= "<input name=\"fleetid\" value=\"". $f['fleet_id'] ."\" type=\"hidden\">";
$page .= "<input value=\" ".$lang['fl_associate']." \" type=\"submit\">";
$page .= "</form>";
}
} else {
$page .= " - ";
}
$page .= "</th>";
// Fin de ligne
$page .= "</tr>";
}
// Y a pas de flottes en vol ... on met des '-'
if ($i == 0) {
$page .= "<tr>";
$page .= "<th>-</th>";
$page .= "<th>-</th>";
$page .= "<th>-</th>";
$page .= "<th>-</th>";
$page .= "<th>-</th>";
$page .= "<th>-</th>";
$page .= "<th>-</th>";
// $page .= "<th>-</th>";
$page .= "<th>-</th>";
$page .= "<th>-</th>";
$page .= "</tr>";
}
if ($MaxFlottes == $MaxFlyingFleets) {
$page .= "<tr height=\"20\"><th colspan=\"9\"><font color=\"red\">".$lang['fl_noslotfree']."</font></th></tr>";
}
$page .= "</table></center>";
$page .= "<center>";
// Selection d'une nouvelle mission
$page .= "<form action=\"floten1.php\" method=\"post\">";
$page .= "<table width=\"519\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">";
$page .= "<tr height=\"20\">";
$page .= "<td colspan=\"4\" class=\"c\">".$lang['fl_new_miss']."</td>";
$page .= "</tr>";
$page .= "<tr height=\"20\">";
$page .= "<th>".$lang['fl_fleet_typ']."</th>";
$page .= "<th>".$lang['fl_fleet_disp']."</th>";
$page .= "<th>-</th>";
$page .= "<th>-</th>";
$page .= "</tr>";
if (!$planet) {
message($lang['fl_noplanetrow'], $lang['fl_error']);
}
$ShipData = "";
$have_ships = false;
foreach ($reslist['fleet'] as $n => $i) {
if ($planet[$resource[$i]] > 0) {
$page .= "<tr height=\"20\">";
$page .= "<th><a title=\"". $lang['fl_fleetspeed'] /*. $CurrentShipSpeed*/ ."\">" . $lang['tech'][$i] . "</a></th>";
$page .= "<th>". pretty_number ($planet[$resource[$i]]);
$ShipData .= "<input type=\"hidden\" name=\"maxship[". $i ."]\" value=\"". $planet[$resource[$i]] ."\" />";
$ShipData .= "<input type=\"hidden\" name=\"consumption[". $i ."]\" value=\"". GetShipConsumption ( $i, $user ) ."\" />";
$ShipData .= "<input type=\"hidden\" name=\"speed[" .$i ."]\" value=\"" . GetFleetMaxSpeed ("", $i, $user) . "\" />";
$ShipData .= "<input type=\"hidden\" name=\"capacity[". $i ."]\" value=\"". $pricelist[$i]['capacity'] ."\" />";
$page .= "</th>";
// Satelitte Solaire (eux ne peuvent pas bouger !)
if ($i == 212) {
$page .= "<th></th><th></th>";
} else {
$page .= "<th><a href=\"javascript:maxShip('ship[". $i ."]'); shortInfo();\">".$lang['fl_selmax']."</a> </th>";
$page .= "<th><input name=\"ship[". $i ."]\" size=\"10\" value=\"0\" onfocus=\"javascript:if(this.value == '0') this.value='';\" onblur=\"javascript:if(this.value == '') this.value='0';\" alt=\"". $lang['tech'][$i] . $planet[$resource[$i]] ."\" onChange=\"shortInfo()\" onKeyUp=\"shortInfo()\" /></th>";
}
$page .= "</tr>";
$have_ships = true;
}
}
$btncontinue = "<tr height=\"20\"><th colspan=\"4\"><input type=\"submit\" value=\" ".$lang['fl_continue']." \" /></th>";
$page .= "<tr height=\"20\">";
if (!$have_ships) {
// Il n'y a pas de vaisseaux sur cette planete
$page .= "<th colspan=\"4\">". $lang['fl_noships'] ."</th>";
$page .= "</tr>";
$page .= $btncontinue;
} else {
$page .= "<th colspan=\"2\"><a href=\"javascript:noShips();shortInfo();noResources();\" >". $lang['fl_unselectall'] ."</a></th>";
$page .= "<th colspan=\"2\"><a href=\"javascript:maxShips();shortInfo();\" >". $lang['fl_selectall'] ."</a></th>";
$page .= "</tr>";
if ($MaxFlottes > $MaxFlyingFleets) {
$page .= $btncontinue;
}
}
$page .= "</tr>";
$page .= "</table>";
$page .= $ShipData;
$page .= "<input type=\"hidden\" name=\"galaxy\" value=\"". $galaxy ."\" />";
$page .= "<input type=\"hidden\" name=\"system\" value=\"". $system ."\" />";
$page .= "<input type=\"hidden\" name=\"planet\" value=\"". $position ."\" />";
$page .= "<input type=\"hidden\" name=\"planet_type\" value=\"". $planetType ."\" />";
$page .= "<input type=\"hidden\" name=\"mission\" value=\"". $targetMission ."\" />";
$page .= "<input type=\"hidden\" name=\"maxepedition\" value=\"". $EnvoiMaxExpedition ."\" />";
$page .= "<input type=\"hidden\" name=\"curepedition\" value=\"". $ExpeditionEnCours ."\" />";
$page .= "<input type=\"hidden\" name=\"target_mission\" value=\"". $targetMission ."\" />";
$page .= "</form>";
$page .= "</center>";
display($page, $lang['fl_title']);