|
1
|
|
|
<?php |
|
2
|
|
|
/* zKillboard |
|
3
|
|
|
* Copyright (C) 2012-2015 EVE-KILL Team and EVSCO. |
|
4
|
|
|
* |
|
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
6
|
|
|
* it under the terms of the GNU Affero General Public License as published by |
|
7
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
8
|
|
|
* (at your option) any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13
|
|
|
* GNU Affero General Public License for more details. |
|
14
|
|
|
* |
|
15
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
16
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
class Points |
|
20
|
|
|
{ |
|
21
|
|
|
private static $pointsArray = array( |
|
22
|
|
|
324 => array("Assault Ship", 100), |
|
23
|
|
|
397 => array("Assembly Array", 10), |
|
24
|
|
|
1201 => array('Attack Battlecruiser', 300), |
|
25
|
|
|
419 => array("Battlecruiser", 250), |
|
26
|
|
|
27 => array("Battleship", 750), |
|
27
|
|
|
898 => array("Black Ops", 1800), |
|
28
|
|
|
1202 => array("Blockade Runner", 125), |
|
29
|
|
|
883 => array("Capital Industrial Ship", 1000), |
|
30
|
|
|
29 => array("Capsule", 5), |
|
31
|
|
|
547 => array("Carrier", 3000), |
|
32
|
|
|
906 => array("Combat Recon Ship", 350), |
|
33
|
|
|
540 => array("Command Ship", 450), |
|
34
|
|
|
365 => array("Control Tower", 250), |
|
35
|
|
|
471 => array("Corporate Hangar Array", 50), |
|
36
|
|
|
830 => array("Covert Ops", 80), |
|
37
|
|
|
26 => array("Cruiser", 100), |
|
38
|
|
|
838 => array("Cynosural Generator Array", 10), |
|
39
|
|
|
839 => array("Cynosural System Jammer", 50), |
|
40
|
|
|
420 => array("Destroyer", 60), |
|
41
|
|
|
485 => array("Dreadnought", 4000), |
|
42
|
|
|
893 => array("Electronic Attack Ship", 200), |
|
43
|
|
|
439 => array("Electronic Warfare Battery", 50), |
|
44
|
|
|
837 => array("Energy Neutralizing Battery", 50), |
|
45
|
|
|
543 => array("Exhumer", 20), |
|
46
|
|
|
833 => array("Force Recon Ship", 350), |
|
47
|
|
|
513 => array("Freighter", 300), |
|
48
|
|
|
25 => array("Frigate", 50), |
|
49
|
|
|
358 => array("Heavy Assault Ship", 400), |
|
50
|
|
|
894 => array("Heavy Interdictor", 600), |
|
51
|
|
|
28 => array("Industrial", 20), |
|
52
|
|
|
941 => array("Industrial Command Ship", 800), |
|
53
|
|
|
1012 => array("Infrastructure Hubs", 500), |
|
54
|
|
|
831 => array("Interceptor", 60), |
|
55
|
|
|
541 => array("Interdictor", 60), |
|
56
|
|
|
902 => array("Jump Freighter", 500), |
|
57
|
|
|
707 => array("Jump Portal Array", 10), |
|
58
|
|
|
832 => array("Logistics", 175), |
|
59
|
|
|
900 => array("Marauder", 1000), |
|
60
|
|
|
463 => array("Mining Barge", 20), |
|
61
|
|
|
449 => array("Mobile Hybrid Sentry", 10), |
|
62
|
|
|
413 => array("Mobile Laboratory", 10), |
|
63
|
|
|
430 => array("Mobile Laser Sentry", 10), |
|
64
|
|
|
417 => array("Mobile Missile Sentry", 10), |
|
65
|
|
|
426 => array("Mobile Projectile Sentry", 10), |
|
66
|
|
|
438 => array("Mobile Reactor", 10), |
|
67
|
|
|
416 => array("Moon Mining", 10), |
|
68
|
|
|
1106 => array("Orbital Construction Platform", 5), |
|
69
|
|
|
1025 => array("Orbital Infrastructure", 500), |
|
70
|
|
|
1022 => array("Prototype Exploration Ship", 5), |
|
71
|
|
|
311 => array("Refining Array", 10), |
|
72
|
|
|
237 => array("Rookie ship", 5), |
|
73
|
|
|
709 => array("Scanner Array", 10), |
|
74
|
|
|
440 => array("Sensor Dampening Battery", 10), |
|
75
|
|
|
444 => array("Shield Hardening Array", 10), |
|
76
|
|
|
363 => array("Ship Maintenance Array", 10), |
|
77
|
|
|
31 => array("Shuttle", 5), |
|
78
|
|
|
404 => array("Silo", 10), |
|
79
|
|
|
1005 => array("Sovereignty Blockade Units", 250), |
|
80
|
|
|
441 => array("Stasis Webification Battery", 10), |
|
81
|
|
|
834 => array("Stealth Bomber", 80), |
|
82
|
|
|
963 => array("Strategic Cruiser", 750), |
|
83
|
|
|
659 => array("Supercarrier", 6000), |
|
84
|
|
|
1305 => array("Tactical Destroyer", 450), |
|
85
|
|
|
1003 => array("Territorial Claim Units", 500), |
|
86
|
|
|
30 => array("Titan", 20000), |
|
87
|
|
|
473 => array("Tracking Array", 10), |
|
88
|
|
|
380 => array("Transport Ship", 30), |
|
89
|
|
|
443 => array("Warp Scrambling Battery", 10), |
|
90
|
|
|
); |
|
91
|
|
|
|
|
92
|
|
|
public static function getPointValues() |
|
93
|
|
|
{ |
|
94
|
|
|
return self::$pointsArray; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public static function getPoints($groupID) |
|
|
|
|
|
|
98
|
|
|
{ |
|
99
|
|
|
if (!isset(self::$pointsArray[$groupID])) return 0; |
|
100
|
|
|
$arr = self::$pointsArray[$groupID]; |
|
101
|
|
|
if (!isset($arr[1])) return 0; |
|
102
|
|
|
return $arr[1]; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public static function updatePoints($killID, $tempTables = false) |
|
106
|
|
|
{ |
|
107
|
|
|
$points = self::calculatePoints($killID, $tempTables); |
|
108
|
|
|
$temp = $tempTables ? "_temporary" : ""; |
|
109
|
|
|
Db::execute("update zz_participants$temp set points = :points where killID = :killID", array(":points" => $points, ":killID" => $killID)); |
|
110
|
|
|
return $points; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public static function calculatePoints($killID, $tempTables = false) |
|
114
|
|
|
{ |
|
115
|
|
|
$temp = $tempTables ? "_temporary" : ""; |
|
116
|
|
|
$victim = Db::queryRow("select * from zz_participants$temp where killID = :killID and isVictim = 1", array(":killID" => $killID), 0); |
|
117
|
|
|
$kill = $victim; |
|
118
|
|
|
$involved = Db::query("select * from zz_participants$temp where killID = :killID and isVictim = 0", array(":killID" => $killID), 0); |
|
119
|
|
|
|
|
120
|
|
|
$vicpoints = self::getPoints($victim["groupID"]); |
|
121
|
|
|
$vicpoints += $kill["total_price"] / 10000000; |
|
122
|
|
|
$maxpoints = round($vicpoints * 1.2); |
|
123
|
|
|
|
|
124
|
|
|
$invpoints = 0; |
|
125
|
|
|
foreach ($involved as $inv) |
|
126
|
|
|
{ |
|
127
|
|
|
$invpoints += self::getPoints($inv["groupID"]); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
if (($vicpoints + $invpoints) == 0) return 0; |
|
131
|
|
|
$gankfactor = $vicpoints / ($vicpoints + $invpoints); |
|
132
|
|
|
$points = ceil($vicpoints * ($gankfactor / 0.75)); |
|
133
|
|
|
|
|
134
|
|
|
if ($points > $maxpoints) $points = $maxpoints; |
|
135
|
|
|
|
|
136
|
|
|
$points = round($points, 0); |
|
137
|
|
|
return max(1, $points); // a kill is always worth at least one point |
|
138
|
|
|
} |
|
139
|
|
|
} |
|
140
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.