diff options
Diffstat (limited to 'src/Controller/Building.php')
-rw-r--r-- | src/Controller/Building.php | 8 |
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( |