diff --git a/app/Http/Controllers/Abstracts/AbstractUnitsController.php b/app/Http/Controllers/Abstracts/AbstractUnitsController.php index 061ea48a..520b6f0d 100644 --- a/app/Http/Controllers/Abstracts/AbstractUnitsController.php +++ b/app/Http/Controllers/Abstracts/AbstractUnitsController.php @@ -99,12 +99,16 @@ public function index(Request $request, PlayerService $player, ObjectService $ob // Check if the current planet has enough resources to build this building. $enough_resources = $planet->hasResources($objects->getObjectPrice($object->machine_name, $planet)); + // Get maximum build amount of this building + $max_build_amount = $objects->getObjectMaxBuildAmount($object->machine_name, $planet, $requirements_met); + $view_model = new UnitViewModel(); $view_model->object = $object; $view_model->count = $count; $view_model->amount = $amount; $view_model->requirements_met = $requirements_met; $view_model->enough_resources = $enough_resources; + $view_model->max_build_amount = $max_build_amount; $view_model->currently_building = (!empty($build_active) && $build_active->object->machine_name == $object->machine_name); $view_model->currently_building_amount = (!empty($build_active) && $build_active->object->machine_name == $object->machine_name) ? $build_active->object_amount_remaining : 0; diff --git a/app/Services/ObjectService.php b/app/Services/ObjectService.php index 70557f06..c9b83abe 100644 --- a/app/Services/ObjectService.php +++ b/app/Services/ObjectService.php @@ -373,6 +373,11 @@ public function getObjectMaxBuildAmount(string $machine_name, PlanetService $pla return 0; } + // Objects only be able to be built once + if ($machine_name === 'small_shield_dome' || $machine_name === 'large_shield_dome') { + return $planet->getObjectAmount($machine_name) ? 0 : 1; + } + $price = $this->getObjectPrice($machine_name, $planet); // Calculate max build amount based on price diff --git a/app/ViewModels/UnitViewModel.php b/app/ViewModels/UnitViewModel.php index efa2e124..00e6937f 100644 --- a/app/ViewModels/UnitViewModel.php +++ b/app/ViewModels/UnitViewModel.php @@ -11,6 +11,7 @@ class UnitViewModel public int $amount; public bool $requirements_met; public bool $enough_resources; + public int $max_build_amount; public bool $currently_building; public int $currently_building_amount; } diff --git a/resources/views/ingame/ajax/object.blade.php b/resources/views/ingame/ajax/object.blade.php index bd5f439f..683a6329 100644 --- a/resources/views/ingame/ajax/object.blade.php +++ b/resources/views/ingame/ajax/object.blade.php @@ -163,7 +163,7 @@ - @if ($object_type == \OGame\GameObjects\Models\Enums\GameObjectType::Ship || $object_type == \OGame\GameObjects\Models\Enums\GameObjectType::Defense) + @if ($max_build_amount && ($object_type == \OGame\GameObjects\Models\Enums\GameObjectType::Ship || $object_type == \OGame\GameObjects\Models\Enums\GameObjectType::Defense))
@@ -181,7 +181,7 @@