diff --git a/src/Module/Colony/Action/BuildOnField/BuildOnField.php b/src/Module/Colony/Action/BuildOnField/BuildOnField.php index ccf73220b..a1e1e0948 100644 --- a/src/Module/Colony/Action/BuildOnField/BuildOnField.php +++ b/src/Module/Colony/Action/BuildOnField/BuildOnField.php @@ -114,22 +114,29 @@ public function handle(GameControllerInterface $game): void $building = $alt_building->getAlternativeBuilding(); } - if ($field->hasBuilding() && $host instanceof ColonyInterface) { - if (!$this->checkBuildingCosts($host, $building, $field, $game)) { - return; - } elseif ($host->getEps() < $building->getEpsCost()) { - $game->addInformationf( - _('Zum Bau wird %d Energie benötigt - Vorhanden ist nur %d'), - $building->getEpsCost(), - $host->getEps() - ); - return; - } elseif ($host->getEps() > $host->getMaxEps() - $field->getBuilding()->getEpsStorage() && $host->getMaxEps() - $field->getBuilding()->getEpsStorage() < $building->getEpsCost()) { - $game->addInformation(_('Nach der Demontage steht nicht mehr genügend Energie zum Bau zur Verfügung')); - return; - } else { - $this->buildingAction->remove($field, $game); + if ($field->hasBuilding()) { + + if ($host instanceof ColonyInterface) { + + if (!$this->checkBuildingCosts($host, $building, $field, $game)) { + return; + } elseif ($host->getEps() < $building->getEpsCost()) { + $game->addInformationf( + _('Zum Bau wird %d Energie benötigt - Vorhanden ist nur %d'), + $building->getEpsCost(), + $host->getEps() + ); + return; + } elseif ( + $host->getEps() > $host->getMaxEps() - $field->getBuilding()->getEpsStorage() + && $host->getMaxEps() - $field->getBuilding()->getEpsStorage() < $building->getEpsCost() + ) { + $game->addInformation(_('Nach der Demontage steht nicht mehr genügend Energie zum Bau zur Verfügung')); + return; + } } + + $this->buildingAction->remove($field, $game); } if ($host instanceof ColonyInterface && !$this->doColonyChecksAndConsume($field, $building, $host, $game)) {