From fa9096c0ab521aae45cab6c48a54290d14a221b9 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 29 Nov 2023 11:03:15 +0100 Subject: event tables --- src/EventRunner.php | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) (limited to 'src/EventRunner.php') diff --git a/src/EventRunner.php b/src/EventRunner.php index a071d32..7dd773d 100644 --- a/src/EventRunner.php +++ b/src/EventRunner.php @@ -9,7 +9,9 @@ use App\Model\Building\IronMine; use App\Model\Building\ResourceGenerator; use App\Model\Building\Storage; use App\Model\Building\WoodCutter; -use App\Model\Event; +use App\Model\Event\SendUnits; +use App\Model\Event\TrainUnits; +use App\Model\Event\UpgradeBuilding; use App\Model\Village; class EventRunner @@ -18,28 +20,57 @@ class EventRunner { // Events - $results = DB::query('select * from events where time < now()')->fetchAll(); + # Upgrade Building + + $results = DB::query(<<fetchAll(); foreach ($results as $row) { - /**@var Event $event*/ - $event = DB::convertToModel(Event::resolveType($row['type']), $row); + /**@var UpgradeBuilding $event*/ + $event = DB::convertToModel(UpgradeBuilding::class, $row); $event(); - DB::query( - 'delete from events where id=:id', - ['id' => $event->id] - ); + $event->dbDelete(); } - # Upgrade Building + # Train Units $results = DB::query(<<fetchAll(); + foreach ($results as $row) { + /**@var TrainUnits $event*/ + $event = DB::convertToModel(TrainUnits::class, $row); + $event(); + + $event->dbDelete(); + } + + # Send Units + + $results = DB::query(<<fetchAll(); + + foreach ($results as $row) { + /**@var SendUnits $event*/ + $event = DB::convertToModel(SendUnits::class, $row); + $event(); + + $event->dbDelete(); + } + // Resources -- cgit v1.2.3