/**
 * gets the sorting weight for a ship class
 * @param ShipClass $shipClass
 * @return int
 */
function getShipClassSortWeight($shipClass)
{
    $shipClassId = $shipClass->getID();
    switch ($shipClassId) {
        // Battleship
        case 1:
            return 60;
            // Capsule
        // Capsule
        case 2:
            return 0;
            // Noobship
        // Noobship
        case 3:
            return 5;
            // Frigate
        // Frigate
        case 4:
            return 10;
            // Interceptor
        // Interceptor
        case 5:
            return 15;
            // Assault frigate
        // Assault frigate
        case 6:
            return 12;
            // Industrial
        // Industrial
        case 7:
            return 7;
            // Cruiser
        // Cruiser
        case 8:
            return 20;
            // Heavy assault
        // Heavy assault
        case 9:
            return 25;
            // Battlecruiser
        // Battlecruiser
        case 10:
            return 35;
            // Shuttle
        // Shuttle
        case 11:
            return 1;
            // Mining barge
        // Mining barge
        case 12:
            return 7;
            // Logistics
        // Logistics
        case 13:
            return 23;
            // Transport
        // Transport
        case 14:
            return 9;
            // Destroyer
        // Destroyer
        case 15:
            return 17;
            // Covert ops
        // Covert ops
        case 16:
            return 16;
            // Drone
        // Drone
        case 17:
            return 6;
            // Unknown
        // Unknown
        case 18:
            return -1;
            // Dreadnought
        // Dreadnought
        case 19:
            return 500;
            // Freighter
        // Freighter
        case 20:
            return 125;
            // Command ship
        // Command ship
        case 21:
            return 40;
            // Exhumer
        // Exhumer
        case 22:
            return 8;
            // Interdictor
        // Interdictor
        case 23:
            return 18;
            // Recon ship
        // Recon ship
        case 24:
            return 21;
            // Titan
        // Titan
        case 26:
            return 1000;
            // Carrier
        // Carrier
        case 27:
            return 250;
            // Supercarrier
        // Supercarrier
        case 28:
            return 750;
            // Capital Industrial
        // Capital Industrial
        case 29:
            return 450;
            // Electronic Attack Ship
        // Electronic Attack Ship
        case 30:
            return 13;
            // Heavy Interdictor
        // Heavy Interdictor
        case 31:
            return 30;
            // Black Ops
        // Black Ops
        case 32:
            return 150;
            // Marauder
        // Marauder
        case 33:
            return 125;
            // Jump Freighter
        // Jump Freighter
        case 34:
            return 175;
            // POS Small
        // POS Small
        case 35:
            return -20;
            // POS Medium
        // POS Medium
        case 36:
            return -15;
            // POS Large
        // POS Large
        case 37:
            return -10;
            // POS Modules
        // POS Modules
        case 38:
            return -25;
            // Indu Command
        // Indu Command
        case 39:
            return 155;
            // Strategic Cruiser
        // Strategic Cruiser
        case 40:
            return 33;
            // Infrastructure Modules
        // Infrastructure Modules
        case 41:
            return -5;
            // Territory Modules
        // Territory Modules
        case 42:
            return -4;
            // Prototype Exploration Ship
        // Prototype Exploration Ship
        case 43:
            return 2;
            // Customs Offices
        // Customs Offices
        case 44:
            return -12;
            // Unknown
        // Unknown
        default:
            return -50;
    }
}
 function forum()
 {
     if ($this->klist_) {
         $entry = array();
         // build array
         $sql = "select scl_id, scl_class\r\n                    from kb3_ship_classes\r\n                   where scl_class not in ( 'Drone', 'Unknown' )\r\n                  order by scl_class";
         $qry = DBFactory::getDBQuery();
         $qry->execute($sql) or die($qry->getErrorMsg());
         while ($row = $qry->getRow()) {
             if (!$row['scl_id']) {
                 continue;
             }
             $shipclass = new ShipClass($row['scl_id']);
             $shipclass->setName($row['scl_class']);
             $entry[$shipclass->getName()]['id'] = $row['scl_id'];
             $entry[$shipclass->getName()]['kills'] = 0;
             $entry[$shipclass->getName()]['kills_isk'] = 0;
             $entry[$shipclass->getName()]['losses'] = 0;
             $entry[$shipclass->getName()]['losses_isk'] = 0;
         }
         // kills
         while ($kill = $this->klist_->getKill()) {
             $classname = $kill->getVictimShipClassName();
             $entry[$classname]['kills']++;
             $entry[$classname]['kills_isk'] += $kill->getVictimShipValue();
             $this->tkcount_++;
             $this->tkisk_ += $kill->getVictimShipValue();
         }
         // losses
         while ($kill = $this->llist_->getKill()) {
             $classname = $kill->getVictimShipClassName();
             $entry[$classname]['losses']++;
             $entry[$classname]['losses_isk'] += $kill->getVictimShipValue();
             $this->tlcount_++;
             $this->tlisk_ += $kill->getVictimShipValue();
         }
     } else {
         $this->getkills();
         $entry =& $this->entry_;
     }
     // Build our Post
     $config = new config(KB_SITE);
     $set_colours = config::get('forum_post_colours');
     //load colour settings
     if (!is_array($set_colours)) {
         $set_colours = array();
     }
     // if the settings have been reset create an empty array so as not to brake the code later on
     $set_styles = config::get('forum_post_styles');
     //load style settings
     if (!is_array($set_styles)) {
         $set_styles = array();
     }
     // if the settings have been reset create an empty array so as not to brake the code later on
     $set_isk = config::get('forum_post_isk', $_POST['isk']);
     // load isk setting
     $forum_post_miss_empty_class = config::get(forum_post_miss_empty_class);
     //print_r($set_styles);
     foreach ($entry as $k => $v) {
         if ($forum_post_miss_empty_class == 1 && $v['kills'] == 0 && $v['losses'] == 0) {
         } else {
             $class = $k . $kclass;
             $kills = $v['kills'];
             if ($set_isk == "yes") {
                 $kills_isk = "(" . round($v['kills_isk'] / 1000000, 2) . "M)";
                 $loss_isk = "(" . round($v['losses_isk'] / 1000000, 2) . "M)";
             }
             $loss = $v['losses'];
             $close = "\r\n";
             $spacer = " / ";
             if (array_key_exists(str_replace(" ", "", $class), $set_colours)) {
                 $colour_open = "[" . $set_colours[str_replace(" ", "", $class)] . "]";
                 $colour_close = "[/" . $set_colours[str_replace(" ", "", $class)] . "]";
             } else {
                 $colour_open = "";
                 $colour_close = "";
             }
             if (array_key_exists(str_replace(" ", "", $class), $set_styles)) {
                 $style_open = "[" . $set_styles[str_replace(" ", "", $class)] . "]";
                 $style_close = "[/" . $set_styles[str_replace(" ", "", $class)] . "]";
             } else {
                 $style_open = "";
                 $style_close = "";
             }
             $order = config::get('forum_post_order');
             if ($order == "first") {
                 $kills_list .= $colour_open . $style_open . $class . $spacer . $kills . $kills_isk . $spacer . $loss . $loss_isk . $style_close . $colour_close . $close;
             } else {
                 $kills_list .= $colour_open . $style_open . $kills . $kills_isk . $spacer . $loss . $loss_isk . $spacer . $class . $style_close . $colour_close . $close;
             }
             $counter++;
             $this->tkcount_ += $kcount;
             $this->tlcount_ += $lcount;
             $this->tkisk_ += $kisk;
             $this->tlisk_ += $lisk;
             $this->tkpoints_ += $kpoints;
             $this->tlpoints_ += $lpoints;
         }
     }
     if ($order == "first") {
         $html .= "Class / ";
     }
     $html .= "Kills";
     if ($set_isk == "yes") {
         $html .= "(kills isk)";
     }
     $html .= " / losses ";
     if ($set_isk == "yes") {
         $html .= "(losses isk)";
     }
     if ($order != "first") {
         $html .= " / Class";
     }
     $html .= "\r\n";
     $html .= $kills_list;
     $html .= "Total / " . $this->tkcount_;
     $html .= " (" . round($this->tkisk_ / 1000000, 2) . "M)";
     $html .= " / " . $this->tlcount_;
     $html .= " (" . round($this->tlisk_ / 1000000, 2) . "M)";
     return $html;
 }
