function info()
 {
     $planet = $this->data->planet($this->planet_id);
     //$designs['army'] = array('attack', 'defense', 'armor', 'hull', 'weapons', 'size');
     //$designs['navy'] = array('attack', 'defense', 'armor', 'hull', 'weapons', 'cargo', 'speed', 'size');
     $unit = $this->data->blueprint($this->unit_type, $this->unit_id);
     $unit['name'] = htmlentities($unit['name']);
     if (!empty($planet['production'][$this->unit_type][$unit[$this->unit_type . 'concept_id']])) {
         $unit['resources']['time'] = format_time(timeparser($unit['time'] * $_SESSION['round_speed'] / $planet['production'][$this->unit_type][$unit[$this->unit_type . 'concept_id']]));
     }
     $unit['resources']['workers'] = format_number($unit['workers'], true);
     $unit['resources']['energy'] = format_number($unit['energy'], true);
     if (!empty($unit['mineralspread'])) {
         $mineralnames = unserialize(MINERALS_ARRAY);
         foreach ($unit['mineralspread'] as $key => $value) {
             $resources['minerals'][$mineralnames[$key]] = format_number($unit['minerals'] / $value, true);
         }
         $unit['resources']['minerals'] = $resources['minerals'];
     }
     if ($unit['kingdom_id'] == $_SESSION['kingdom_id']) {
         blueprints_stats($this->unit_type, $this->unit_id);
     }
     research_planets();
     $this->smarty->assign('unit', $unit);
     $this->smarty->assign('unit_type', $this->unit_type);
     $this->smarty->assign('unit_id', $this->unit_id);
     $this->smarty->display('units_info.tpl');
 }
 function info()
 {
     $designs['main'] = array('army', 'navy', 'weapon');
     $designs['army'] = array('attack', 'defense', 'armor', 'hull', 'weaponsload');
     $designs['navy'] = array('attack', 'defense', 'armor', 'hull', 'weaponsload', 'cargo', 'speed');
     $designs['weapon'] = array('accuracy', 'areadamage', 'rateoffire', 'power', 'damage');
     foreach ($designs['main'] as $value) {
         if (!empty($_REQUEST[$value . 'design_id'])) {
             $design_id = (int) $_REQUEST[$value . 'design_id'];
             $design_name = $value;
             break;
         }
     }
     if (empty($design_name)) {
         error(__FILE__, __LINE__, 'DATA_NULL', 'Null design selected');
     }
     $db_query = "\n\t\t\t\tSELECT * \n\t\t\t\tFROM `" . $design_name . "designs` \n\t\t\t\tWHERE \n\t\t\t\t\t`kingdom_id` = '" . $_SESSION['kingdom_id'] . "' AND \n\t\t\t\t\t`" . $design_name . "design_id` = '" . $design_id . "' \n\t\t\t\tLIMIT 1";
     $db_result = mysql_query($db_query);
     if (mysql_num_rows($db_result) == 0) {
         error(__FILE__, __LINE__, 'DATA_INVALID', 'Invalid design selected');
     }
     $design = mysql_fetch_array($db_result, MYSQL_ASSOC);
     $design['mineralspread'] = unserialize($design['mineralspread']);
     $upgrades = array();
     foreach ($designs[$design_name] as $value) {
         // =IF(C1 < $B$2; ROUNDDOWN(C1 + (($B$4 / 100) * C1) + $B$3); "")
         if ($design[$value . '_base'] < $design[$value . '_max']) {
             $increment = floor($design[$value . '_per'] / 100 * $design[$value . '_base'] + $design[$value . '_inc']);
             if ($design[$value . '_base'] + $increment > $design[$value . '_max']) {
                 $increment = $design[$value . '_max'] - $design[$value . '_base'];
             }
             $sizeincrement = floor($design[$value . '_size'] / 100 * $design['size_base'] + $design[$value . '_sizeinc']);
             if ($design['size_base'] + $sizeincrement > $design['size_max']) {
                 $sizeincrement = $design['size_max'] - $design['size_base'];
             }
             if ($value == 'weaponsload') {
                 $upgrades[$value]['name'] = 'Weapon Load';
             } else {
                 $upgrades[$value]['name'] = ucfirst($value);
             }
             $upgrades[$value]['current'] = $design[$value . '_base'];
             $upgrades[$value]['increase'] = $increment;
             $upgrades[$value]['sizeincrease'] = $sizeincrement;
         }
     }
     if (!empty($design['mineralspread'])) {
         $mineralnames = array(0 => 'fe', 1 => 'o', 2 => 'si', 3 => 'mg', 4 => 'ni', 5 => 's', 6 => 'he', 7 => 'h');
         foreach ($design['mineralspread'] as $key => $value) {
             $resources['resources']['minerals'][$mineralnames[$key]] = format_number($design['minerals'] * ($value / 100), true);
         }
     }
     $resources['name'] = $design['name'];
     $resources['design_id'] = $design_id;
     $resources['type'] = $design_name;
     $resources['resources']['time'] = format_time(timeparser($design['time'] * $_SESSION['round_speed']));
     $resources['resources']['workers'] = $design['workers'];
     $resources['resources']['energy'] = $design['energy'];
     $resources['upgrades'] = $upgrades;
     research_planets();
     $this->smarty->assign('design', $resources);
     $this->smarty->display('designs_info.tpl');
     exit;
 }
 function info()
 {
     // FIXME
     $concept_id = $this->concept_id;
     $this->planets();
     $concept = $this->data->concept($this->concept_id);
     if (empty($concept)) {
         error(__FILE__, __LINE__, 'DATA', 'Invalid concept selected');
     }
     $grant_types = array(array(0 => 'concepts', 1 => 'concept_id', 2 => 'Concept'), array(0 => 'buildings', 1 => 'building_id', 2 => 'Building'), array(0 => 'armyconcepts', 1 => 'armyconcept_id', 2 => 'Army Unit'), array(0 => 'navyconcepts', 1 => 'navyconcept_id', 2 => 'Navy Unit'), array(0 => 'weaponconcepts', 1 => 'weaponconcept_id', 2 => 'Weapon'));
     foreach ($grant_types as $value) {
         if (!empty($concept['grants'][$value[0]])) {
             $db_query = "SELECT `name` FROM `" . $value[0] . "` WHERE `" . $value[1] . "` IN ('" . implode("', '", array_keys($concept['grants'][$value[0]])) . "')";
             $db_result = mysql_query($db_query);
             while ($db_row = mysql_fetch_array($db_result, MYSQL_ASSOC)) {
                 $grants[] = array('type' => $value[2], 'name' => $db_row['name']);
             }
         }
     }
     $concept['grants'] = $grants;
     $mineralnames = array(0 => 'fe', 1 => 'o', 2 => 'si', 3 => 'mg', 4 => 'ni', 5 => 's', 6 => 'he', 7 => 'h');
     foreach ($concept['mineralspread'] as $key => $value) {
         $concept['resources']['minerals'][$mineralnames[$key]] = format_number($concept['minerals'] * ($value / 100), true);
     }
     $concept['resources']['time'] = format_time(timeparser($concept['time'] * $_SESSION['round_speed']));
     $concept['resources']['workers'] = format_number($concept['workers'], true);
     $concept['resources']['energy'] = format_number($concept['energy'], true);
     unset($concept['minerals'], $concept['mineralspread'], $concept['time'], $concept['workers'], $concept['energy']);
     research_planets();
     $this->smarty->assign('concept', $concept);
     $this->smarty->display('research_info.tpl');
 }