Skip to content

Commit

Permalink
Merge pull request #508 from yazilimmz/310-energy-and-deuterium-mine-…
Browse files Browse the repository at this point in the history
…production

fixed #310 energy and deuterium mine production
  • Loading branch information
lanedirt authored Dec 24, 2024
2 parents e1478d2 + 4e3ae50 commit ec82b98
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/GameObjects/BuildingObjects.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static function get(): array
$deuteriumSynthesizer->valid_planet_types = [PlanetType::Planet];

$deuteriumSynthesizer->production = new GameObjectProduction();
$deuteriumSynthesizer->production->deuterium = 'return ((10 * $object_level * pow((1.1), $object_level)) * (-0.002 * $planet_temperature + 1.28)) * (0.1 * $building_percentage);';
$deuteriumSynthesizer->production->deuterium = 'return ((10 * $object_level * pow((1.1), $object_level)) * (1.44 - 0.004 * $planet_max_temperature) ) * (0.1 * $building_percentage);';
$deuteriumSynthesizer->production->energy = 'return - (20 * $object_level * pow((1.1), $object_level)) * (0.1 * $building_percentage);';

$deuteriumSynthesizer->assets = new GameObjectAssets();
Expand Down
2 changes: 1 addition & 1 deletion app/GameObjects/CivilShipObjects.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static function get(): array

$solarSatellite->production = new GameObjectProduction();
// TODO: solar satellite production formula should be dependent on the planet position: proximity to sun.
$solarSatellite->production->energy = 'return (20 * $object_level) * (0.1 * $building_percentage);';
$solarSatellite->production->energy = 'return (floor(($planet_max_temperature + 140) / 6) * $object_level) * (0.1 * $building_percentage);';

$solarSatellite->properties = new GameObjectProperties($solarSatellite, 2000, 1, 0, 0, 0, 1);

Expand Down
1 change: 1 addition & 0 deletions app/Services/PlanetService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ public function getObjectProduction(string $machine_name, int|null $object_level

$building_percentage = !$force_factor ? $this->getBuildingPercent($machine_name) : 100;
$planet_temperature = $this->getPlanetTempAvg();
$planet_max_temperature = $this->getPlanetTempMax();
$energy_technology_level = 0; // Implement energy technology level getter.
$universe_resource_multiplier = $this->settingsService->economySpeed();

Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/ResourceProductionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ public function testSolarSatelliteEnergyProduction(): void
$this->createAndSetPlanetModel([
'solar_satellite' => 100,
'solar_satellite_percent' => 10,
'temp_max' => 100
]);

// Currently solar satellites produce fixed 20 energy each.
// So 100 satellites should produce 2000 energy.
// @TODO: this will need to be updated once the planet temperature
// is added and the energy production formula is updated.
$this->assertEquals(2000, $this->planetService->energyProduction()->get());
$this->assertEquals(4000, $this->planetService->energyProduction()->get());
}
}

0 comments on commit ec82b98

Please sign in to comment.