public static function create(CelestialBodyEntity $celestialBodyEntity, CelestialBodySpecialtyRepository $celestialBodySpecialtyRepository) { $result = null; switch ($celestialBodyEntity->getType()) { case CelestialBodyEntity::DISCR_ASTEROID: $result = new AsteroidModel($celestialBodyEntity); break; case CelestialBodyEntity::DISCR_ELECTRICITY_STORM: $result = new ElectricityStormModel($celestialBodyEntity); break; case CelestialBodyEntity::DISCR_GAS_GIANT: $result = new GasGiantModel($celestialBodyEntity); break; case CelestialBodyEntity::DISCR_GRAVIMETRIC_ANOMALY: $result = new GravimetricAnomalyModel($celestialBodyEntity); break; case CelestialBodyEntity::DISCR_ICE_GIANT: $result = new IceGiantModel($celestialBodyEntity); break; case CelestialBodyEntity::DISCR_ION_STORM: $result = new IonStormModel($celestialBodyEntity); break; case CelestialBodyEntity::DISCR_SPATIAL_DISTORTION: $result = new SpatialDistortionModel($celestialBodyEntity); break; case CelestialBodyEntity::DISCR_TERRESTRIAL_PLANET: $result = new TerrestrialPlanetModel($celestialBodyEntity, $celestialBodySpecialtyRepository); break; case CelestialBodyEntity::DISCR_VOID: $result = new VoidModel($celestialBodyEntity); break; } return $result; }
/** * @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())); }
/** * Returns a label for this celestial body. Can be used as text for links. */ public function getLabel() { $system = $this->celestialBodyEntity->getSystem(); $galaxy = $system->getGalaxy(); return $this->createLabel($galaxy->getNumber(), $system->getNumber(), $this->celestialBodyEntity->getNumber()); }