function CreateOnePlanetRecord($Galaxy, $System, $Position, $PlanetOwnerID, $PlanetName = '', $HomeWorld = false) { global $lang; $QrySelectPlanet = "SELECT\t`id` "; $QrySelectPlanet .= "FROM {{table}} "; $QrySelectPlanet .= "WHERE "; $QrySelectPlanet .= "`galaxy` = '" . $Galaxy . "' AND "; $QrySelectPlanet .= "`system` = '" . $System . "' AND "; $QrySelectPlanet .= "`planet` = '" . $Position . "';"; $PlanetExist = doquery($QrySelectPlanet, 'planets', true); if (!$PlanetExist) { $planet = PlanetSizeRandomiser($Position, $HomeWorld); $planet['diameter'] = ($planet['field_max'] ^ 14 / 1.5) * 75; $planet['metal'] = BUILD_METAL; $planet['crystal'] = BUILD_CRISTAL; $planet['deuterium'] = BUILD_DEUTERIUM; $planet['metal_perhour'] = $game_config['metal_basic_income']; $planet['crystal_perhour'] = $game_config['crystal_basic_income']; $planet['deuterium_perhour'] = $game_config['deuterium_basic_income']; $planet['metal_max'] = BASE_STORAGE_SIZE; $planet['crystal_max'] = BASE_STORAGE_SIZE; $planet['deuterium_max'] = BASE_STORAGE_SIZE; // Posistion 1 - 3: 80% entre 40 et 70 Cases ( 55+ / -15 ) // Posistion 4 - 6: 80% entre 120 et 310 Cases ( 215+ / -95 ) // Posistion 7 - 9: 80% entre 105 et 195 Cases ( 150+ / -45 ) // Posistion 10 - 12: 80% entre 75 et 125 Cases ( 100+ / -25 ) // Posistion 13 - 15: 80% entre 60 et 190 Cases ( 125+ / -65 ) $planet['galaxy'] = $Galaxy; $planet['system'] = $System; $planet['planet'] = $Position; if ($Position == 1 || $Position == 2 || $Position == 3) { $PlanetType = array('trocken'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(0, 100); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 4 || $Position == 5 || $Position == 6) { $PlanetType = array('dschjungel'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(-25, 75); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 7 || $Position == 8 || $Position == 9) { $PlanetType = array('normaltemp'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07'); $planet['temp_min'] = rand(-50, 50); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 10 || $Position == 11 || $Position == 12) { $PlanetType = array('wasser'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09'); $planet['temp_min'] = rand(-75, 25); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 13 || $Position == 14 || $Position == 15) { $PlanetType = array('eis'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(-100, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } else { $PlanetType = array('dschjungel', 'gas', 'normaltemp', 'trocken', 'wasser', 'wuesten', 'eis'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '00'); $planet['temp_min'] = rand(-120, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } $planet['image'] = $PlanetType[rand(0, count($PlanetType) - 1)]; $planet['image'] .= $PlanetClass[rand(0, count($PlanetClass) - 1)]; $planet['image'] .= $PlanetDesign[rand(0, count($PlanetDesign) - 1)]; $planet['planet_type'] = 1; $planet['id_owner'] = $PlanetOwnerID; $planet['last_update'] = time(); $planet['name'] = $PlanetName == '' ? $lang['sys_colo_defaultname'] : $PlanetName; $QryInsertPlanet = "INSERT INTO {{table}} SET "; if ($HomeWorld == false) { $QryInsertPlanet .= "`name` = '" . $lang['fcp_colony'] . "', "; } $QryInsertPlanet .= "`id_owner` = '" . $planet['id_owner'] . "', "; $QryInsertPlanet .= "`id_level` = '" . $user['authlevel'] . "', "; $QryInsertPlanet .= "`galaxy` = '" . $planet['galaxy'] . "', "; $QryInsertPlanet .= "`system` = '" . $planet['system'] . "', "; $QryInsertPlanet .= "`planet` = '" . $planet['planet'] . "', "; $QryInsertPlanet .= "`last_update` = '" . $planet['last_update'] . "', "; $QryInsertPlanet .= "`planet_type` = '" . $planet['planet_type'] . "', "; $QryInsertPlanet .= "`image` = '" . $planet['image'] . "', "; $QryInsertPlanet .= "`diameter` = '" . $planet['diameter'] . "', "; $QryInsertPlanet .= "`field_max` = '" . $planet['field_max'] . "', "; $QryInsertPlanet .= "`temp_min` = '" . $planet['temp_min'] . "', "; $QryInsertPlanet .= "`temp_max` = '" . $planet['temp_max'] . "', "; $QryInsertPlanet .= "`metal` = '" . $planet['metal'] . "', "; $QryInsertPlanet .= "`metal_perhour` = '" . $planet['metal_perhour'] . "', "; $QryInsertPlanet .= "`metal_max` = '" . $planet['metal_max'] . "', "; $QryInsertPlanet .= "`crystal` = '" . $planet['crystal'] . "', "; $QryInsertPlanet .= "`crystal_perhour` = '" . $planet['crystal_perhour'] . "', "; $QryInsertPlanet .= "`crystal_max` = '" . $planet['crystal_max'] . "', "; $QryInsertPlanet .= "`deuterium` = '" . $planet['deuterium'] . "', "; $QryInsertPlanet .= "`deuterium_perhour` = '" . $planet['deuterium_perhour'] . "', "; $QryInsertPlanet .= "`deuterium_max` = '" . $planet['deuterium_max'] . "';"; doquery($QryInsertPlanet, 'planets'); $QrySelectPlanet = "SELECT `id` "; $QrySelectPlanet .= "FROM {{table}} "; $QrySelectPlanet .= "WHERE "; $QrySelectPlanet .= "`galaxy` = '" . $planet['galaxy'] . "' AND "; $QrySelectPlanet .= "`system` = '" . $planet['system'] . "' AND "; $QrySelectPlanet .= "`planet` = '" . $planet['planet'] . "' AND "; $QrySelectPlanet .= "`id_owner` = '" . $planet['id_owner'] . "';"; $GetPlanetID = doquery($QrySelectPlanet, 'planets', true); $QrySelectGalaxy = "SELECT * "; $QrySelectGalaxy .= "FROM {{table}} "; $QrySelectGalaxy .= "WHERE "; $QrySelectGalaxy .= "`galaxy` = '" . $planet['galaxy'] . "' AND "; $QrySelectGalaxy .= "`system` = '" . $planet['system'] . "' AND "; $QrySelectGalaxy .= "`planet` = '" . $planet['planet'] . "';"; $GetGalaxyID = doquery($QrySelectGalaxy, 'galaxy', true); if ($GetGalaxyID) { $QryUpdateGalaxy = "UPDATE {{table}} SET "; $QryUpdateGalaxy .= "`id_planet` = '" . $GetPlanetID['id'] . "' "; $QryUpdateGalaxy .= "WHERE "; $QryUpdateGalaxy .= "`galaxy` = '" . $planet['galaxy'] . "' AND "; $QryUpdateGalaxy .= "`system` = '" . $planet['system'] . "' AND "; $QryUpdateGalaxy .= "`planet` = '" . $planet['planet'] . "';"; doquery($QryUpdateGalaxy, 'galaxy'); } else { $QryInsertGalaxy = "INSERT INTO {{table}} SET "; $QryInsertGalaxy .= "`galaxy` = '" . $planet['galaxy'] . "', "; $QryInsertGalaxy .= "`system` = '" . $planet['system'] . "', "; $QryInsertGalaxy .= "`planet` = '" . $planet['planet'] . "', "; $QryInsertGalaxy .= "`id_planet` = '" . $GetPlanetID['id'] . "';"; doquery($QryInsertGalaxy, 'galaxy'); } $RetValue = true; } else { $RetValue = false; } return $RetValue; }
function CreateOnePlanetRecord($Galaxy, $System, $Position, $PlanetOwnerID, $PlanetName = '', $HomeWorld = false) { global $lang; // Avant tout, on verifie s'il existe deja une planete a cet endroit $QrySelectPlanet = "SELECT\t`id` "; $QrySelectPlanet .= "FROM {{table}} "; $QrySelectPlanet .= "WHERE "; $QrySelectPlanet .= "`galaxy` = '" . $Galaxy . "' AND "; $QrySelectPlanet .= "`system` = '" . $System . "' AND "; $QrySelectPlanet .= "`planet` = '" . $Position . "';"; $PlanetExist = doquery($QrySelectPlanet, 'planets', true); // Si $PlanetExist est autre chose que false ... c'est qu'il y a quelque chose là bas ... // C'est donc aussi que je ne peux pas m'y poser !! if (!$PlanetExist) { $planet = PlanetSizeRandomiser($Position, $HomeWorld); $planet['diameter'] = ($planet['field_max'] ^ 14 / 1.5) * 75; $planet['metal'] = BUILD_METAL; $planet['crystal'] = BUILD_CRISTAL; $planet['deuterium'] = BUILD_DEUTERIUM; $planet['metal_perhour'] = $game_config['metal_basic_income']; $planet['crystal_perhour'] = $game_config['crystal_basic_income']; $planet['deuterium_perhour'] = $game_config['deuterium_basic_income']; $planet['metal_max'] = BASE_STORAGE_SIZE; $planet['crystal_max'] = BASE_STORAGE_SIZE; $planet['deuterium_max'] = BASE_STORAGE_SIZE; // Posistion 1 - 3: 80% entre 40 et 70 Cases ( 55+ / -15 ) // Posistion 4 - 6: 80% entre 120 et 310 Cases ( 215+ / -95 ) // Posistion 7 - 9: 80% entre 105 et 195 Cases ( 150+ / -45 ) // Posistion 10 - 12: 80% entre 75 et 125 Cases ( 100+ / -25 ) // Posistion 13 - 15: 80% entre 60 et 190 Cases ( 125+ / -65 ) $planet['galaxy'] = $Galaxy; $planet['system'] = $System; $planet['planet'] = $Position; if ($Position == 1 || $Position == 2 || $Position == 3) { $PlanetType = array('trocken'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(0, 100); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 4 || $Position == 5 || $Position == 6) { $PlanetType = array('dschjungel'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(-25, 75); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 7 || $Position == 8 || $Position == 9) { $PlanetType = array('normaltemp'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07'); $planet['temp_min'] = rand(-50, 50); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 10 || $Position == 11 || $Position == 12) { $PlanetType = array('wasser'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09'); $planet['temp_min'] = rand(-75, 25); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 13 || $Position == 14 || $Position == 15) { $PlanetType = array('eis'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(-100, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } else { $PlanetType = array('dschjungel', 'gas', 'normaltemp', 'trocken', 'wasser', 'wuesten', 'eis'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '00'); $planet['temp_min'] = rand(-120, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } $planet['image'] = $PlanetType[rand(0, count($PlanetType) - 1)]; $planet['image'] .= $PlanetClass[rand(0, count($PlanetClass) - 1)]; $planet['image'] .= $PlanetDesign[rand(0, count($PlanetDesign) - 1)]; $planet['planet_type'] = 1; $planet['id_owner'] = $PlanetOwnerID; $planet['last_update'] = time(); $planet['name'] = $PlanetName == '' ? $lang['sys_colo_defaultname'] : $PlanetName; $QryInsertPlanet = "INSERT INTO {{table}} SET "; $QryInsertPlanet .= "`name` = '" . $planet['name'] . "', "; $QryInsertPlanet .= "`id_owner` = '" . $planet['id_owner'] . "', "; $QryInsertPlanet .= "`galaxy` = '" . $planet['galaxy'] . "', "; $QryInsertPlanet .= "`system` = '" . $planet['system'] . "', "; $QryInsertPlanet .= "`planet` = '" . $planet['planet'] . "', "; $QryInsertPlanet .= "`last_update` = '" . $planet['last_update'] . "', "; $QryInsertPlanet .= "`planet_type` = '" . $planet['planet_type'] . "', "; $QryInsertPlanet .= "`image` = '" . $planet['image'] . "', "; $QryInsertPlanet .= "`diameter` = '" . $planet['diameter'] . "', "; $QryInsertPlanet .= "`field_max` = '" . $planet['field_max'] . "', "; $QryInsertPlanet .= "`temp_min` = '" . $planet['temp_min'] . "', "; $QryInsertPlanet .= "`temp_max` = '" . $planet['temp_max'] . "', "; $QryInsertPlanet .= "`metal` = '" . $planet['metal'] . "', "; $QryInsertPlanet .= "`metal_perhour` = '" . $planet['metal_perhour'] . "', "; $QryInsertPlanet .= "`metal_max` = '" . $planet['metal_max'] . "', "; $QryInsertPlanet .= "`crystal` = '" . $planet['crystal'] . "', "; $QryInsertPlanet .= "`crystal_perhour` = '" . $planet['crystal_perhour'] . "', "; $QryInsertPlanet .= "`crystal_max` = '" . $planet['crystal_max'] . "', "; $QryInsertPlanet .= "`deuterium` = '" . $planet['deuterium'] . "', "; $QryInsertPlanet .= "`deuterium_perhour` = '" . $planet['deuterium_perhour'] . "', "; $QryInsertPlanet .= "`deuterium_max` = '" . $planet['deuterium_max'] . "';"; doquery($QryInsertPlanet, 'planets'); // On recupere l'id de planete nouvellement créé $QrySelectPlanet = "SELECT `id` "; $QrySelectPlanet .= "FROM {{table}} "; $QrySelectPlanet .= "WHERE "; $QrySelectPlanet .= "`galaxy` = '" . $planet['galaxy'] . "' AND "; $QrySelectPlanet .= "`system` = '" . $planet['system'] . "' AND "; $QrySelectPlanet .= "`planet` = '" . $planet['planet'] . "' AND "; $QrySelectPlanet .= "`id_owner` = '" . $planet['id_owner'] . "';"; $GetPlanetID = doquery($QrySelectPlanet, 'planets', true); // Testons s'il y a deja eu une planete ici $QrySelectGalaxy = "SELECT * "; $QrySelectGalaxy .= "FROM {{table}} "; $QrySelectGalaxy .= "WHERE "; $QrySelectGalaxy .= "`galaxy` = '" . $planet['galaxy'] . "' AND "; $QrySelectGalaxy .= "`system` = '" . $planet['system'] . "' AND "; $QrySelectGalaxy .= "`planet` = '" . $planet['planet'] . "';"; $GetGalaxyID = doquery($QrySelectGalaxy, 'galaxy', true); if ($GetGalaxyID) { // Ah ... Ce secteur de ce vaste monde a deja ete occupé $QryUpdateGalaxy = "UPDATE {{table}} SET "; $QryUpdateGalaxy .= "`id_planet` = '" . $GetPlanetID['id'] . "' "; $QryUpdateGalaxy .= "WHERE "; $QryUpdateGalaxy .= "`galaxy` = '" . $planet['galaxy'] . "' AND "; $QryUpdateGalaxy .= "`system` = '" . $planet['system'] . "' AND "; $QryUpdateGalaxy .= "`planet` = '" . $planet['planet'] . "';"; doquery($QryUpdateGalaxy, 'galaxy'); } else { // C'est tout vide ... y a que dalle ... j'm'y pose !! $QryInsertGalaxy = "INSERT INTO {{table}} SET "; $QryInsertGalaxy .= "`galaxy` = '" . $planet['galaxy'] . "', "; $QryInsertGalaxy .= "`system` = '" . $planet['system'] . "', "; $QryInsertGalaxy .= "`planet` = '" . $planet['planet'] . "', "; $QryInsertGalaxy .= "`id_planet` = '" . $GetPlanetID['id'] . "';"; doquery($QryInsertGalaxy, 'galaxy'); } $RetValue = true; } else { $RetValue = false; } return $RetValue; }
/** * Create a new planet and insert it on the database * * @param int|string $galaxy * @param int|string $system * @param int|string $position * @param int|string $planetOwnerId * @param string $planetName * @param bool $homeWorld * * @return bool */ function CreateOnePlanetRecord($galaxy, $system, $position, $planetOwnerId, $planetName = '', $homeWorld = false) { global $lang, $game_config; /** * @var resource Get database link */ $readConnection = Nova::getSingleton('core/database_connection_pool')->getConnection('core_read'); $planetExist = $readConnection->select()->from($readConnection->getDeprecatedTable('planets'))->where('galaxy =?', $galaxy)->where('system =?', $system)->where('planet =?', $position)->query()->fetch(); if (!$planetExist) { $planet = PlanetSizeRandomiser($position, $homeWorld); $planet['metal'] = BUILD_METAL; $planet['crystal'] = BUILD_CRISTAL; $planet['deuterium'] = BUILD_DEUTERIUM; $planet['metal_perhour'] = $game_config['metal_basic_income']; $planet['crystal_perhour'] = $game_config['crystal_basic_income']; $planet['deuterium_perhour'] = $game_config['deuterium_basic_income']; $planet['metal_max'] = BASE_STORAGE_SIZE; $planet['crystal_max'] = BASE_STORAGE_SIZE; $planet['deuterium_max'] = BASE_STORAGE_SIZE; $planet['galaxy'] = $galaxy; $planet['system'] = $system; $planet['planet'] = $position; if ($position == 1 || $position == 2 || $position == 3) { $planetType = 'trocken'; $planetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(0, 100); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($position == 4 || $position == 5 || $position == 6) { $planetType = 'dschjungel'; $planetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(-25, 75); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($position == 7 || $position == 8 || $position == 9) { $planetType = 'normaltemp'; $planetDesign = array('01', '02', '03', '04', '05', '06', '07'); $planet['temp_min'] = rand(-50, 50); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($position == 10 || $position == 11 || $position == 12) { $planetType = 'wasser'; $planetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09'); $planet['temp_min'] = rand(-75, 25); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($position == 13 || $position == 14 || $position == 15) { $planetType = 'eis'; $planetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(-100, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } else { $planetType = 'wuesten'; $planetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '00'); $planet['temp_min'] = rand(-120, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } $planet['image'] = $planetType . 'planet' . $planetDesign[rand(0, count($planetDesign) - 1)]; $planet['planet_type'] = 1; $planet['id_owner'] = $planetOwnerId; $planet['last_update'] = new Zend_Db_Expr('UNIX_TIMESTAMP()'); $planet['name'] = $planetName == '' ? $lang['sys_colo_defaultname'] : $planetName; $readConnection->insert($readConnection->getDeprecatedTable('planets'), $planet); $planetId = $readConnection->lastInsertId($readConnection->getDeprecatedTable('planets')); $galaxyPosition = $readConnection->select()->from($readConnection->getDeprecatedTable('galaxy'), array('id' => 'id_planet'))->where('galaxy=?', $galaxy)->where('system=?', $system)->where('planet=?', $position)->query()->fetch(); if ($galaxyPosition) { $readConnection->update($readConnection->getDeprecatedTable('galaxy'), array('id_planet' => $planetId), array('id_planet =?', $galaxyPosition['id'])); } else { $data = array('galaxy' => $planet['galaxy'], 'system' => $planet['system'], 'planet' => $planet['planet'], 'id_planet' => $planetId); $readConnection->insert($readConnection->getDeprecatedTable('galaxy'), $data); } return $planetId; } else { return false; } }
function CreateOnePlanetRecord($Galaxy, $System, $Position, $PlanetOwnerID, $PlanetName = '', $HomeWorld = false) { global $lang, $DB, $game_config; // Avant tout, on verifie s'il existe deja une planete a cet endroit $QrySelectPlanet = "SELECT\t`id` "; $QrySelectPlanet .= "FROM {{table}} "; $QrySelectPlanet .= "WHERE "; $QrySelectPlanet .= "`galaxy` = '" . $Galaxy . "' AND "; $QrySelectPlanet .= "`system` = '" . $System . "' AND "; $QrySelectPlanet .= "`planet` = '" . $Position . "';"; $PlanetExist = doquery($QrySelectPlanet, 'planets', true); // Si $PlanetExist est autre chose que false ... c'est qu'il y a quelque chose là bas ... // C'est donc aussi que je ne peux pas m'y poser !! if (!$PlanetExist) { $planet = PlanetSizeRandomiser($Position, $HomeWorld); $planet['diameter'] = ($planet['field_max'] ^ 14 / 1.5) * 75; $planet['metal'] = $game_config['build_metal']; $planet['crystal'] = $game_config['build_cristal']; $planet['deuterium'] = $game_config['build_deuterium']; $planet['metal_perhour'] = $game_config['metal_basic_income']; $planet['crystal_perhour'] = $game_config['crystal_basic_income']; $planet['deuterium_perhour'] = $game_config['deuterium_basic_income']; $planet['metal_max'] = $game_config['base_storage_size']; $planet['crystal_max'] = $game_config['base_storage_size']; $planet['deuterium_max'] = $game_config['base_storage_size']; // Posistion 1 - 3: 80% entre 40 et 70 Cases ( 55+ / -15 ) // Posistion 4 - 6: 80% entre 120 et 310 Cases ( 215+ / -95 ) // Posistion 7 - 9: 80% entre 105 et 195 Cases ( 150+ / -45 ) // Posistion 10 - 12: 80% entre 75 et 125 Cases ( 100+ / -25 ) // Posistion 13 - 15: 80% entre 60 et 190 Cases ( 125+ / -65 ) $planet['galaxy'] = $Galaxy; $planet['system'] = $System; $planet['planet'] = $Position; $erstes_bild = 1; //nummer des erstes Planetenbildes $letztes_bild = 46; //Nummer des letzten Planetenbildes if ($Position == 1 || $Position == 2 || $Position == 3) { $PlanetType = 'planet_'; $PlanetNumber = rand($erstes_bild, $letztes_bild); $planet['temp_min'] = rand(0, 100); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 4 || $Position == 5 || $Position == 6) { $PlanetType = 'planet_'; $PlanetNumber = rand($erstes_bild, $letztes_bild); $planet['temp_min'] = rand(-25, 75); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 7 || $Position == 8 || $Position == 9) { $PlanetType = 'planet_'; $PlanetNumber = rand($erstes_bild, $letztes_bild); $planet['temp_min'] = rand(-50, 50); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 10 || $Position == 11 || $Position == 12) { $PlanetType = 'planet_'; $PlanetNumber = rand($erstes_bild, $letztes_bild); $planet['temp_min'] = rand(-75, 25); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 13 || $Position == 14 || $Position == 15) { $PlanetType = 'planet_'; $PlanetNumber = rand($erstes_bild, $letztes_bild); $planet['temp_min'] = rand(-100, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } else { $PlanetType = 'planet_'; $PlanetNumber = rand($erstes_bild, $letztes_bild); $planet['temp_min'] = rand(-120, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } if ($PlanetNumber < 10) { $PlanetNumber = "0" . $PlanetNumber; //ne 0 davorsetzen, wenn Planetennummer < 10 } $planet['image'] = "{$PlanetType}" . "{$PlanetNumber}"; $planet['planet_type'] = 1; $planet['id_owner'] = $PlanetOwnerID; $planet['last_update'] = time(); $planet['name'] = $PlanetName == '' ? $lang['sys_colo_defaultname'] : $PlanetName; $QryInsertPlanet = "INSERT INTO {{table}} SET "; $QryInsertPlanet .= "`name` = '" . $planet['name'] . "', "; $QryInsertPlanet .= "`id_owner` = '" . $planet['id_owner'] . "', "; $QryInsertPlanet .= "`galaxy` = '" . $planet['galaxy'] . "', "; $QryInsertPlanet .= "`system` = '" . $planet['system'] . "', "; $QryInsertPlanet .= "`planet` = '" . $planet['planet'] . "', "; $QryInsertPlanet .= "`last_update` = '" . $planet['last_update'] . "', "; $QryInsertPlanet .= "`planet_type` = '" . $planet['planet_type'] . "', "; $QryInsertPlanet .= "`image` = '" . $planet['image'] . "', "; $QryInsertPlanet .= "`diameter` = '" . $planet['diameter'] . "', "; $QryInsertPlanet .= "`field_max` = '" . $planet['field_max'] . "', "; $QryInsertPlanet .= "`temp_min` = '" . $planet['temp_min'] . "', "; $QryInsertPlanet .= "`temp_max` = '" . $planet['temp_max'] . "', "; $QryInsertPlanet .= "`metal` = '" . $planet['metal'] . "', "; $QryInsertPlanet .= "`metal_perhour` = '" . $planet['metal_perhour'] . "', "; $QryInsertPlanet .= "`metal_max` = '" . $planet['metal_max'] . "', "; $QryInsertPlanet .= "`crystal` = '" . $planet['crystal'] . "', "; $QryInsertPlanet .= "`crystal_perhour` = '" . $planet['crystal_perhour'] . "', "; $QryInsertPlanet .= "`crystal_max` = '" . $planet['crystal_max'] . "', "; $QryInsertPlanet .= "`deuterium` = '" . $planet['deuterium'] . "', "; $QryInsertPlanet .= "`deuterium_perhour` = '" . $planet['deuterium_perhour'] . "', "; $QryInsertPlanet .= "`deuterium_max` = '" . $planet['deuterium_max'] . "';"; doquery($QryInsertPlanet, 'planets'); // On recupere l'id de planete nouvellement créé $QrySelectPlanet = "SELECT `id` "; $QrySelectPlanet .= "FROM {{table}} "; $QrySelectPlanet .= "WHERE "; $QrySelectPlanet .= "`galaxy` = '" . $planet['galaxy'] . "' AND "; $QrySelectPlanet .= "`system` = '" . $planet['system'] . "' AND "; $QrySelectPlanet .= "`planet` = '" . $planet['planet'] . "' AND "; $QrySelectPlanet .= "`id_owner` = '" . $planet['id_owner'] . "';"; $GetPlanetID = doquery($QrySelectPlanet, 'planets', true); // Testons s'il y a deja eu une planete ici $QrySelectGalaxy = "SELECT * "; $QrySelectGalaxy .= "FROM {{table}} "; $QrySelectGalaxy .= "WHERE "; $QrySelectGalaxy .= "`galaxy` = '" . $planet['galaxy'] . "' AND "; $QrySelectGalaxy .= "`system` = '" . $planet['system'] . "' AND "; $QrySelectGalaxy .= "`planet` = '" . $planet['planet'] . "';"; $GetGalaxyID = doquery($QrySelectGalaxy, 'galaxy', true); if ($GetGalaxyID) { // Ah ... Ce secteur de ce vaste monde a deja ete occupé $QryUpdateGalaxy = "UPDATE {{table}} SET "; $QryUpdateGalaxy .= "`id_planet` = '" . $GetPlanetID['id'] . "' "; $QryUpdateGalaxy .= "WHERE "; $QryUpdateGalaxy .= "`galaxy` = '" . $planet['galaxy'] . "' AND "; $QryUpdateGalaxy .= "`system` = '" . $planet['system'] . "' AND "; $QryUpdateGalaxy .= "`planet` = '" . $planet['planet'] . "';"; doquery($QryUpdateGalaxy, 'galaxy'); } else { // C'est tout vide ... y a que dalle ... j'm'y pose !! $QryInsertGalaxy = "INSERT INTO {{table}} SET "; $QryInsertGalaxy .= "`galaxy` = '" . $planet['galaxy'] . "', "; $QryInsertGalaxy .= "`system` = '" . $planet['system'] . "', "; $QryInsertGalaxy .= "`planet` = '" . $planet['planet'] . "', "; $QryInsertGalaxy .= "`id_planet` = '" . $GetPlanetID['id'] . "';"; doquery($QryInsertGalaxy, 'galaxy'); } $RetValue = true; } else { $RetValue = false; } return $RetValue; }
function CreateOnePlanetRecord($gal, $System, $pos, $id_owner, $planet_name = '', $homeplanet = false) { global $lang; // We must check if planet exists. $PlanetExist = mysql_fetch_array(doquery("SELECT\t`id` FROM {{table}} WHERE `galaxy` = '" . $gal . "' AND `system` = '" . $System . "' AND `planet` = '" . $pos . "';", 'planets')); // Well, does planet exist. if (!$PlanetExist) { $planet = PlanetSizeRandomiser($pos, $homeplanet); $planet['metal'] = BUILD_METAL; $planet['crystal'] = BUILD_CRISTAL; $planet['deuterium'] = BUILD_DEUTERIUM; $planet['metal_perhour'] = $game_config['metal_basic_income']; $planet['crystal_perhour'] = $game_config['crystal_basic_income']; $planet['deuterium_perhour'] = $game_config['deuterium_basic_income']; $planet['metal_max'] = BASE_STORAGE_SIZE; $planet['crystal_max'] = BASE_STORAGE_SIZE; $planet['deuterium_max'] = BASE_STORAGE_SIZE; $planet['galaxy'] = $gal; $planet['system'] = $System; $planet['planet'] = $pos; $planet['id_owner'] = $id_owner; if ($pos == 1 || $pos == 2 || $pos == 3) { $planet['img'] = 'trocken'; $planet['no.'] = rand_in_array(array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10')); $planet['temp_min'] = mt_rand(0, 100); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($pos == 4 || $pos == 5 || $pos == 6) { $planet['img'] = 'dschjungel'; $planet['no.'] = rand_in_array(array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10')); $planet['temp_min'] = mt_rand(-25, 75); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($pos == 7 || $pos == 8 || $pos == 9) { $planet['img'] = 'normaltemp'; $planet['no.'] = rand_in_array(array('01', '02', '03', '04', '05', '06', '07')); $planet['temp_min'] = mt_rand(-50, 50); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($pos == 10 || $pos == 11 || $pos == 12) { $planet['img'] = 'wasser'; $planet['no.'] = rand_in_array(array('01', '02', '03', '04', '05', '06', '07', '08', '09')); $planet['temp_min'] = mt_rand(-75, 25); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($pos == 13 || $pos == 14 || $pos == 15) { $planet['img'] = 'eis'; $planet['no.'] = rand_in_array(array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10')); $planet['temp_min'] = mt_rand(-100, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } else { $planet['img'] = rand_in_array(array('dschjungel', 'gas', 'normaltemp', 'trocken', 'wasser', 'wuesten', 'eis')); $planet['no.'] = rand_in_array(array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '00')); $planet['temp_min'] = mt_rand(-120, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } $planet['image'] = $planet['img'] . "planet" . $planet['no.']; if (strlen($planet_name) > 0) { $planet['name'] = $planet_name; } else { $planet['name'] = $lang['sys_colo_defaultname']; } doquery("INSERT INTO {{table}} (`name`,`id_owner`,`galaxy`,`system`,`planet`,`last_update`,`planet_type`,`image`,`diameter`,`field_max`,`temp_min`,`temp_max`,`metal`,`metal_perhour`,`metal_max`,`crystal`,`crystal_perhour`,`crystal_max`,`deuterium`,`deuterium_perhour`,`deuterium_max`)\r\n\t\tVALUES ('" . $planet['name'] . "','" . $planet['id_owner'] . "','" . $planet['galaxy'] . "','" . $planet['system'] . "','" . $planet['planet'] . "','" . time() . "','1','" . $planet['image'] . "','" . $planet['diameter'] . "','" . $planet['field_max'] . "','" . $planet['temp_min'] . "','" . $planet['temp_max'] . "','" . $planet['metal'] . "','" . $planet['metal_perhour'] . "','" . $planet['metal_max'] . "','" . $planet['crystal'] . "','" . $planet['crystal_perhour'] . "','" . $planet['crystal_max'] . "','" . $planet['deuterium'] . "','" . $planet['deuterium_perhour'] . "','" . $planet['deuterium_max'] . "') ;", 'planets'); return true; } else { return false; } }
function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $PlanetName = '', $HomeWorld = false) { global $lang, $config; // Avant tout, on verifie s'il existe deja une planete a cet endroit $QrySelectPlanet = "SELECT `id` "; $QrySelectPlanet .= "FROM `{{planets}}` "; $QrySelectPlanet .= "WHERE "; $QrySelectPlanet .= "`galaxy` = '" . $Galaxy . "' AND "; $QrySelectPlanet .= "`system` = '" . $System . "' AND "; $QrySelectPlanet .= "`planet` = '" . $Position . "';"; $PlanetExist = doquery($QrySelectPlanet, '', true); // Si $PlanetExist est autre chose que false ... c'est qu'il y a quelque chose là bas ... // C'est donc aussi que je ne peux pas m'y poser !! if (!$PlanetExist) { $planet = PlanetSizeRandomiser($Position, $HomeWorld); $planet['diameter'] = ($planet['field_max'] ^ 14 / 1.5) * 75; $planet['metal'] = BUILD_METAL; $planet['crystal'] = BUILD_CRISTAL; $planet['deuterium'] = BUILD_DEUTERIUM; $planet['metal_perhour'] = $config->metal_basic_income; $planet['crystal_perhour'] = $config->crystal_basic_income; $planet['deuterium_perhour'] = $config->deuterium_basic_income; $planet['metal_max'] = BASE_STORAGE_SIZE; $planet['crystal_max'] = BASE_STORAGE_SIZE; $planet['deuterium_max'] = BASE_STORAGE_SIZE; // Posistion 1 - 3: 80% entre 40 et 70 Cases ( 55+ / -15 ) // Posistion 4 - 6: 80% entre 120 et 310 Cases ( 215+ / -95 ) // Posistion 7 - 9: 80% entre 105 et 195 Cases ( 150+ / -45 ) // Posistion 10 - 12: 80% entre 75 et 125 Cases ( 100+ / -25 ) // Posistion 13 - 15: 80% entre 60 et 190 Cases ( 125+ / -65 ) $planet['galaxy'] = $Galaxy; $planet['system'] = $System; $planet['planet'] = $Position; if ($Position == 1 || $Position == 2 || $Position == 3) { $PlanetType = array('trocken'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(0, 100); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 4 || $Position == 5 || $Position == 6) { $PlanetType = array('dschjungel'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(-25, 75); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 7 || $Position == 8 || $Position == 9) { $PlanetType = array('normaltemp'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07'); $planet['temp_min'] = rand(-50, 50); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 10 || $Position == 11 || $Position == 12) { $PlanetType = array('wasser'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09'); $planet['temp_min'] = rand(-75, 25); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 13 || $Position == 14 || $Position == 15) { $PlanetType = array('eis'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(-100, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } else { $PlanetType = array('dschjungel', 'gas', 'normaltemp', 'trocken', 'wasser', 'wuesten', 'eis'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '00'); $planet['temp_min'] = rand(-120, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } if ($HomeWorld) { $planet['temp_min'] = 0; $planet['temp_max'] = $planet['temp_min'] + 40; } $planet['image'] = $PlanetType[rand(0, count($PlanetType) - 1)]; $planet['image'] .= $PlanetClass[rand(0, count($PlanetClass) - 1)]; $planet['image'] .= $PlanetDesign[rand(0, count($PlanetDesign) - 1)]; $planet['planet_type'] = 1; $planet['id_owner'] = $PlanetOwnerID; $planet['last_update'] = time(); $planet['name'] = $PlanetName ? $PlanetName : $lang['sys_colo_defaultname']; if (!$HomeWorld) { $OwnerName = doquery("SELECT `username` FROM {{users}} WHERE `id` = {$PlanetOwnerID};", '', true); $planet['name'] = "{$OwnerName['username']} {$planet['name']}"; } $planet['name'] = mysql_real_escape_string(strip_tags(trim($planet['name']))); $QryInsertPlanet = "INSERT INTO `{{planets}}` SET "; $QryInsertPlanet .= "`name` = '" . $planet['name'] . "', "; $QryInsertPlanet .= "`id_owner` = '" . $planet['id_owner'] . "', "; // $QryInsertPlanet .= "`id_level` = '". $user['authlevel'] ."', "; $QryInsertPlanet .= "`galaxy` = '" . $planet['galaxy'] . "', "; $QryInsertPlanet .= "`system` = '" . $planet['system'] . "', "; $QryInsertPlanet .= "`planet` = '" . $planet['planet'] . "', "; $QryInsertPlanet .= "`last_update` = '" . $planet['last_update'] . "', "; $QryInsertPlanet .= "`planet_type` = '" . $planet['planet_type'] . "', "; $QryInsertPlanet .= "`image` = '" . $planet['image'] . "', "; $QryInsertPlanet .= "`diameter` = '" . $planet['diameter'] . "', "; $QryInsertPlanet .= "`field_max` = '" . $planet['field_max'] . "', "; $QryInsertPlanet .= "`temp_min` = '" . $planet['temp_min'] . "', "; $QryInsertPlanet .= "`temp_max` = '" . $planet['temp_max'] . "', "; $QryInsertPlanet .= "`metal` = '" . $planet['metal'] . "', "; $QryInsertPlanet .= "`metal_perhour` = '" . $planet['metal_perhour'] . "', "; $QryInsertPlanet .= "`metal_max` = '" . $planet['metal_max'] . "', "; $QryInsertPlanet .= "`crystal` = '" . $planet['crystal'] . "', "; $QryInsertPlanet .= "`crystal_perhour` = '" . $planet['crystal_perhour'] . "', "; $QryInsertPlanet .= "`crystal_max` = '" . $planet['crystal_max'] . "', "; $QryInsertPlanet .= "`deuterium` = '" . $planet['deuterium'] . "', "; $QryInsertPlanet .= "`deuterium_perhour` = '" . $planet['deuterium_perhour'] . "', "; $QryInsertPlanet .= "`deuterium_max` = '" . $planet['deuterium_max'] . "';"; doquery($QryInsertPlanet); // On recupere l'id de planete nouvellement créé $QrySelectPlanet = "SELECT `id` FROM `{{planets}}` WHERE "; $QrySelectPlanet .= "`galaxy` = '{$planet['galaxy']}' AND `system` = '{$planet['system']}' AND `planet` = '{$planet['planet']}' AND "; $QrySelectPlanet .= "`id_owner` = '{$planet['id_owner']}';"; $GetPlanetID = doquery($QrySelectPlanet, '', true); $RetValue = $GetPlanetID['id']; } else { $RetValue = false; } return $RetValue; }
function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array()) { global $lang, $config; /* Типы планет по плотности (г/см^3) - добыча при средней температуре: 1. <2 - Лёд (метановый, водный, водородный итд) + Газ (местами водород). Металл 0 Кристалл -- Дейтерий++ 2. 2-3.5 Силикат (кремний) + Водяной лёд + Газ (водород, метан). Метал --. Кристалл норма. Дейтерий + 3. 3.5-5 - Камень. Металл - Кристалл+ Дейтерий норма 4. 5-6 - Руда. Металл норма. Кристалл норма. Дейтерий норма 5. 6-7 - Металл. Металл +. Кристалл -. Дейтерий - 6. >7 - тяжелый металл. Металл ++ Кристалл -- Дейтерий -- sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4) 1-2-3 0..100 4-5-6 -25..75 7-8-9 -50..50 10-11-12 -75..25 13-14-15 -100..10 16+ -120..10 Типы планеты по средней температуре: 1. Замороженная - меньше -183 градусов Цельсия. Метановый лёд 2. Холодная - от -183 до -161 градусов. Жидкий метан, водный лёд 3. Ледяная - от -161 до -20. Газообразный метан, водный лёд 4. Земного типа - от -20 до +40 градусов 5. Горячая - от +40 до +80 градусов 6. Инферно - выше +80 градусов */ /* $density = array(0,0,0,0,0,0,0,); for($i = 0;$i<10000;$i++) { $q = sn_rand_gauss_range(850, 9250, true, 3); if($q < 2000) { $density[0]++; } elseif($q < 3250) { $density[1]++; } elseif($q < 4500) { $density[2]++; } elseif($q < 5750) { $density[3]++; } elseif($q < 7000) { $density[4]++; } elseif($q < 8250) { $density[5]++; } else { $density[6]++; } // pdump($q); } foreach($density as $key => $value) { echo $key,' ', $value, ' ', str_repeat('*', $value/30), '<br />'; 0. 0.75-2 - Лёд (метановый, водный, водородный итд) + Газ (местами водород). Металл 25% Кристалл 25% Дейтерий 175% 225%+ 1. 2-3.25 Силикат (кремний) + Водяной лёд + Газ (водород, метан). Метал 25% Кристалл 150% Дейтерий 75% 250%+ 2. 3.25-4.5 - Камень. Металл 50% Кристалл 125% Дейтерий 100% 275%+ 3. 4.5-5.75 - Стандарт Металл 100%. Кристалл 100% Дейтерий 100% 300%+ 4. 5.25-6.50 - Руда Металл 125% Кристалл 50% Дейтерий 100% 275%+ 5 6.50-7.75 Металл Металл 150% Кристалл 25% Дейтерий 75% 250%+ 6. >7.75-9 - тяжелый металл. Металл 175% Кристалл 25% Дейтерий 25% 225%+ Лёд Силикат Камень Стандарт Руда Металл Тяжмет } /* */ /* $planet_density = array( 2000 => array(RES_METAL => 0.25, RES_CRYSTAL => 0.25, RES_DEUTERIUM => 1.75), 3250 => array(RES_METAL => 0.25, RES_CRYSTAL => 1.50, RES_DEUTERIUM => 0.75), 4500 => array(RES_METAL => 0.50, RES_CRYSTAL => 1.25, RES_DEUTERIUM => 1.00), 5750 => array(RES_METAL => 1.00, RES_CRYSTAL => 1.00, RES_DEUTERIUM => 1.00), 7000 => array(RES_METAL => 1.25, RES_CRYSTAL => 0.50, RES_DEUTERIUM => 1.00), 8250 => array(RES_METAL => 1.50, RES_CRYSTAL => 0.25, RES_DEUTERIUM => 0.75), 9250 => array(RES_METAL => 1.75, RES_CRYSTAL => 0.25, RES_DEUTERIUM => 0.25), ); $planet_density = array( 850 => array(RES_METAL => 0.10, RES_CRYSTAL => 0.10, RES_DEUTERIUM => 1.30), 2000 => array(RES_METAL => 0.30, RES_CRYSTAL => 0.20, RES_DEUTERIUM => 1.20), // Лёд 3250 => array(RES_METAL => 0.40, RES_CRYSTAL => 1.40, RES_DEUTERIUM => 0.90), // Силикат 4500 => array(RES_METAL => 0.80, RES_CRYSTAL => 1.25, RES_DEUTERIUM => 0.80), // Камень 5750 => array(RES_METAL => 1.00, RES_CRYSTAL => 1.00, RES_DEUTERIUM => 1.00), // Норма 7000 => array(RES_METAL => 2.00, RES_CRYSTAL => 0.75, RES_DEUTERIUM => 0.75), // Руда 8250 => array(RES_METAL => 3.00, RES_CRYSTAL => 0.50, RES_DEUTERIUM => 0.50), // Металл 9250 => array(RES_METAL => 4.00, RES_CRYSTAL => 0.25, RES_DEUTERIUM => 0.25), // Тяжмет ); */ $planet_density = sn_get_groups('planet_density'); $density_min = reset($planet_density); $density_min = $density_min[UNIT_PLANET_DENSITY]; $density_max = end($planet_density); $density_max = $density_max[UNIT_PLANET_DENSITY]; $density = sn_rand_gauss_range($density_min, $density_max, true, 3); // Avant tout, on verifie s'il existe deja une planete a cet endroit $PlanetExist = db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`'); // Si $PlanetExist est autre chose que false ... c'est qu'il y a quelque chose la bas ... // C'est donc aussi que je ne peux pas m'y poser !! if (!$PlanetExist) { $planet = PlanetSizeRandomiser($Position, $HomeWorld); $planet['diameter'] = ($planet['field_max'] ^ 14 / 1.5) * 75; $planet['metal'] = BUILD_METAL; $planet['crystal'] = BUILD_CRISTAL; $planet['deuterium'] = BUILD_DEUTERIUM; $planet['metal_max'] = BASE_STORAGE_SIZE; $planet['crystal_max'] = BASE_STORAGE_SIZE; $planet['deuterium_max'] = BASE_STORAGE_SIZE; // Posistion 1 - 3: 80% entre 40 et 70 Cases ( 55+ / -15 ) // Posistion 4 - 6: 80% entre 120 et 310 Cases ( 215+ / -95 ) // Posistion 7 - 9: 80% entre 105 et 195 Cases ( 150+ / -45 ) // Posistion 10 - 12: 80% entre 75 et 125 Cases ( 100+ / -25 ) // Posistion 13 - 15: 80% entre 60 et 190 Cases ( 125+ / -65 ) $planet['galaxy'] = $Galaxy; $planet['system'] = $System; $planet['planet'] = $Position; if ($Position == 1 || $Position == 2 || $Position == 3) { $PlanetType = array('trocken'); $PlanetClass = array('planet'); // $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(0, 100); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 4 || $Position == 5 || $Position == 6) { $PlanetType = array('dschjungel'); $PlanetClass = array('planet'); // $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(-25, 75); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 7 || $Position == 8 || $Position == 9) { $PlanetType = array('normaltemp'); $PlanetClass = array('planet'); // $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07'); $planet['temp_min'] = rand(-50, 50); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 10 || $Position == 11 || $Position == 12) { $PlanetType = array('wasser'); $PlanetClass = array('planet'); // $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09'); $planet['temp_min'] = rand(-75, 25); $planet['temp_max'] = $planet['temp_min'] + 40; } elseif ($Position == 13 || $Position == 14 || $Position == 15) { $PlanetType = array('eis'); $PlanetClass = array('planet'); // $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); $planet['temp_min'] = rand(-100, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } else { $PlanetType = array('dschjungel', 'gas', 'normaltemp', 'trocken', 'wasser', 'wuesten', 'eis'); $PlanetClass = array('planet'); $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '00'); $planet['temp_min'] = rand(-140, 10); $planet['temp_max'] = $planet['temp_min'] + 40; } if ($HomeWorld) { $planet['temp_min'] = 0; $planet['temp_max'] = $planet['temp_min'] + 40; $planet['density'] = 5500; } else { $planet['density'] = $density; } foreach ($planet_density as $planet['density_index'] => $value) { if ($planet['density'] < $value[UNIT_PLANET_DENSITY]) { break; } } $density_info_resources =& $planet_density[$planet['density_index']][UNIT_RESOURCES]; $planet['metal_perhour'] = $config->metal_basic_income * $density_info_resources[RES_METAL]; $planet['crystal_perhour'] = $config->crystal_basic_income * $density_info_resources[RES_CRYSTAL]; $planet['deuterium_perhour'] = $config->deuterium_basic_income * $density_info_resources[RES_DEUTERIUM]; if (isset($options['image']) && $options['image']) { $planet['image'] = $options['image']; } else { $planet['image'] = $PlanetType[rand(0, count($PlanetType) - 1)]; $planet['image'] .= $PlanetClass[rand(0, count($PlanetClass) - 1)]; $planet['image'] .= $PlanetDesign[rand(0, count($PlanetDesign) - 1)]; } $planet['planet_type'] = 1; $planet['id_owner'] = $PlanetOwnerID; $planet['last_update'] = time(); $planet['name'] = $planet_name_unsafe ? $planet_name_unsafe : $lang['sys_colo_defaultname']; if (!$HomeWorld) { $OwnerName = db_user_by_id($PlanetOwnerID, false, 'username'); $planet['name'] = "{$OwnerName['username']} {$planet['name']}"; } $planet['name'] = db_escape(strip_tags(trim($planet['name']))); $RetValue = classSupernova::db_ins_record(LOC_PLANET, "`name` = '{$planet['name']}', `id_owner` = '{$planet['id_owner']}', `last_update` = '{$planet['last_update']}', `image` = '{$planet['image']}',\n `galaxy` = '{$planet['galaxy']}', `system` = '{$planet['system']}', `planet` = '{$planet['planet']}', `planet_type` = '{$planet['planet_type']}',\n `diameter` = '{$planet['diameter']}', `field_max` = '{$planet['field_max']}', `density` = '{$planet['density']}', `density_index` = '{$planet['density_index']}',\n `temp_min` = '{$planet['temp_min']}', `temp_max` = '{$planet['temp_max']}',\n `metal` = '{$planet['metal']}', `metal_perhour` = '{$planet['metal_perhour']}', `metal_max` = '{$planet['metal_max']}',\n `crystal` = '{$planet['crystal']}', `crystal_perhour` = '{$planet['crystal_perhour']}', `crystal_max` = '{$planet['crystal_max']}',\n `deuterium` = '{$planet['deuterium']}', `deuterium_perhour` = '{$planet['deuterium_perhour']}', `deuterium_max` = '{$planet['deuterium_max']}'"); // $RetValue = db_insert_id(); $RetValue = is_array($RetValue) ? $RetValue['id'] : false; } else { $RetValue = false; } return $RetValue; }
public function GalaxyRowPlanetName($GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $System, $Planet, $PlanetType, $HavePhalanx, $CurrentGalaxy, $CurrentSystem, $GalaxyRowWormHole) { global $user, $lang; if ($GalaxyRowPlanet['last_update'] > time() - 59 * 60 && $GalaxyRowUser['id'] != $user['id']) { $Inactivity = pretty_time_hour(time() - $GalaxyRowPlanet['last_update']); } if ($GalaxyRow && $GalaxyRowPlanet["destruyed"] == 0) { $Result = "<th style=\"white-space: nowrap;\" width=130>"; if ($HavePhalanx != 0) { if ($GalaxyRowPlanet["galaxy"] == $CurrentGalaxy) { $Range = $this->GetPhalanxRange($HavePhalanx); if ($CurrentGalaxy + $Range <= $CurrentSystem && $CurrentSystem >= $CurrentGalaxy - $Range) { $PhalanxTypeLink = "<a href=# onclick=fenster('game.php?page=phalanx&galaxy=" . $Galaxy . "&system=" . $System . "&planet=" . $Planet . "&planettype=" . $PlanetType . "') title=\"Phalanx\">" . $GalaxyRowPlanet['name'] . "</a><br />"; } else { $PhalanxTypeLink = stripslashes($GalaxyRowPlanet['name']); } } else { $PhalanxTypeLink = stripslashes($GalaxyRowPlanet['name']); } } else { $PhalanxTypeLink = stripslashes($GalaxyRowPlanet['name']); } $Result .= $TextColor . $PhalanxTypeLink . $EndColor; if ($GalaxyRowPlanet['last_update'] > time() - 59 * 60 && $GalaxyRowUser['id'] != $user['id']) { if ($GalaxyRowPlanet['last_update'] > time() - 10 * 60 && $GalaxyRowUser['id'] != $user['id']) { $Result .= "(*)"; } else { $Result .= " (" . $Inactivity . ")"; } } } elseif ($GalaxyRowWormHole) { $Result = "<th style=\"white-space: nowrap;\" width=130>"; if ($GalaxyRowWormHole['start_galaxy'] == $Galaxy and $GalaxyRowWormHole['start_system'] == $System and $GalaxyRowWormHole['start_planet'] == $Planet) { $Orientation = 'end'; } else { $Orientation = 'start'; } if ($GalaxyRowWormHole['state'] == 1) { $Result .= "<span style='color:yellow;'>Agujero de gusano [" . $GalaxyRowWormHole[$Orientation . '_galaxy'] . ":" . $GalaxyRowWormHole[$Orientation . '_system'] . ":" . $GalaxyRowWormHole[$Orientation . '_planet'] . "]</span>"; } elseif ($GalaxyRowWormHole['state'] == 2) { $Result .= "<span style='color:lime;'>Agujero de gusano [" . $GalaxyRowWormHole[$Orientation . '_galaxy'] . ":" . $GalaxyRowWormHole[$Orientation . '_system'] . ":" . $GalaxyRowWormHole[$Orientation . '_planet'] . "]</span>"; } elseif ($GalaxyRowWormHole['state'] == 0) { $Result .= "<span style='color:red;'>Agujero de gusano [" . $GalaxyRowWormHole[$Orientation . '_galaxy'] . ":" . $GalaxyRowWormHole[$Orientation . '_system'] . ":" . $GalaxyRowWormHole[$Orientation . '_planet'] . "]</span>"; } } elseif ($GalaxyRowPlanet["destruyed"] != 0) { $Result .= $lang['gl_planet_destroyed']; } else { $Result .= "<a id='colo" . $Planet . "' class='coloLink' href=\"game.php?page=fleet&galaxy=" . $Galaxy . "&system=" . $System . "&planet=" . $Planet . "&planettype=1&target_mission=7\">[Colonizar]</a>"; $Fields = PlanetSizeRandomiser($Planet, false, true); AddTooltip("#colo" . $Planet, 'Envia un Colonizador a esta posicion y crea una Colonia<br/><br/><b>Campos estimados</b><br/>De <span style=color:lime;>' . $Fields[0] . '</span> a <span style=color:lime; >' . $Fields[1] . '</span> campos', 'Colonizar'); } $Result .= "</th>"; return $Result; }
define('INSTALL', false); $xnova_root_path = './'; include $xnova_root_path . 'extension.inc'; include $xnova_root_path . 'common.' . $phpEx; function missilerange($impulse) { if ($user[$resource[117]] > 0) { $MissileRange = $user[$resource[117]] * 5 - 1; } elseif ($user[$resource[117]] == 0) { $MissileRange = 0; } return $MissileRange; } if ($_GET['type'] == "planetsize") { if (is_numeric($_GET['pos'])) { $size = PlanetSizeRandomiser($_GET['pos'], false, true); echo "<br /><font color=red>" . $size['field_max'] . "</font><br /><br /><br />"; echo "<form action='' method='GET'>\r\n\t\t<input type='hidden' value='planetsize' name='type' />\r\n\t\t<input type='s' value='" . UNI . "' name='type' />\r\n\t\tPosition: <input type='text' name='pos' value='" . $_GET['pos'] . "' maxlenth='2' size='3' />\r\n\t\t<input type='submit' value='Go' />"; } else { echo "<form action='' method='GET'>\r\n\t\t<input type='hidden' value='planetsize' name='type' />\r\n\t\t<input type='s' value='" . UNI . "' name='type' />\r\n\t\tPosition: <input type='text' name='pos' maxlenth='2' size='3' />\r\n\t\t<input type='submit' value='Go' />"; } } elseif ($_GET['type'] == "missilerange") { if (is_numeric($_GET['impulse'])) { $userimpulse = $user[$resource[117]]; $user[$resource[117]] = $_GET['impulse']; $result = GetMissileRange(); $user[$resource[117]] = $userimpulse; echo "<br /><font color=red>With Impulse drive level " . $_GET['impulse'] . " you can fire across " . $result . " systems</font><br /><br /><br />"; echo "<form action='' method='GET'>\r\n\t\t<input type='hidden' value='missilerange' name='type' />\r\n\t\t<input type='s' value='" . UNI . "' name='type' />\r\n\t\tImpulse Drive: <input type='text' name='impulse' value='" . ($_GET['impulse'] + 1) . "' maxlenth='2' size='3' />\r\n\t\t<input type='submit' value='Go' />"; } else { echo "<form action='' method='GET'>\r\n\t\t<input type='hidden' value='missilerange' name='type' />\r\n\t\t<input type='s' value='" . UNI . "' name='type' />\r\n\t\tImpulse Drive: <input type='text' name='impulse' maxlenth='2' size='3' />\r\n\t\t<input type='submit' value='Go' />";