Example #3
0
 /**
  * Look up a Ship by name.
  *
  * @param string $name a string containing a ship name.
  */
 static function lookup($name)
 {
     static $cache_name = array();
     static $pqry = null;
     static $id = 0;
     static $shp_name = "";
     static $scl_id = 0;
     static $typeName = "";
     if (isset($cache_name[$name])) {
         return $cache_name[$name];
     }
     if ($name == "Unknown") {
         $cache_name[$name] = Ship::getByID(0);
         return $cache_name[$name];
     }
     if ($pqry === null) {
         $pqry = new DBPreparedQuery();
         $pqry->prepare("SELECT typeID, typeName, shp_class" . " FROM kb3_ships RIGHT JOIN kb3_invtypes ON shp_id=typeID" . " WHERE typeName = ?");
     }
     $shp_name = $name = trim(stripslashes($name));
     $pqry->bind_param('s', $shp_name);
     $pqry->bind_result($id, $typeName, $scl_id);
     if (!$pqry->execute() || !$pqry->recordCount()) {
         return false;
     } else {
         $pqry->fetch();
     }
     if ($scl_id == null && $id) {
         $qry = DBFactory::getDBQuery();
         $qry->execute("INSERT INTO kb3_ships (shp_id, shp_class) values({$id}, 18)");
         $scl_id = 18;
         // "Unknown"
     }
     $shipclass = ShipClass::getByID($scl_id);
     $cache_name[$name] = new Ship($id, null, $typeName, $shipclass);
     return $cache_name[$name];
 }