summaryrefslogtreecommitdiff
path: root/src/Controller/Building.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-11-29 09:35:27 +0100
committerDaniel Weipert <code@drogueronin.de>2023-11-29 09:35:27 +0100
commit3afcaef927391db23fe23c6c8c26b8960e8dae32 (patch)
tree143b9f6df9e8c795c8c6ed901bffdc7119f40df1 /src/Controller/Building.php
parentc4ce3e884a6aa527bcc138771617215cf03265a4 (diff)
intermediate commit
Diffstat (limited to 'src/Controller/Building.php')
-rw-r--r--src/Controller/Building.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Controller/Building.php b/src/Controller/Building.php
index d8fe656..6199286 100644
--- a/src/Controller/Building.php
+++ b/src/Controller/Building.php
@@ -5,6 +5,7 @@ namespace App\Controller;
use App\DB;
use App\Model\Building as Model;
use App\Model\Event;
+use App\Model\Event\UpgradeBuilding;
use App\Model\Village;
use App\Router;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -18,7 +19,7 @@ class Building
public function levelUp(Request $request): Response
{
$village = Village::getByCoordinates($request->get('x'), $request->get('y'));
- $building = Model::getByVillage($village->id, $request->get('type'));
+ $building = Model::getByVillage($village->id, $request->get('type')) ?? Model::getEmpty($village->id, $request->get('type'));
// resources
foreach ($building->getResourceRequirements() as $resourceType => $resourceValue) {
@@ -27,11 +28,12 @@ class Building
$village->updateResources();
// event
- $event = new Event();
+ $event = new UpgradeBuilding();
$event->type = 'UpgradeBuilding';
$event->time = (new \DateTime())->add(\DateInterval::createFromDateString($building->getBuildTime() . ' seconds'));
$event->payload = json_encode([
- 'id' => $building->id,
+ 'type' => $building->type,
+ 'village_id' => $building->villageId,
]);
DB::query(