/** * @see AbstractFleetEventHandler::executeImpact() */ public function executeImpact() { // check colonies $sql = "SELECT COUNT(*) AS count\r\n\t\t\t\tFROM ugml_planets\r\n\t\t\t\tWHERE planetKind = 1\r\n\t\t\t\t\tAND id_owner = " . $this->ownerID; $count = WCF::getDB()->getFirstRow($sql); // get existing planet $system = new System($this->galaxy, $this->system); $planetObj = $system->getPlanet($this->planet); // restricted by planet limit if ($count['count'] >= self::MAX_PLANETS) { $this->message = 'planetLimit'; return; } // planet exists if ($planetObj !== null) { $this->message = 'exists'; return; } // create planet --$this->fleet[self::COLONY_SHIP]; $name = WCF::getLanguage()->get('wot.planet.colony'); $planet = PlanetEditor::create($this->galaxy, $this->system, $this->planet, $name, $this->ownerID, self::DEFAULT_METAL, self::DEFAULT_CRYSTAL, self::DEFAULT_DEUTERIUM, 1, time(), self::DEFAULT_FIELDS, null); $planet->getEditor()->changeResources($this->metal, $this->crystal, $this->deuterium); $planet->getEditor()->changeLevel($this->fleet); $this->getEditor()->delete(); }
/** * Save Data: Saves a moon if created */ protected function saveDataMoon() { if ($this->moon['size'] !== null) { $fields = floor(pow($this->moon['size'] / 1000, 2)); $name = WCF::getLanguage()->get('wot.global.moon.defaultName'); PlanetEditor::create($this->galaxy, $this->system, $this->planet, $name, $this->ofiaraID, 0, 0, 0, self::MOON_PLANET_TYPE_ID, $this->impactTime, $fields, $this->moon['temp']); } }
/** * Creates a new planet. */ protected function createPlanet() { list($galaxy, $system, $planet) = $this->findCoordinates(); $planetObj = PlanetEditor::create($galaxy, $system, $planet, 'Heimatplanet', $this->data['userid'], 500, 500, 0, 1, time(), 400); $sql = "UPDATE ugml_users\n\t\t\t\tSET current_planet = " . $planetObj->planetID . ",\n\t\t\t\t\tid_planet = " . $planetObj->planetID . ",\n\t\t\t\t\tgalaxy = " . $galaxy . ",\n\t\t\t\t\tsystem = " . $system . ",\n\t\t\t\t\tplanet = " . $planet . "\n\t\t\t\tWHERE id = " . $this->data['userid']; WCF::getDB()->sendQuery($sql); }