Exemplo n.º 1
0
 public static function NewColony($name, Coordinates $coordinates, User $owner, $isHomecolony, $ismoon = FALSE)
 {
     // Import the configuration file.
     global $NN_config;
     // Create a new colony.
     $colony = new Colony();
     // Colony details
     $colony->Name($name);
     $colony->Coordinates($coordinates);
     $colony->Owner($owner);
     $colony->HomeColony($isHomecolony);
     // Resources
     $colony->CurrentResources(new Cost($NN_config["starting_amount_metal"], $NN_config["starting_amount_crystal"], $NN_config["starting_amount_deuterium"], 0));
     // Storage
     $colony->MetalStorage($NN_config["starting_storage"]);
     $colony->CrystalStorage($NN_config["starting_storage"]);
     $colony->DeuteriumStorage($NN_config["starting_storage"]);
     // Generate available fields
     $colony->GenerateFields();
     $colony->UsedFields(0);
     // Generate the planet's properties (temperature, image)
     $colony->GeneratePlanetProperties();
     // Set the "Last updated" variable
     $colony->LastUpdated(time());
     // TODO: dump this and make a separate class for moons perhaps, we can get planet class with PlanetType->ID()
     // Is this colony a moon?
     $colony->IsMoon($ismoon);
     // Generate building units
     $colony->BuildingUnits(BuildingGroup::GenerateBuildingUnits($colony));
     // Generate production units
     $colony->ProductionUnits(BuildingGroup::GenerateProductionUnits($colony));
     // Generate defenses
     $colony->Defenses(CombatGroup::GenerateDefenses($colony));
     // Generate home fleet
     $colony->Fleet(CombatGroup::GenerateShips($colony));
     return $colony;
 }