From: Roland Haeder Date: Mon, 29 Jun 2015 03:08:22 +0000 (+0200) Subject: Added task 'household_growth' + updated 'core'. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1c18b6937dd9676c478a8919c1c7da5449d0ba3c;p=city.git Added task 'household_growth' + updated 'core'. Signed-off-by: Roland Haeder --- diff --git a/application/city/config.php b/application/city/config.php index 9a3e9b2..63e6786 100644 --- a/application/city/config.php +++ b/application/city/config.php @@ -543,5 +543,17 @@ $cfg->setConfigEntry('task_map_expander_interval_delay', 100); // CFG: TASK-MAP-EXPANDER-MAX-RUNS $cfg->setConfigEntry('task_map_expander_max_runs', 0); +// CFG: CITY-DAEMON-HOUSEHOLD-GROWTH-TASK-CLASS +$cfg->setConfigEntry('city_daemon_household_growth_task_class', 'CityDaemonHouseholdGrowthTask'); + +// CFG: TASK-HOUSEHOLD-GROWTH-STARTUP-DELAY +$cfg->setConfigEntry('task_household_growth_startup_delay', 1000); + +// CFG: TASK-HOUSEHOLD-GROWTH-INTERVAL-DELAY +$cfg->setConfigEntry('task_household_growth_interval_delay', 200); + +// CFG: TASK-HOUSEHOLD-GROWTH-MAX-RUNS +$cfg->setConfigEntry('task_household_growth_max_runs', 0); + // [EOF] ?> diff --git a/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php b/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php index b2d3e4c..893a910 100644 --- a/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php +++ b/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php @@ -70,6 +70,12 @@ class CityDaemonTaskHandlerInitializerFilter extends BaseCityFilter implements F // Register it $handlerInstance->registerTask('map_expander', $taskInstance); + // Prepare a household growth task + $taskInstance = ObjectFactory::createObjectByConfiguredName('city_daemon_household_growth_task_class'); + + // Register it + $handlerInstance->registerTask('household_growth', $taskInstance); + /* * Add extra tasks depending on daemon modus. */ diff --git a/application/city/main/tasks/daemon/household/.htaccess b/application/city/main/tasks/daemon/household/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/tasks/daemon/household/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/tasks/daemon/household/class_CityDaemonHouseholdGrowthTask.php b/application/city/main/tasks/daemon/household/class_CityDaemonHouseholdGrowthTask.php new file mode 100644 index 0000000..ea041ed --- /dev/null +++ b/application/city/main/tasks/daemon/household/class_CityDaemonHouseholdGrowthTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CityDaemonHouseholdGrowthTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCityDaemonHouseholdGrowthTask () { + // Get new instance + $taskInstance = new CityDaemonHouseholdGrowthTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% done + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/core b/core index 15bab11..3391522 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 15bab1114f3d4e33c67d035a7d3c20a8babeee81 +Subproject commit 339152247b6ea0fd31e96571303dc31d7a32aa7d diff --git a/docs/tasks.txt b/docs/tasks.txt index 364a88d..475910c 100644 --- a/docs/tasks.txt +++ b/docs/tasks.txt @@ -1,10 +1,11 @@ The following tasks are used: ----------------------------- -Name | Description ---------------+-------------------------------- - map_expander | Expands the city map if needed ---------------+-------------------------------- + Name | Done | Description +------------------+------+-------------------------------- + map_expander | 0% | Expands the city map if needed + household_growth | 0% | Growths a single household +------------------+------+-------------------------------- - - - - - @@ -25,4 +26,36 @@ close ("city border threashold") to the border (default: 10). If that value has reached or surpassed (to close, e.g. by constructing a long road) the map is expanded (default: 10+100 from outer-most). +- - - - - + +Task 'household_growth': +------------------------ + +The task is responsible for growing all households. The task checks if an empty +zone is given and several pre-conditions are met: + +1) A road/path way is nearby (must be given but it will be checked anyway). + +2) The zone is not to small (minimum: 2x1 as 1 square must be given as distance + to the road. This however will be pre-checked by the client. + +3) The land value of the resitential zone is not to low (below zero) as this + hinders that people move in. Please note that some other zones (e.g. + landfills) may reduce land value around them). + +4) The land value is not to high for the citizen (cannot effort to buy the + zone). + +5) There is no initial "building" (e.g. hut) on the zone or the existing + building is a multi-household building and has at least one appartment for + sale. Please note that rich people prefer low-density and high land-value + zones over high-density zones except it is an expansive multi-household + building. + +The task also checks if an existing household has 2 adults of different gender +(1 male, 1 female). Only under this condition reproduction is possible and a +3rd person may be added to it (after about 260-280 days). Adoption is not yet +simulated and may not be added. Please note that this is a city growth +simulation and not a social simulation. + [EOF]