1 | <? |
---|
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 | $pilot = new Pilot( $inv->getPilotID() ); |
---|
200 | $corp = new Corporation( $inv->getCorpID() ); |
---|
201 | $alliance = new Alliance( $inv->getAllianceID() ); |
---|
202 | |
---|
203 | $weapon = $inv->getWeapon(); |
---|
204 | $ship = $inv->getShip(); |
---|
205 | if ( $pilot->getName() == $weapon->getName() ) |
---|
206 | $name = $pilot->getName()." / ".$corp->getName(); |
---|
207 | else |
---|
208 | $name = $pilot->getName(); |
---|
209 | |
---|
210 | $mail .= "Name: ".$name; |
---|
211 | if ( $pilot->getID() == $this->getFBPilotID() ) |
---|
212 | $mail .= " (laid the final blow)"; |
---|
213 | $mail .= "\r\n"; |
---|
214 | |
---|
215 | if ( $pilot->getName() != $weapon->getName() ) { |
---|
216 | $mail .= "Security: ".$inv->getSecStatus()."\r\n"; |
---|
217 | $mail .= "Alliance: ".$alliance->getName()."\r\n"; |
---|
218 | $mail .= "Corp: ".$corp->getName()."\r\n"; |
---|
219 | $mail .= "Ship: ".$ship->getName()."\r\n"; |
---|
220 | $mail .= "Weapon: ".$weapon->getName()."\r\n"; |
---|
221 | } |
---|
222 | $mail .= "\r\n"; |
---|
223 | } |
---|
224 | |
---|
225 | if ( count( $this->destroyeditems_ ) > 0 ) { |
---|
226 | $mail .= "\r\nDestroyed items:\r\n\r\n"; |
---|
227 | |
---|
228 | foreach( $this->destroyeditems_ as $destroyed ) { |
---|
229 | $item = $destroyed->getItem(); |
---|
230 | $mail .= $item->getName(); |
---|
231 | if ( $destroyed->getQuantity() > 1 ) |
---|
232 | $mail .= ", Qty: ".$destroyed->getQuantity(); |
---|
233 | if ( $destroyed->getLocationID() == 4 ) // cargo |
---|
234 | $mail .= " (Cargo)"; |
---|
235 | if ( $destroyed->getLocationID() == 6 ) // drone |
---|
236 | $mail .= " (Drone Bay)"; |
---|
237 | $mail .= "\r\n"; |
---|
238 | } |
---|
239 | } |
---|
240 | |
---|
241 | return $mail; |
---|
242 | } |
---|
243 | |
---|
244 | function getDupe() |
---|
245 | { |
---|
246 | $this->execQuery(); |
---|
247 | $dupe = 0; |
---|
248 | $qry = new DBQuery(); |
---|
249 | if ( !$this->getFBPilotID() || !$this->victimid_ ) |
---|
250 | return 0; |
---|
251 | $qry->execute( "select kll_id |
---|
252 | from kb3_kills |
---|
253 | where kll_timestamp <= |
---|
254 | date_add( '".$this->timestamp_."', INTERVAL '15:0' MINUTE_SECOND ) |
---|
255 | and kll_timestamp >= |
---|
256 | date_sub( '".$this->timestamp_."', INTERVAL '15:0' MINUTE_SECOND ) |
---|
257 | and kll_victim_id = ".$this->victimid_." |
---|
258 | and kll_ship_id = ".$this->victimship_->getID()." |
---|
259 | and kll_system_id = ".$this->solarsystem_->getID()." |
---|
260 | and kll_fb_plt_id = ".$this->getFBPilotID()." |
---|
261 | and kll_id != ".$this->id_ ); |
---|
262 | |
---|
263 | $row = $qry->getRow(); |
---|
264 | if ( $row ) |
---|
265 | return $row['kll_id']; |
---|
266 | else |
---|
267 | return 0; |
---|
268 | } |
---|
269 | |
---|
270 | function execQuery() |
---|
271 | { |
---|
272 | if ( !$this->timestamp_ ) { |
---|
273 | $qry = new DBQuery(); |
---|
274 | |
---|
275 | $this->qry_ = new DBQuery(); |
---|
276 | $this->sql_ = "select kll.kll_id, kll.kll_timestamp, plt.plt_name, |
---|
277 | crp.crp_name, ali.all_name, kll.kll_ship_id, |
---|
278 | kll.kll_system_id, kll.kll_ship_id, |
---|
279 | kll.kll_victim_id, plt.plt_externalid, |
---|
280 | kll.kll_crp_id, kll.kll_points, |
---|
281 | fbplt.plt_id as fbplt_id, |
---|
282 | fbcrp.crp_id as fbcrp_id, |
---|
283 | fbali.all_id as fbali_id, |
---|
284 | fbplt.plt_name as fbplt_name, |
---|
285 | fbcrp.crp_name as fbcrp_name, |
---|
286 | fbali.all_name as fbali_name |
---|
287 | from kb3_kills kll, kb3_pilots plt, kb3_corps crp, |
---|
288 | kb3_alliances ali, kb3_alliances fbali, kb3_corps fbcrp, |
---|
289 | kb3_pilots fbplt |
---|
290 | where kll.kll_id = ".$this->id_." |
---|
291 | and plt.plt_id = kll.kll_victim_id |
---|
292 | and crp.crp_id = kll.kll_crp_id |
---|
293 | and ali.all_id = kll.kll_all_id |
---|
294 | and fbali.all_id = kll.kll_fb_all_id |
---|
295 | and fbcrp.crp_id = kll.kll_fb_crp_id |
---|
296 | and fbplt.plt_id = kll.kll_fb_plt_id"; |
---|
297 | |
---|
298 | |
---|
299 | $this->qry_->execute( $this->sql_ ); |
---|
300 | $row = $this->qry_->getRow(); |
---|
301 | $this->setTimeStamp( $row['kll_timestamp'] ); |
---|
302 | $this->setSolarSystem( new SolarSystem( $row['kll_system_id'] ) ); |
---|
303 | $this->setVictimID( $row['kll_victim_id'] ); |
---|
304 | $this->setVictimName( $row['plt_name'] ); |
---|
305 | $this->setVictimCorpID( $row['kll_crp_id'] ); |
---|
306 | $this->setVictimCorpName( $row['crp_name'] ); |
---|
307 | $this->setVictimAllianceName( $row['all_name'] ); |
---|
308 | $this->setVictimShip( new Ship( $row['kll_ship_id'] ) ); |
---|
309 | $this->setFBPilotID( $row['fbplt_id'] ); |
---|
310 | $this->setFBPilotName( $row['fbplt_name'] ); |
---|
311 | $this->setFBCorpID( $row['fbcrp_id'] ); |
---|
312 | $this->setFBCorpName( $row['fbcrp_name'] ); |
---|
313 | $this->setFBAllianceID( $row['fbali_id'] ); |
---|
314 | $this->setFBAllianceName( $row['fbali_name'] ); |
---|
315 | $this->setKillPoints( $row['kll_points'] ); |
---|
316 | |
---|
317 | if ( !$row ) |
---|
318 | $this->valid_ = false; |
---|
319 | else |
---|
320 | $this->valid_ = true; |
---|
321 | |
---|
322 | // involved |
---|
323 | $sql = "select ind_plt_id, ind_crp_id, ind_all_id, ind_sec_status, |
---|
324 | ind_shp_id, ind_wep_id |
---|
325 | from kb3_inv_detail |
---|
326 | where ind_kll_id = ".$this->getID()." |
---|
327 | order by ind_order"; |
---|
328 | |
---|
329 | $qry->execute( $sql ) or die( $qry->getErrorMsg() ); |
---|
330 | while ( $row = $qry->getRow() ) { |
---|
331 | $involved = new InvolvedParty( $row['ind_plt_id'], |
---|
332 | $row['ind_crp_id'], |
---|
333 | $row['ind_all_id'], |
---|
334 | $row['ind_sec_status'], |
---|
335 | new Ship( $row['ind_shp_id'] ), |
---|
336 | new Item( $row['ind_wep_id'] ) ); |
---|
337 | array_push( $this->involvedparties_, $involved ); |
---|
338 | } |
---|
339 | |
---|
340 | // destroyed items |
---|
341 | $sql = "select sum( itd.itd_quantity ) as itd_quantity, itd_itm_id, |
---|
342 | itd_itl_id, itl_location |
---|
343 | from kb3_items_destroyed itd, kb3_items itm, |
---|
344 | kb3_item_locations itl |
---|
345 | where itd.itd_kll_id = ".$this->getID()." |
---|
346 | and itd.itd_itm_id = itm.itm_id |
---|
347 | and ( itd.itd_itl_id = itl.itl_id or itd.itd_itl_id = 0 ) |
---|
348 | group by itd_itm_id, itd_itl_id |
---|
349 | order by itd.itd_itl_id, itm.itm_type"; |
---|
350 | |
---|
351 | $qry->execute( $sql ) or die( $qry->getErrorMsg() ); |
---|
352 | while ( $row = $qry->getRow() ) { |
---|
353 | $destroyed = new DestroyedItem( new Item( $row['itd_itm_id'] ), |
---|
354 | $row['itd_quantity'], |
---|
355 | $row['itl_location'] ); |
---|
356 | array_push( $this->destroyeditems_, $destroyed ); |
---|
357 | } |
---|
358 | } |
---|
359 | } |
---|
360 | |
---|
361 | function exists() |
---|
362 | { |
---|
363 | $this->execQuery(); |
---|
364 | return $this->valid_; |
---|
365 | } |
---|
366 | |
---|
367 | function relatedKillCount() |
---|
368 | { |
---|
369 | $kslist = new KillList(); |
---|
370 | $kslist->setRelated( $this->id_ ); |
---|
371 | if ( CORP_ID ) |
---|
372 | $kslist->addInvolvedCorp( new Corporation( CORP_ID ) ); |
---|
373 | if ( ALLIANCE_ID ) |
---|
374 | $kslist->addInvolvedAlliance( new Alliance( ALLIANCE_ID ) ); |
---|
375 | |
---|
376 | return $kslist->getCount(); |
---|
377 | } |
---|
378 | |
---|
379 | function relatedLossCount() |
---|
380 | { |
---|
381 | $lslist = new KillList(); |
---|
382 | $lslist->setRelated( $this->id_ ); |
---|
383 | if ( CORP_ID ) |
---|
384 | $lslist->addVictimCorp( new Corporation( CORP_ID ) ); |
---|
385 | if ( ALLIANCE_ID ) |
---|
386 | $lslist->addVictimAlliance( new Alliance( ALLIANCE_ID ) ); |
---|
387 | |
---|
388 | return $lslist->getCount(); |
---|
389 | } |
---|
390 | |
---|
391 | function setID( $id ) |
---|
392 | { |
---|
393 | $this->id_ = $id; |
---|
394 | } |
---|
395 | |
---|
396 | function setTimeStamp( $timestamp ) |
---|
397 | { |
---|
398 | $this->timestamp_ = $timestamp; |
---|
399 | } |
---|
400 | |
---|
401 | function setSolarSystem( $solarsystem ) |
---|
402 | { |
---|
403 | $this->solarsystem_ = $solarsystem; |
---|
404 | } |
---|
405 | |
---|
406 | function setSolarSystemName( $solarsystemname ) |
---|
407 | { |
---|
408 | $this->solarsystemname_ = $solarsystemname; |
---|
409 | } |
---|
410 | |
---|
411 | function setSolarSystemSecurity( $solarsystemsecurity ) |
---|
412 | { |
---|
413 | $this->solarsystemsecurity_ = $solarsystemsecurity; |
---|
414 | } |
---|
415 | |
---|
416 | function setVictim( $victim ) |
---|
417 | { |
---|
418 | $this->victim_ = $victim; |
---|
419 | } |
---|
420 | |
---|
421 | function setVictimID( $victimid ) |
---|
422 | { |
---|
423 | $this->victimid_ = $victimid; |
---|
424 | } |
---|
425 | |
---|
426 | function setVictimName( $victimname ) |
---|
427 | { |
---|
428 | $this->victimname_ = $victimname; |
---|
429 | } |
---|
430 | |
---|
431 | function setVictimCorpID( $victimcorpid ) |
---|
432 | { |
---|
433 | $this->victimcorpid_ = $victimcorpid; |
---|
434 | } |
---|
435 | |
---|
436 | function setVictimCorpName( $victimcorpname ) |
---|
437 | { |
---|
438 | $this->victimcorpname_ = $victimcorpname; |
---|
439 | } |
---|
440 | |
---|
441 | function setVictimAllianceID( $victimallianceid ) |
---|
442 | { |
---|
443 | $this->victimallianceid_ = $victimallianceid; |
---|
444 | } |
---|
445 | |
---|
446 | function setVictimAllianceName( $victimalliancename ) |
---|
447 | { |
---|
448 | $this->victimalliancename_ = $victimalliancename; |
---|
449 | } |
---|
450 | |
---|
451 | function setVictimShip( $victimship ) |
---|
452 | { |
---|
453 | $this->victimship_ = $victimship; |
---|
454 | } |
---|
455 | |
---|
456 | function setVictimShipName( $victimshipname ) |
---|
457 | { |
---|
458 | $this->victimshipname_ = $victimshipname; |
---|
459 | } |
---|
460 | |
---|
461 | function setVictimShipExternalID( $victimshipexternalid ) |
---|
462 | { |
---|
463 | $this->victimshipexternalid_ = $victimshipexternalid; |
---|
464 | } |
---|
465 | |
---|
466 | function setVictimShipClassName( $victimshipclassname ) |
---|
467 | { |
---|
468 | $this->victimshipclassname_ = $victimshipclassname; |
---|
469 | } |
---|
470 | |
---|
471 | function setVictimShipValue( $victimshipvalue ) |
---|
472 | { |
---|
473 | $this->victimshipvalue_ = $victimshipvalue; |
---|
474 | } |
---|
475 | |
---|
476 | function setFBPilotID( $fbpilotid ) |
---|
477 | { |
---|
478 | $this->fbpilotid_ = $fbpilotid; |
---|
479 | } |
---|
480 | |
---|
481 | function setFBPilotName( $fbpilotname ) |
---|
482 | { |
---|
483 | $this->fbpilotname_ = $fbpilotname; |
---|
484 | } |
---|
485 | |
---|
486 | function setFBCorpID( $fbcorpid ) |
---|
487 | { |
---|
488 | $this->fbcorpid_ = $fbcorpid; |
---|
489 | } |
---|
490 | |
---|
491 | function setFBCorpName( $fbcorpname ) |
---|
492 | { |
---|
493 | $this->fbcorpname_ = $fbcorpname; |
---|
494 | } |
---|
495 | |
---|
496 | function setFBAllianceID( $fballianceid ) |
---|
497 | { |
---|
498 | $this->fballianceid_ = $fballianceid; |
---|
499 | } |
---|
500 | |
---|
501 | function setFBAllianceName( $fballiancename ) |
---|
502 | { |
---|
503 | $this->fballiancename_ = $fballiancename; |
---|
504 | } |
---|
505 | function setKillPoints( $killpoints ) |
---|
506 | { |
---|
507 | $this->killpoints_ = $killpoints; |
---|
508 | } |
---|
509 | |
---|
510 | function calculateKillPoints() |
---|
511 | { |
---|
512 | $ship = $this->getVictimShip(); |
---|
513 | $shipclass= $ship->getClass(); |
---|
514 | $vicpoints = $shipclass->getPoints(); |
---|
515 | $maxpoints = round( $vicpoints * 1.2 ); |
---|
516 | foreach ( $this->involvedparties_ as $inv ) { |
---|
517 | $ship = $inv->getShip(); |
---|
518 | $invpoints += $shipclass->getPoints(); |
---|
519 | } |
---|
520 | |
---|
521 | $gankfactor = $vicpoints / ( $vicpoints + $invpoints ); |
---|
522 | $points = ceil( $vicpoints * ( $gankfactor / 0.6 ) ); |
---|
523 | |
---|
524 | if ( $points > $maxpoints ) $points = $maxpoints; |
---|
525 | |
---|
526 | $points = round( $points, 0 ); |
---|
527 | //echo "invpoints:".$invpoints."<br>"; |
---|
528 | //echo "vicpoints:".$vicpoints."<br>"; |
---|
529 | //echo "gankfactor:".$gankfactor."<br>"; |
---|
530 | //echo "points:".$points; |
---|
531 | //exit; |
---|
532 | |
---|
533 | return $points; |
---|
534 | } |
---|
535 | |
---|
536 | function add() |
---|
537 | { |
---|
538 | //if ( $this->timestamp_ == "" || !$this->victimid_ || !$this->victimship_->getID() || !$this->solarsystem_->getID() || |
---|
539 | // !$this->victimallianceid_ || !$this->victimcorpid_ || !$this->getFBAllianceID() || !$this->getFBCorpID() || |
---|
540 | // !$this->getFBPilotID() ) |
---|
541 | // return 0; |
---|
542 | |
---|
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 | $sql = "insert into kb3_kills |
---|
557 | values ( null, |
---|
558 | date_format('".$this->timestamp_."', '%Y.%m.%d %H:%i:%s'), |
---|
559 | ".$this->victimid_.", ".$this->victimallianceid_.", |
---|
560 | ".$this->victimcorpid_.", ".$this->victimship_->getID().", |
---|
561 | ".$this->solarsystem_->getID().", ".$this->getFBAllianceID().", |
---|
562 | ".$this->getFBCorpID().", ".$this->getFBPilotID().", ".$this->calculateKillPoints()." )"; |
---|
563 | $qry->execute( $sql ) or die( $qry->getErrorMsg() ); |
---|
564 | $this->id_ = $qry->getInsertID(); |
---|
565 | |
---|
566 | // involved |
---|
567 | $order = 0; |
---|
568 | $invall = array(); |
---|
569 | $invcrp = array(); |
---|
570 | $invplt = array(); |
---|
571 | foreach ( $this->involvedparties_ as $inv ) { |
---|
572 | $ship = $inv->getShip(); |
---|
573 | $weapon = $inv->getWeapon(); |
---|
574 | if ( !$inv->getPilotID() || $inv->getSecStatus() == "" || !$inv->getAllianceID() || !$inv->getCorpID() || |
---|
575 | !$ship->getID() || !$weapon->getID() ) { |
---|
576 | $this->remove(); |
---|
577 | return 0; |
---|
578 | } |
---|
579 | |
---|
580 | $sql = "insert into kb3_inv_detail |
---|
581 | values ( ".$this->getID().", ".$inv->getPilotID().", '".$inv->getSecStatus()."', " |
---|
582 | .$inv->getAllianceID().", ".$inv->getCorpID().", ".$ship->getID().", " |
---|
583 | .$weapon->getID().", ".$order++." )"; |
---|
584 | $qry->execute( $sql ) or die( $qry->getErrorMsg() ); |
---|
585 | |
---|
586 | if ( !in_array( $inv->getAllianceID(), $invall ) && $inv->getAllianceID() != 14 ) { |
---|
587 | array_push( $invall, $inv->getAllianceID() ); |
---|
588 | $qry->execute( "insert into kb3_inv_all values ( ".$this->getID().", ".$inv->getAllianceID()." )" ) or die( $qry->getErrorMsg() ); |
---|
589 | } |
---|
590 | if ( !in_array( $inv->getCorpID(), $invcrp ) ) { |
---|
591 | array_push( $invcrp, $inv->getCorpID() ); |
---|
592 | $qry->execute( "insert into kb3_inv_crp values ( ".$this->getID().", ".$inv->getCorpID()." )" ) or die( $qry->getErrorMsg() ); |
---|
593 | } |
---|
594 | if ( !in_array( $inv->getPilotID(), $invplt ) ) { |
---|
595 | array_push( $invplt, $inv->getPilotID() ); |
---|
596 | $qry->execute( "insert into kb3_inv_plt values ( ".$this->getID().", ".$inv->getPilotID()." )" ) or die( $qry->getErrorMsg() ); |
---|
597 | } |
---|
598 | } |
---|
599 | |
---|
600 | // destroyed |
---|
601 | foreach ( $this->destroyeditems_ as $dest ) { |
---|
602 | $item = $dest->getItem(); |
---|
603 | if ( !$item->getID() || !$dest->getQuantity() || !$dest->getLocationID() ) |
---|
604 | continue; |
---|
605 | |
---|
606 | $sql = "insert into kb3_items_destroyed |
---|
607 | values ( ".$this->getID().", ".$item->getID().", ".$dest->getQuantity().", " |
---|
608 | .$dest->getLocationID()." )"; |
---|
609 | $qry->execute( $sql ) or die( $qry->getErrorMsg() ); |
---|
610 | } |
---|
611 | } |
---|
612 | else { |
---|
613 | $row = $qry->getRow(); |
---|
614 | $this->dupeid_ = $row['kll_id']; |
---|
615 | $this->id_ = -1; |
---|
616 | } |
---|
617 | return $this->id_; |
---|
618 | } |
---|
619 | |
---|
620 | function remove() |
---|
621 | { |
---|
622 | if ( !$this->id_ ) |
---|
623 | return; |
---|
624 | |
---|
625 | $qry = new DBQuery(); |
---|
626 | $qry->execute( "delete from kb3_kills |
---|
627 | where kll_id = ".$this->id_ ); |
---|
628 | $qry->execute( "delete from kb3_inv_detail |
---|
629 | where ind_kll_id = ".$this->id_ ); |
---|
630 | $qry->execute( "delete from kb3_inv_all |
---|
631 | where ina_kll_id = ".$this->id_ ); |
---|
632 | $qry->execute( "delete from kb3_inv_crp |
---|
633 | where inc_kll_id = ".$this->id_ ); |
---|
634 | $qry->execute( "delete from kb3_inv_plt |
---|
635 | where inp_kll_id = ".$this->id_ ); |
---|
636 | $qry->execute( "delete from kb3_items_destroyed |
---|
637 | where itd_kll_id = ".$this->id_ ); |
---|
638 | } |
---|
639 | |
---|
640 | function addInvolvedParty( $involved ) |
---|
641 | { |
---|
642 | array_push( $this->involvedparties_, $involved ); |
---|
643 | } |
---|
644 | |
---|
645 | function addDestroyedItem( $destroyed ) |
---|
646 | { |
---|
647 | array_push( $this->destroyeditems_, $destroyed ); |
---|
648 | } |
---|
649 | } |
---|
650 | |
---|
651 | class InvolvedParty |
---|
652 | { |
---|
653 | function InvolvedParty( $pilotid, $corpid, $allianceid, |
---|
654 | $secstatus, $ship, $weapon ) |
---|
655 | { |
---|
656 | $this->pilotid_ = $pilotid; |
---|
657 | $this->corpid_ = $corpid; |
---|
658 | $this->allianceid_ = $allianceid; |
---|
659 | $this->secstatus_ = $secstatus; |
---|
660 | $this->ship_ = $ship; |
---|
661 | $this->weapon_ = $weapon; |
---|
662 | } |
---|
663 | |
---|
664 | function getPilotID() |
---|
665 | { |
---|
666 | return $this->pilotid_; |
---|
667 | } |
---|
668 | |
---|
669 | function getCorpID() |
---|
670 | { |
---|
671 | return $this->corpid_; |
---|
672 | } |
---|
673 | |
---|
674 | function getAllianceID() |
---|
675 | { |
---|
676 | return $this->allianceid_; |
---|
677 | } |
---|
678 | |
---|
679 | function getSecStatus() |
---|
680 | { |
---|
681 | return $this->secstatus_; |
---|
682 | } |
---|
683 | |
---|
684 | function getShip() |
---|
685 | { |
---|
686 | return $this->ship_; |
---|
687 | } |
---|
688 | |
---|
689 | function getWeapon() |
---|
690 | { |
---|
691 | return $this->weapon_; |
---|
692 | } |
---|
693 | } |
---|
694 | |
---|
695 | class DestroyedItem |
---|
696 | { |
---|
697 | function DestroyedItem( $item, $quantity, $location ) |
---|
698 | { |
---|
699 | $this->item_ = $item; |
---|
700 | $this->quantity_ = $quantity; |
---|
701 | $this->location_ = $location; |
---|
702 | } |
---|
703 | |
---|
704 | function getItem() |
---|
705 | { |
---|
706 | return $this->item_; |
---|
707 | } |
---|
708 | |
---|
709 | function getQuantity() |
---|
710 | { |
---|
711 | if ( $this->quantity_ == "" ) $this->quantity = 1; |
---|
712 | return $this->quantity_; |
---|
713 | } |
---|
714 | |
---|
715 | function getLocationID() |
---|
716 | { |
---|
717 | $id = 0; |
---|
718 | if ( strlen( $this->location_ ) < 2 ) { |
---|
719 | $id = $this->item_->getSlot(); |
---|
720 | } |
---|
721 | else { |
---|
722 | $qry = new DBQuery(); |
---|
723 | $qry->execute( "select itl_id from kb3_item_locations where itl_location = '".$this->location_."'" ) or die( $qry->getErrorMsg() ); |
---|
724 | $row = $qry->getRow(); |
---|
725 | $id = $row['itl_id']; |
---|
726 | } |
---|
727 | |
---|
728 | return $id; |
---|
729 | } |
---|
730 | } |
---|
731 | ?> |
---|