zkb-points - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of zkb-points.php
- <?php
- <?php
- $killmail = json_decode('[{"killmail_id":105768021,"zkb":{"locationID":50008241,"hash":"56ec85c4b6acda53409a5ae37345a1d91458f493","fittedValue":3922886564.15,"droppedValue":340907511.39,"destroyedValue":3638168196.23,"totalValue":4005843926.69,"points":322,"npc":false,"solo":false,"awox":false}}]');
- $rigSizes = array();$rigSizes[17841]=1;$rigSizes['73796']=1;
- function getRigSize($typeID)
- {
- return $rigSizes[$typeId];
- }
- function getPoints() {
- $victim = $killmail['victim'];
- $shipTypeID = $victim['ship_type_id'];
- $items = $victim['items'];
- $shipInfo = Info::getInfo('typeID', $shipTypeID);
- $rigSize = getRigSize($shipTypeID);;
- $shipInfo['rigSize'] = $rigSize;
- $dangerFactor = 0;
- $basePoints = pow(5, @$shipInfo['rigSize']);
- $points = $basePoints;
- foreach ((array) $items as $item) {
- $itemInfo = Info::getInfo('typeID', $item['item_type_id']);
- if (@$itemInfo['categoryID'] != 7) continue;
- $flagName = Info::getFlagName($item['flag']);
- if (($flagName == "Low Slots" || $flagName == "Mid Slots" || $flagName == "High Slots" || $flagName == 'SubSystems') || ($killID < 23970577 && $item['flag'] == 0) ) {
- $typeID = $item['item_type_id'];
- $qty = @$item['quantity_destroyed'] + @$item['quantity_dropped'];
- $metaLevel = Info::getDogma($typeID, 633);
- $meta = 1 + floor($metaLevel / 2);
- $heatDamage = Info::getDogma($typeID, 1211);
- $dangerFactor += ((bool) $heatDamage) * $qty * $meta; // offensive/defensive modules overloading are good for pvp
- $dangerFactor += ($itemInfo['groupID'] == 645) * $qty * $meta; // drone damange multipliers
- $dangerFactor -= ($itemInfo['groupID'] == 54) * $qty * $meta; // Mining ships don't earn as many points
- }
- }
- $points += $dangerFactor;
- $points *= max(0.01, min(1, $dangerFactor / 4));
- // Divide by number of ships on killmail
- $numAttackers = sizeof($killmail['attackers']);
- $involvedPenalty = max(1, $numAttackers * max(1, $numAttackers / 2));
- $points = $points / $involvedPenalty;
- // Apply a bonus/penalty from -50% to 20% depending on average size of attacking ships
- // For example: Smaller ships blowing up bigger ships get a bonus
- // or bigger ships blowing up smaller ships get a penalty
- $size = 0;
- $hasChar = false;
- foreach ((array) $killmail['attackers'] as $attacker) {
- $hasChar |= @$attacker['character_id'] > 0;
- $shipTypeID = @$attacker['ship_type_id'];
- $categoryID = Info::getInfoField("typeID", $shipTypeID, "categoryID");
- if ($categoryID == 65) return 1; // Structure on your mail, only 1 point
- $aInfo = Info::getInfo('typeID', $shipTypeID);
- $aInfo['rigSize'] = self::getRigSize($shipTypeID);
- $size += pow(5, ((@$aInfo['groupID'] != 29) ? @$aInfo['rigSize'] : @$shipInfo['rigSize'] + 1));
- }
- if ($hasChar == false) return 1;
- $avg = max(1, $size / $numAttackers);
- $modifier = min(1.2, max(0.5, $basePoints / $avg));
- $points = (int) floor($points * $modifier);
- return max(1, $points);
- }
- echo "Points = " + getPoints();
File Description
- zkb-points
- PHP Code
- 14 Jan-2023
- 3.13 Kb
You can Share it:
Latest PHP Pastes