]> git.mxchange.org Git - city.git/blob - application/city/classes/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.php
Continued:
[city.git] / application / city / classes / tasks / daemon / building / class_CityDaemonBuildingGrowthTask.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\City\Daemon\Task\Growth\Building;
4
5 // Import application-specific stuff
6 use Org\Mxchange\City\Daemon\Factory\CityDaemonFactory;
7 use Org\Mxchange\City\Task\BaseCityTask;
8
9 // Import framework stuff
10 use Org\Mxchange\CoreFramework\Task\Taskable;
11 use Org\Mxchange\CoreFramework\Visitor\Visitable;
12 use Org\Mxchange\CoreFramework\Visitor\Visitor;
13
14 /**
15  * A BuildingGrowth city daemon-task
16  *
17  * @author              Roland Haeder <webmaster@ship-simu.org>
18  * @version             0.0.0
19  * @copyright   Copyright (c) 2015, 2016 City Developer Team
20  * @license             GNU GPL 3.0 or any newer version
21  * @link                http://www.ship-simu.org
22  *
23  * This program is free software: you can redistribute it and/or modify
24  * it under the terms of the GNU General Public License as published by
25  * the Free Software Foundation, either version 3 of the License, or
26  * (at your option) any later version.
27  *
28  * This program is distributed in the hope that it will be useful,
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31  * GNU General Public License for more details.
32  *
33  * You should have received a copy of the GNU General Public License
34  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
35  */
36 class CityDaemonBuildingGrowthTask extends BaseCityTask implements Taskable, Visitable {
37         /**
38          * Protected constructor
39          *
40          * @return      void
41          */
42         protected function __construct () {
43                 // Call parent constructor
44                 parent::__construct(__CLASS__);
45         }
46
47         /**
48          * Creates an instance of this class
49          *
50          * @return      $taskInstance   An instance of a Visitable class
51          */
52         public final static function createCityDaemonBuildingGrowthTask () {
53                 // Get new instance
54                 $taskInstance = new CityDaemonBuildingGrowthTask();
55
56                 // Get city daemon instance
57                 $cityInstance = CityDaemonFactory::createCityDaemonInstance();
58
59                 // Set it here for "caching" it
60                 $taskInstance->setCityInstance($cityInstance);
61
62                 // Return the prepared instance
63                 return $taskInstance;
64         }
65
66         /**
67          * Accepts the visitor to process the visitor
68          *
69          * @param       $visitorInstance        An instance of a Visitor class
70          * @return      void
71          * @todo        Maybe visit some sub-objects
72          */
73         public function accept (Visitor $visitorInstance) {
74                 // Visit this task
75                 $visitorInstance->visitTask($this);
76         }
77
78         /**
79          * Executes the task
80          *
81          * @return      void
82          * @todo        0% done
83          */
84         public function executeTask () {
85                 // Get daemon instance
86                 $cityInstance = $this->getCityInstance();
87
88                 // Is there at least one building to expand?
89                 if ($cityInstance->isBuildingPendingExpansion()) {
90                         // Expand the building
91                         $cityInstance->expandBuildings();
92                 } // END - if
93         }
94
95         /**
96          * Shuts down the task
97          *
98          * @return      void
99          * @todo        0% done
100          */
101         public function doShutdown () {
102                 self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
103         }
104 }