1 | <?php |
---|
2 | require_once("db.php"); |
---|
3 | require_once("class.item.php"); |
---|
4 | require_once("class.corp.php"); |
---|
5 | require_once("class.alliance.php"); |
---|
6 | require_once("class.ship.php"); |
---|
7 | require_once("class.system.php"); |
---|
8 | require_once("class.pilot.php"); |
---|
9 | require_once("class.killlist.php"); |
---|
10 | |
---|
11 | class Kill |
---|
12 | { |
---|
13 | function Kill($id = 0) |
---|
14 | { |
---|
15 | $this->id_ = $id; |
---|
16 | $this->involvedparties_ = array(); |
---|
17 | $this->destroyeditems_ = array(); |
---|
18 | } |
---|
19 | |
---|
20 | function getID() |
---|
21 | { |
---|
22 | return $this->id_; |
---|
23 | } |
---|
24 | |
---|
25 | function getTimeStamp() |
---|
26 | { |
---|
27 | $this->execQuery(); |
---|
28 | return $this->timestamp_; |
---|
29 | } |
---|
30 | |
---|
31 | function getVictimName() |
---|
32 | { |
---|
33 | $this->execQuery(); |
---|
34 | return $this->victimname_; |
---|
35 | } |
---|
36 | |
---|
37 | function getVictimID() |
---|
38 | { |
---|
39 | $this->execQuery(); |
---|
40 | return $this->victimid_; |
---|
41 | } |
---|
42 | |
---|
43 | function getVictimPortrait($size = 32) |
---|
44 | { |
---|
45 | $this->execQuery(); |
---|
46 | $plt = new Pilot($this->victimid_); |
---|
47 | return $plt->getPortraitURL($size); |
---|
48 | } |
---|
49 | |
---|
50 | function getVictimCorpID() |
---|
51 | { |
---|
52 | $this->execQuery(); |
---|
53 | return $this->victimcorpid_; |
---|
54 | } |
---|
55 | |
---|
56 | function getVictimCorpName() |
---|
57 | { |
---|
58 | $this->execQuery(); |
---|
59 | return $this->victimcorpname_; |
---|
60 | } |
---|
61 | |
---|
62 | function getVictimAllianceName() |
---|
63 | { |
---|
64 | $this->execQuery(); |
---|
65 | return $this->victimalliancename_; |
---|
66 | } |
---|
67 | |
---|
68 | function getVictimShip() |
---|
69 | { |
---|
70 | $this->execQuery(); |
---|
71 | return $this->victimship_; |
---|
72 | } |
---|
73 | |
---|
74 | function getSystem() |
---|
75 | { |
---|
76 | $this->execQuery(); |
---|
77 | return $this->solarsystem_; |
---|
78 | } |
---|
79 | |
---|
80 | function getFBPilotID() |
---|
81 | { |
---|
82 | $this->execQuery(); |
---|
83 | if (!$this->fbpilotid_) return "null"; |
---|
84 | else return $this->fbpilotid_; |
---|
85 | } |
---|
86 | |
---|
87 | function getFBPilotName() |
---|
88 | { |
---|
89 | $this->execQuery(); |
---|
90 | return $this->fbpilotname_; |
---|
91 | } |
---|
92 | |
---|
93 | function getFBCorpID() |
---|
94 | { |
---|
95 | $this->execQuery(); |
---|
96 | if (!$this->fbcorpid_) return "null"; |
---|
97 | else return $this->fbcorpid_; |
---|
98 | } |
---|
99 | |
---|
100 | function getFBCorpName() |
---|
101 | { |
---|
102 | $this->execQuery(); |
---|
103 | return $this->fbcorpname_; |
---|
104 | } |
---|
105 | |
---|
106 | function getFBAllianceID() |
---|
107 | { |
---|
108 | $this->execQuery(); |
---|
109 | if (!$this->fballianceid_) return "null"; |
---|
110 | else return $this->fballianceid_; |
---|
111 | } |
---|
112 | |
---|
113 | function getFBAllianceName() |
---|
114 | { |
---|
115 | $this->execQuery(); |
---|
116 | return $this->fballiancename_; |
---|
117 | } |
---|
118 | |
---|
119 | function getKillPoints() |
---|
120 | { |
---|
121 | $this->execQuery(); |
---|
122 | return $this->killpoints_; |
---|
123 | } |
---|
124 | |
---|
125 | function getSolarSystemName() |
---|
126 | { |
---|
127 | return $this->solarsystemname_; |
---|
128 | } |
---|
129 | |
---|
130 | function getSolarSystemSecurity() |
---|
131 | { |
---|
132 | return $this->solarsystemsecurity_; |
---|
133 | } |
---|
134 | |
---|
135 | function getVictimShipName() |
---|
136 | { |
---|
137 | return $this->victimshipname_; |
---|
138 | } |
---|
139 | |
---|
140 | function getVictimShipExternalID() |
---|
141 | { |
---|
142 | return $this->victimshipexternalid_; |
---|
143 | } |
---|
144 | |
---|
145 | function getVictimShipClassName() |
---|
146 | { |
---|
147 | return $this->victimshipclassname_; |
---|
148 | } |
---|
149 | |
---|
150 | function getVictimShipValue() |
---|
151 | { |
---|
152 | return $this->victimshipvalue_; |
---|
153 | } |
---|
154 | |
---|
155 | function getVictimShipImage($size) |
---|
156 | { |
---|
157 | return IMG_URL . "/ships/" . $size . "_" . $size . "/" |
---|
158 | . $this->victimshipexternalid_ . ".png"; |
---|
159 | } |
---|
160 | |
---|
161 | function getVictimShipValueIndicator() |
---|
162 | { |
---|
163 | $value = $this->getVictimShipValue(); |
---|
164 | |
---|
165 | if ($value >= 0 && $value <= 1) |
---|
166 | $color = "gray"; |
---|
167 | elseif ($value > 1 && $value <= 15) |
---|
168 | $color = "blue"; |
---|
169 | elseif ($value > 15 && $value <= 25) |
---|
170 | $color = "green"; |
---|
171 | elseif ($value > 25 && $value <= 40) |
---|
172 | $color = "yellow"; |
---|
173 | elseif ($value > 40 && $value <= 80) |
---|
174 | $color = "red"; |
---|
175 | elseif ($value > 80 && $value <= 250) |
---|
176 | $color = "orange"; |
---|
177 | elseif ($value > 250 && $value <= 5000) |
---|
178 | $color = "purple"; |
---|
179 | |
---|
180 | return IMG_URL . "/ships/ship-" . $color . ".gif"; |
---|
181 | } |
---|
182 | |
---|
183 | function getRawMail() |
---|
184 | { |
---|
185 | $this->execQuery(); |
---|
186 | |
---|
187 | $mail .= substr(str_replace('-', '.' , $this->getTimeStamp()), 0, 16) . "\r\n\r\n"; |
---|
188 | $mail .= "Victim: " . $this->getVictimName() . "\r\n"; |
---|
189 | $mail .= "Alliance: " . $this->getVictimAllianceName() . "\r\n"; |
---|
190 | $mail .= "Corp: " . $this->getVictimCorpName() . "\r\n"; |
---|
191 | $ship = $this->getVictimShip(); |
---|
192 | $mail .= "Destroyed: " . $ship->getName() . "\r\n"; |
---|
193 | $system = $this->getSystem(); |
---|
194 | $mail .= "System: " . $system->getName() . "\r\n"; |
---|
195 | $mail .= "Security: " . $system->getSecurity(true) . "\r\n\r\n"; |
---|
196 | $mail .= "Involved parties:\r\n\r\n"; |
---|
197 | |
---|
198 | foreach ($this->involvedparties_ as $inv) |
---|
199 | { |
---|
200 | $pilot = new Pilot($inv->getPilotID()); |
---|
201 | $corp = new Corporation($inv->getCorpID()); |
---|
202 | $alliance = new Alliance($inv->getAllianceID()); |
---|
203 | |
---|
204 | $weapon = $inv->getWeapon(); |
---|
205 | $ship = $inv->getShip(); |
---|
206 | if ($pilot->getName() == $weapon->getName()) |
---|
207 | $name = $pilot->getName() . " / " . $corp->getName(); |
---|
208 | else |
---|
209 | $name = $pilot->getName(); |
---|
210 | |
---|
211 | $mail .= "Name: " . $name; |
---|
212 | if ($pilot->getID() == $this->getFBPilotID()) |
---|
213 | $mail .= " (laid the final blow)"; |
---|
214 | $mail .= "\r\n"; |
---|
215 | |
---|
216 | if ($pilot->getName() != $weapon->getName()) |
---|
217 | { |
---|
218 | $mail .= "Security: " . $inv->getSecStatus() . "\r\n"; |
---|
219 | $mail .= "Alliance: " . $alliance->getName() . "\r\n"; |
---|
220 | $mail .= "Corp: " . $corp->getName() . "\r\n"; |
---|
221 | $mail .= "Ship: " . $ship->getName() . "\r\n"; |
---|
222 | $mail .= "Weapon: " . $weapon->getName() . "\r\n"; |
---|
223 | } |
---|
224 | $mail .= "\r\n"; |
---|
225 | } |
---|
226 | |
---|
227 | if (count($this->destroyeditems_) > 0) |
---|
228 | { |
---|
229 | $mail .= "\r\nDestroyed items:\r\n\r\n"; |
---|
230 | |
---|
231 | foreach($this->destroyeditems_ as $destroyed) |
---|
232 | { |
---|
233 | $item = $destroyed->getItem(); |
---|
234 | $mail .= $item->getName(); |
---|
235 | if ($destroyed->getQuantity() > 1) |
---|
236 | $mail .= ", Qty: " . $destroyed->getQuantity(); |
---|
237 | if ($destroyed->getLocationID() == 4) // cargo |
---|
238 | $mail .= " (Cargo)"; |
---|
239 | if ($destroyed->getLocationID() == 6) // drone |
---|
240 | $mail .= " (Drone Bay)"; |
---|
241 | $mail .= "\r\n"; |
---|
242 | } |
---|
243 | } |
---|
244 | |
---|
245 | return $mail; |
---|
246 | } |
---|
247 | |
---|
248 | function getDupe() |
---|
249 | { |
---|
250 | $this->execQuery(); |
---|
251 | $dupe = 0; |
---|
252 | $qry = new DBQuery(); |
---|
253 | if (!$this->getFBPilotID() || !$this->victimid_) |
---|
254 | return 0; |
---|
255 | $qry->execute("select kll_id |
---|
256 | from kb3_kills |
---|
257 | where kll_timestamp <= |
---|
258 | date_add( '" . $this->timestamp_ . "', INTERVAL '15:0' MINUTE_SECOND ) |
---|
259 | and kll_timestamp >= |
---|
260 | date_sub( '" . $this->timestamp_ . "', INTERVAL '15:0' MINUTE_SECOND ) |
---|
261 | and kll_victim_id = " . $this->victimid_ . " |
---|
262 | and kll_ship_id = " . $this->victimship_->getID() . " |
---|
263 | and kll_system_id = " . $this->solarsystem_->getID() . " |
---|
264 | and kll_fb_plt_id = " . $this->getFBPilotID() . " |
---|
265 | and kll_id != " . $this->id_); |
---|
266 | |
---|
267 | $row = $qry->getRow(); |
---|
268 | if ($row) |
---|
269 | return $row['kll_id']; |
---|
270 | else |
---|
271 | return 0; |
---|
272 | } |
---|
273 | |
---|
274 | function execQuery() |
---|
275 | { |
---|
276 | if (!$this->timestamp_) |
---|
277 | { |
---|
278 | $qry = new DBQuery(); |
---|
279 | |
---|
280 | $this->qry_ = new DBQuery(); |
---|
281 | $this->sql_ = "select kll.kll_id, kll.kll_timestamp, plt.plt_name, |
---|
282 | crp.crp_name, ali.all_name, kll.kll_ship_id, |
---|
283 | kll.kll_system_id, kll.kll_ship_id, |
---|
284 | kll.kll_victim_id, plt.plt_externalid, |
---|
285 | kll.kll_crp_id, kll.kll_points, |
---|
286 | fbplt.plt_id as fbplt_id, |
---|
287 | fbcrp.crp_id as fbcrp_id, |
---|
288 | fbali.all_id as fbali_id, |
---|
289 | fbplt.plt_name as fbplt_name, |
---|
290 | fbcrp.crp_name as fbcrp_name, |
---|
291 | fbali.all_name as fbali_name |
---|
292 | from kb3_kills kll, kb3_pilots plt, kb3_corps crp, |
---|
293 | kb3_alliances ali, kb3_alliances fbali, kb3_corps fbcrp, |
---|
294 | kb3_pilots fbplt |
---|
295 | where kll.kll_id = " . $this->id_ . " |
---|
296 | and plt.plt_id = kll.kll_victim_id |
---|
297 | and crp.crp_id = kll.kll_crp_id |
---|
298 | and ali.all_id = kll.kll_all_id |
---|
299 | and fbali.all_id = kll.kll_fb_all_id |
---|
300 | and fbcrp.crp_id = kll.kll_fb_crp_id |
---|
301 | and fbplt.plt_id = kll.kll_fb_plt_id"; |
---|
302 | |
---|
303 | $this->qry_->execute($this->sql_); |
---|
304 | $row = $this->qry_->getRow(); |
---|
305 | $this->setTimeStamp($row['kll_timestamp']); |
---|
306 | $this->setSolarSystem(new SolarSystem($row['kll_system_id'])); |
---|
307 | $this->setVictimID($row['kll_victim_id']); |
---|
308 | $this->setVictimName($row['plt_name']); |
---|
309 | $this->setVictimCorpID($row['kll_crp_id']); |
---|
310 | $this->setVictimCorpName($row['crp_name']); |
---|
311 | $this->setVictimAllianceName($row['all_name']); |
---|
312 | $this->setVictimShip(new Ship($row['kll_ship_id'])); |
---|
313 | $this->setFBPilotID($row['fbplt_id']); |
---|
314 | $this->setFBPilotName($row['fbplt_name']); |
---|
315 | $this->setFBCorpID($row['fbcrp_id']); |
---|
316 | $this->setFBCorpName($row['fbcrp_name']); |
---|
317 | $this->setFBAllianceID($row['fbali_id']); |
---|
318 | $this->setFBAllianceName($row['fbali_name']); |
---|
319 | $this->setKillPoints($row['kll_points']); |
---|
320 | |
---|
321 | if (!$row) |
---|
322 | $this->valid_ = false; |
---|
323 | else |
---|
324 | $this->valid_ = true; |
---|
325 | // involved |
---|
326 | $sql = "select ind_plt_id, ind_crp_id, ind_all_id, ind_sec_status, |
---|
327 | ind_shp_id, ind_wep_id |
---|
328 | from kb3_inv_detail |
---|
329 | where ind_kll_id = " . $this->getID() . " |
---|
330 | order by ind_order"; |
---|
331 | |
---|
332 | $qry->execute($sql) or die($qry->getErrorMsg()); |
---|
333 | while ($row = $qry->getRow()) |
---|
334 | { |
---|
335 | $involved = new InvolvedParty($row['ind_plt_id'], |
---|
336 | $row['ind_crp_id'], |
---|
337 | $row['ind_all_id'], |
---|
338 | $row['ind_sec_status'], |
---|
339 | new Ship($row['ind_shp_id']), |
---|
340 | new Item($row['ind_wep_id'])); |
---|
341 | array_push($this->involvedparties_, $involved); |
---|
342 | } |
---|
343 | // destroyed items |
---|
344 | $sql = "select sum( itd.itd_quantity ) as itd_quantity, itd_itm_id, |
---|
345 | itd_itl_id, itl_location |
---|
346 | from kb3_items_destroyed itd, kb3_items itm, |
---|
347 | kb3_item_locations itl |
---|
348 | where itd.itd_kll_id = " . $this->getID() . " |
---|
349 | and itd.itd_itm_id = itm.itm_id |
---|
350 | and ( itd.itd_itl_id = itl.itl_id or itd.itd_itl_id = 0 ) |
---|
351 | group by itd_itm_id, itd_itl_id |
---|
352 | order by itd.itd_itl_id, itm.itm_type"; |
---|
353 | |
---|
354 | $qry->execute($sql) or die($qry->getErrorMsg()); |
---|
355 | while ($row = $qry->getRow()) |
---|
356 | { |
---|
357 | $destroyed = new DestroyedItem(new Item($row['itd_itm_id']), |
---|
358 | $row['itd_quantity'], |
---|
359 | $row['itl_location']); |
---|
360 | array_push($this->destroyeditems_, $destroyed); |
---|
361 | } |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | function exists() |
---|
366 | { |
---|
367 | $this->execQuery(); |
---|
368 | return $this->valid_; |
---|
369 | } |
---|
370 | |
---|
371 | function relatedKillCount() |
---|
372 | { |
---|
373 | $kslist = new KillList(); |
---|
374 | $kslist->setRelated($this->id_); |
---|
375 | if (CORP_ID) |
---|
376 | $kslist->addInvolvedCorp(new Corporation(CORP_ID)); |
---|
377 | if (ALLIANCE_ID) |
---|
378 | $kslist->addInvolvedAlliance(new Alliance(ALLIANCE_ID)); |
---|
379 | |
---|
380 | return $kslist->getCount(); |
---|
381 | } |
---|
382 | |
---|
383 | function relatedLossCount() |
---|
384 | { |
---|
385 | $lslist = new KillList(); |
---|
386 | $lslist->setRelated($this->id_); |
---|
387 | if (CORP_ID) |
---|
388 | $lslist->addVictimCorp(new Corporation(CORP_ID)); |
---|
389 | if (ALLIANCE_ID) |
---|
390 | $lslist->addVictimAlliance(new Alliance(ALLIANCE_ID)); |
---|
391 | |
---|
392 | return $lslist->getCount(); |
---|
393 | } |
---|
394 | |
---|
395 | function setID($id) |
---|
396 | { |
---|
397 | $this->id_ = $id; |
---|
398 | } |
---|
399 | |
---|
400 | function setTimeStamp($timestamp) |
---|
401 | { |
---|
402 | $this->timestamp_ = $timestamp; |
---|
403 | } |
---|
404 | |
---|
405 | function setSolarSystem($solarsystem) |
---|
406 | { |
---|
407 | $this->solarsystem_ = $solarsystem; |
---|
408 | } |
---|
409 | |
---|
410 | function setSolarSystemName($solarsystemname) |
---|
411 | { |
---|
412 | $this->solarsystemname_ = $solarsystemname; |
---|
413 | } |
---|
414 | |
---|
415 | function setSolarSystemSecurity($solarsystemsecurity) |
---|
416 | { |
---|
417 | $this->solarsystemsecurity_ = $solarsystemsecurity; |
---|
418 | } |
---|
419 | |
---|
420 | function setVictim($victim) |
---|
421 | { |
---|
422 | $this->victim_ = $victim; |
---|
423 | } |
---|
424 | |
---|
425 | function setVictimID($victimid) |
---|
426 | { |
---|
427 | $this->victimid_ = $victimid; |
---|
428 | } |
---|
429 | |
---|
430 | function setVictimName($victimname) |
---|
431 | { |
---|
432 | $this->victimname_ = $victimname; |
---|
433 | } |
---|
434 | |
---|
435 | function setVictimCorpID($victimcorpid) |
---|
436 | { |
---|
437 | $this->victimcorpid_ = $victimcorpid; |
---|
438 | } |
---|
439 | |
---|
440 | function setVictimCorpName($victimcorpname) |
---|
441 | { |
---|
442 | $this->victimcorpname_ = $victimcorpname; |
---|
443 | } |
---|
444 | |
---|
445 | function setVictimAllianceID($victimallianceid) |
---|
446 | { |
---|
447 | $this->victimallianceid_ = $victimallianceid; |
---|
448 | } |
---|
449 | |
---|
450 | function setVictimAllianceName($victimalliancename) |
---|
451 | { |
---|
452 | $this->victimalliancename_ = $victimalliancename; |
---|
453 | } |
---|
454 | |
---|
455 | function setVictimShip($victimship) |
---|
456 | { |
---|
457 | $this->victimship_ = $victimship; |
---|
458 | } |
---|
459 | |
---|
460 | function setVictimShipName($victimshipname) |
---|
461 | { |
---|
462 | $this->victimshipname_ = $victimshipname; |
---|
463 | } |
---|
464 | |
---|
465 | function setVictimShipExternalID($victimshipexternalid) |
---|
466 | { |
---|
467 | $this->victimshipexternalid_ = $victimshipexternalid; |
---|
468 | } |
---|
469 | |
---|
470 | function setVictimShipClassName($victimshipclassname) |
---|
471 | { |
---|
472 | $this->victimshipclassname_ = $victimshipclassname; |
---|
473 | } |
---|
474 | |
---|
475 | function setVictimShipValue($victimshipvalue) |
---|
476 | { |
---|
477 | $this->victimshipvalue_ = $victimshipvalue; |
---|
478 | } |
---|
479 | |
---|
480 | function setFBPilotID($fbpilotid) |
---|
481 | { |
---|
482 | $this->fbpilotid_ = $fbpilotid; |
---|
483 | } |
---|
484 | |
---|
485 | function setFBPilotName($fbpilotname) |
---|
486 | { |
---|
487 | $this->fbpilotname_ = $fbpilotname; |
---|
488 | } |
---|
489 | |
---|
490 | function setFBCorpID($fbcorpid) |
---|
491 | { |
---|
492 | $this->fbcorpid_ = $fbcorpid; |
---|
493 | } |
---|
494 | |
---|
495 | function setFBCorpName($fbcorpname) |
---|
496 | { |
---|
497 | $this->fbcorpname_ = $fbcorpname; |
---|
498 | } |
---|
499 | |
---|
500 | function setFBAllianceID($fballianceid) |
---|
501 | { |
---|
502 | $this->fballianceid_ = $fballianceid; |
---|
503 | } |
---|
504 | |
---|
505 | function setFBAllianceName($fballiancename) |
---|
506 | { |
---|
507 | $this->fballiancename_ = $fballiancename; |
---|
508 | } |
---|
509 | function setKillPoints($killpoints) |
---|
510 | { |
---|
511 | $this->killpoints_ = $killpoints; |
---|
512 | } |
---|
513 | |
---|
514 | function calculateKillPoints() |
---|
515 | { |
---|
516 | $ship = $this->getVictimShip(); |
---|
517 | $shipclass = $ship->getClass(); |
---|
518 | $vicpoints = $shipclass->getPoints(); |
---|
519 | $maxpoints = round($vicpoints * 1.2); |
---|
520 | |
---|
521 | foreach ($this->involvedparties_ as $inv) |
---|
522 | { |
---|
523 | $shipinv = $inv->getShip(); |
---|
524 | $shipclassinv = $shipinv->getClass(); |
---|
525 | $invpoints += $shipclassinv->getPoints(); |
---|
526 | } |
---|
527 | |
---|
528 | $gankfactor = $vicpoints / ($vicpoints + $invpoints); |
---|
529 | $points = ceil($vicpoints * ($gankfactor / 0.75)); |
---|
530 | |
---|
531 | if ($points > $maxpoints) $points = $maxpoints; |
---|
532 | |
---|
533 | $points = round($points, 0); |
---|
534 | return $points; |
---|
535 | } |
---|
536 | |
---|
537 | function add() |
---|
538 | { |
---|
539 | // if ( $this->timestamp_ == "" || !$this->victimid_ || !$this->victimship_->getID() || !$this->solarsystem_->getID() || |
---|
540 | // !$this->victimallianceid_ || !$this->victimcorpid_ || !$this->getFBAllianceID() || !$this->getFBCorpID() || |
---|
541 | // !$this->getFBPilotID() ) |
---|
542 | // return 0; |
---|
543 | $qry = new DBQuery(); |
---|
544 | $qry->execute("select kll_id |
---|
545 | from kb3_kills |
---|
546 | where kll_timestamp <= |
---|
547 | date_add( '" . $this->timestamp_ . "', INTERVAL '15:0' MINUTE_SECOND ) |
---|
548 | and kll_timestamp >= |
---|
549 | date_sub( '" . $this->timestamp_ . "', INTERVAL '15:0' MINUTE_SECOND ) |
---|
550 | and kll_victim_id = " . $this->victimid_ . " |
---|
551 | and kll_ship_id = " . $this->victimship_->getID() . " |
---|
552 | and kll_system_id = " . $this->solarsystem_->getID() . " |
---|
553 | and kll_fb_plt_id = " . $this->getFBPilotID()) or die($qry->getErrorMsg()); |
---|
554 | |
---|
555 | if ($qry->recordCount() == 0) |
---|
556 | { |
---|
557 | $sql = "insert into kb3_kills |
---|
558 | values ( null, |
---|
559 | date_format('" . $this->timestamp_ . "', '%Y.%m.%d %H:%i:%s'), |
---|
560 | " . $this->victimid_ . ", " . $this->victimallianceid_ . ", |
---|
561 | " . $this->victimcorpid_ . ", " . $this->victimship_->getID() . ", |
---|
562 | " . $this->solarsystem_->getID() . ", " . $this->getFBAllianceID() . ", |
---|
563 | " . $this->getFBCorpID() . ", " . $this->getFBPilotID() . ", " . $this->calculateKillPoints() . " )"; |
---|
564 | $qry->execute($sql) or die($qry->getErrorMsg()); |
---|
565 | $this->id_ = $qry->getInsertID(); |
---|
566 | // involved |
---|
567 | $order = 0; |
---|
568 | $invall = array(); |
---|
569 | $invcrp = array(); |
---|
570 | $invplt = array(); |
---|
571 | foreach ($this->involvedparties_ as $inv) |
---|
572 | { |
---|
573 | $ship = $inv->getShip(); |
---|
574 | $weapon = $inv->getWeapon(); |
---|
575 | if (!$inv->getPilotID() || $inv->getSecStatus() == "" || !$inv->getAllianceID() || !$inv->getCorpID() || !$ship->getID() || !$weapon->getID()) |
---|
576 | { |
---|
577 | $this->remove(); |
---|
578 | return 0; |
---|
579 | } |
---|
580 | |
---|
581 | $sql = "insert into kb3_inv_detail |
---|
582 | values ( " . $this->getID() . ", " . $inv->getPilotID() . ", '" . $inv->getSecStatus() . "', " |
---|
583 | . $inv->getAllianceID() . ", " . $inv->getCorpID() . ", " . $ship->getID() . ", " |
---|
584 | . $weapon->getID() . ", " . $order++ . " )"; |
---|
585 | $qry->execute($sql) or die($qry->getErrorMsg()); |
---|
586 | |
---|
587 | if (!in_array($inv->getAllianceID(), $invall) && $inv->getAllianceID() != 14) |
---|
588 | { |
---|
589 | array_push($invall, $inv->getAllianceID()); |
---|
590 | $qry->execute("insert into kb3_inv_all values ( " . $this->getID() . ", " . $inv->getAllianceID() . " )") or die($qry->getErrorMsg()); |
---|
591 | } |
---|
592 | if (!in_array($inv->getCorpID(), $invcrp)) |
---|
593 | { |
---|
594 | array_push($invcrp, $inv->getCorpID()); |
---|
595 | $qry->execute("insert into kb3_inv_crp values ( " . $this->getID() . ", " . $inv->getCorpID() . " )") or die($qry->getErrorMsg()); |
---|
596 | } |
---|
597 | if (!in_array($inv->getPilotID(), $invplt)) |
---|
598 | { |
---|
599 | array_push($invplt, $inv->getPilotID()); |
---|
600 | $qry->execute("insert into kb3_inv_plt values ( " . $this->getID() . ", " . $inv->getPilotID() . " )") or die($qry->getErrorMsg()); |
---|
601 | } |
---|
602 | } |
---|
603 | // destroyed |
---|
604 | foreach ($this->destroyeditems_ as $dest) |
---|
605 | { |
---|
606 | $item = $dest->getItem(); |
---|
607 | if (!$item->getID() || !$dest->getQuantity() || !$dest->getLocationID()) |
---|
608 | continue; |
---|
609 | |
---|
610 | $sql = "insert into kb3_items_destroyed |
---|
611 | values ( " . $this->getID() . ", " . $item->getID() . ", " . $dest->getQuantity() . ", " |
---|
612 | . $dest->getLocationID() . " )"; |
---|
613 | $qry->execute($sql) or die($qry->getErrorMsg()); |
---|
614 | } |
---|
615 | } |
---|
616 | else |
---|
617 | { |
---|
618 | $row = $qry->getRow(); |
---|
619 | $this->dupeid_ = $row['kll_id']; |
---|
620 | $this->id_ = -1; |
---|
621 | } |
---|
622 | return $this->id_; |
---|
623 | } |
---|
624 | |
---|
625 | function remove() |
---|
626 | { |
---|
627 | if (!$this->id_) |
---|
628 | return; |
---|
629 | |
---|
630 | $qry = new DBQuery(); |
---|
631 | $qry->execute("delete from kb3_kills |
---|
632 | where kll_id = " . $this->id_); |
---|
633 | $qry->execute("delete from kb3_inv_detail |
---|
634 | where ind_kll_id = " . $this->id_); |
---|
635 | $qry->execute("delete from kb3_inv_all |
---|
636 | where ina_kll_id = " . $this->id_); |
---|
637 | $qry->execute("delete from kb3_inv_crp |
---|
638 | where inc_kll_id = " . $this->id_); |
---|
639 | $qry->execute("delete from kb3_inv_plt |
---|
640 | where inp_kll_id = " . $this->id_); |
---|
641 | $qry->execute("delete from kb3_items_destroyed |
---|
642 | where itd_kll_id = " . $this->id_); |
---|
643 | } |
---|
644 | |
---|
645 | function addInvolvedParty($involved) |
---|
646 | { |
---|
647 | array_push($this->involvedparties_, $involved); |
---|
648 | } |
---|
649 | |
---|
650 | function addDestroyedItem($destroyed) |
---|
651 | { |
---|
652 | array_push($this->destroyeditems_, $destroyed); |
---|
653 | } |
---|
654 | } |
---|
655 | |
---|
656 | class InvolvedParty |
---|
657 | { |
---|
658 | function InvolvedParty($pilotid, $corpid, $allianceid, |
---|
659 | $secstatus, $ship, $weapon) |
---|
660 | { |
---|
661 | $this->pilotid_ = $pilotid; |
---|
662 | $this->corpid_ = $corpid; |
---|
663 | $this->allianceid_ = $allianceid; |
---|
664 | $this->secstatus_ = $secstatus; |
---|
665 | $this->ship_ = $ship; |
---|
666 | $this->weapon_ = $weapon; |
---|
667 | } |
---|
668 | |
---|
669 | function getPilotID() |
---|
670 | { |
---|
671 | return $this->pilotid_; |
---|
672 | } |
---|
673 | |
---|
674 | function getCorpID() |
---|
675 | { |
---|
676 | return $this->corpid_; |
---|
677 | } |
---|
678 | |
---|
679 | function getAllianceID() |
---|
680 | { |
---|
681 | return $this->allianceid_; |
---|
682 | } |
---|
683 | |
---|
684 | function getSecStatus() |
---|
685 | { |
---|
686 | return $this->secstatus_; |
---|
687 | } |
---|
688 | |
---|
689 | function getShip() |
---|
690 | { |
---|
691 | return $this->ship_; |
---|
692 | } |
---|
693 | |
---|
694 | function getWeapon() |
---|
695 | { |
---|
696 | return $this->weapon_; |
---|
697 | } |
---|
698 | } |
---|
699 | |
---|
700 | class DestroyedItem |
---|
701 | { |
---|
702 | function DestroyedItem($item, $quantity, $location) |
---|
703 | { |
---|
704 | $this->item_ = $item; |
---|
705 | $this->quantity_ = $quantity; |
---|
706 | $this->location_ = $location; |
---|
707 | } |
---|
708 | |
---|
709 | function getItem() |
---|
710 | { |
---|
711 | return $this->item_; |
---|
712 | } |
---|
713 | |
---|
714 | function getQuantity() |
---|
715 | { |
---|
716 | if ($this->quantity_ == "") $this->quantity = 1; |
---|
717 | return $this->quantity_; |
---|
718 | } |
---|
719 | |
---|
720 | function getLocationID() |
---|
721 | { |
---|
722 | $id = 0; |
---|
723 | if (strlen($this->location_) < 2) |
---|
724 | { |
---|
725 | $id = $this->item_->getSlot(); |
---|
726 | } |
---|
727 | else |
---|
728 | { |
---|
729 | $qry = new DBQuery(); |
---|
730 | $qry->execute("select itl_id from kb3_item_locations where itl_location = '" . $this->location_ . "'") or die($qry->getErrorMsg()); |
---|
731 | $row = $qry->getRow(); |
---|
732 | $id = $row['itl_id']; |
---|
733 | } |
---|
734 | |
---|
735 | return $id; |
---|
736 | } |
---|
737 | } |
---|
738 | |
---|
739 | ?> |
---|