Skip to content

Commit

Permalink
fix building replacement in colony sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
g5bot committed Jan 28, 2025
1 parent f69b966 commit 92b4258
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/Module/Colony/Action/BuildOnField/BuildOnField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 92b4258

Please sign in to comment.