/** * @todo Maybe refine this. Better resources values might mean worse gravity/ * living conditions. * Also, gravity has a wide range. Produce more planets within the * "normal" zone. * Maybe use binomial distribution. * @param CelestialBodyEntity $celestialBodyEntity */ private function shuffleCelestialBodySpecs(CelestialBodyEntity $celestialBodyEntity) { $galaxyModel = new GalaxyModel($celestialBodyEntity->getSystem()->getGalaxy()); $maxSpecs = $galaxyModel->getMaxCelestialBodySpecs($celestialBodyEntity->getType()); $minSpecs = $galaxyModel->getMinCelestialBodySpecs($celestialBodyEntity->getType()); foreach ($this->celestialBodySpecialtyRepository->findAll() as $specialty) { $assignSpecialty = rand(1, self::SPECIALTY_LIKELIHOOD) === 1; if ($assignSpecialty) { $celestialBodyEntity->getSpecialties()->add($specialty); } } $effects = $celestialBodyEntity->getSpecs()->getEffects(); $minEffects = $minSpecs->getEffects(); $maxEffects = $maxSpecs->getEffects(); $effects->setBuildingCost($this->rand($minEffects->getBuildingCost(), $maxEffects->getBuildingCost())); $effects->setBuildingTime($this->rand($minEffects->getBuildingTime(), $maxEffects->getBuildingTime())); $effects->setFleetScannerRange($this->rand($minEffects->getFleetScannerRange(), $maxEffects->getFleetScannerRange())); $effects->setResearchPoints($this->rand($minEffects->getResearchPoints(), $maxEffects->getResearchPoints())); $effects->setTaxes($this->rand($minEffects->getTaxes(), $maxEffects->getTaxes())); $specs = $celestialBodyEntity->getSpecs(); $specs->setGravity($this->rand($minSpecs->getGravity(), $maxSpecs->getGravity())); $specs->setLivingConditions($this->rand($minSpecs->getLivingConditions(), $maxSpecs->getLivingConditions())); $resourceDensity = $celestialBodyEntity->getSpecs()->getResourceDensity(); $minResourceDensity = $minSpecs->getResourceDensity(); $maxResourceDensity = $maxSpecs->getResourceDensity(); $resourceDensity->setChemicals($this->rand($minResourceDensity->getChemicals(), $maxResourceDensity->getChemicals())); $resourceDensity->setIce($this->rand($minResourceDensity->getIce(), $maxResourceDensity->getIce())); $resourceDensity->setIron($this->rand($minResourceDensity->getIron(), $maxResourceDensity->getIron())); }