Ejemplo n.º 1
0
 /**
  * @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()));
 }
Ejemplo n.º 2
0
 /**
  * Resets the celestial body attributes to the defaults for new players.
  */
 public function reset()
 {
     // TODO Check modifiers of system and galaxy? Throw if there are any?
     //      Basically, we only want to reset planets for new players.
     //      Those shouldn't be in chaos galaxies or systems with nebula.
     $specs = $this->terrestrialPlanetEntity->getSpecs();
     $specs->setGravity(1.0);
     $specs->setLivingConditions(1.0);
     $specs->getResourceDensity()->setChemicals(1.0);
     $specs->getResourceDensity()->setIce(0.3);
     $specs->getResourceDensity()->setIron(1.0);
     $specs->getEffects()->setBuildingCost(1.0);
     $specs->getEffects()->setBuildingTime(1.0);
     $specs->getEffects()->setFleetScannerRange(1.0);
     $specs->getEffects()->setResearchPoints(1.0);
     $specs->getEffects()->setTaxes(1.0);
     $specialties = $this->terrestrialPlanetEntity->getSpecialties();
     $specialties->clear();
     $specialties->add($this->celestialBodySpecialtyRepository->getMoon());
 }