From 16af2d372d6239f7083aa09547850a90346a6197 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 29 Jun 2015 06:48:54 +0200 Subject: [PATCH] Added new task + documentation for building growth. Signed-off-by: Roland Haeder --- application/city/config.php | 12 +++ ...CityDaemonTaskHandlerInitializerFilter.php | 6 ++ .../city/main/tasks/daemon/building/.htaccess | 1 + .../class_CityDaemonBuildingGrowthTask.php | 82 +++++++++++++++++++ docs/tasks.txt | 50 ++++++++++- 5 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 application/city/main/tasks/daemon/building/.htaccess create mode 100644 application/city/main/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.php diff --git a/application/city/config.php b/application/city/config.php index cb910ab..5e98a6a 100644 --- a/application/city/config.php +++ b/application/city/config.php @@ -555,5 +555,17 @@ $cfg->setConfigEntry('task_household_growth_interval_delay', 200); // CFG: TASK-HOUSEHOLD-GROWTH-MAX-RUNS $cfg->setConfigEntry('task_household_growth_max_runs', 0); +// CFG: CITY-DAEMON-BUILDING-GROWTH-TASK-CLASS +$cfg->setConfigEntry('city_daemon_building_growth_task_class', 'CityDaemonBuildingGrowthTask'); + +// CFG: TASK-BUILDING-GROWTH-STARTUP-DELAY +$cfg->setConfigEntry('task_building_growth_startup_delay', 1000); + +// CFG: TASK-BUILDING-GROWTH-INTERVAL-DELAY +$cfg->setConfigEntry('task_building_growth_interval_delay', 200); + +// CFG: TASK-BUILDING-GROWTH-MAX-RUNS +$cfg->setConfigEntry('task_building_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 893a910..f4b8fbf 100644 --- a/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php +++ b/application/city/main/filter/task/city_daemon/class_CityDaemonTaskHandlerInitializerFilter.php @@ -76,6 +76,12 @@ class CityDaemonTaskHandlerInitializerFilter extends BaseCityFilter implements F // Register it $handlerInstance->registerTask('household_growth', $taskInstance); + // Prepare a building growth task + $taskInstance = ObjectFactory::createObjectByConfiguredName('city_daemon_building_growth_task_class'); + + // Register it + $handlerInstance->registerTask('building_growth', $taskInstance); + /* * Add extra tasks depending on daemon modus. */ diff --git a/application/city/main/tasks/daemon/building/.htaccess b/application/city/main/tasks/daemon/building/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/tasks/daemon/building/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.php b/application/city/main/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.php new file mode 100644 index 0000000..b133795 --- /dev/null +++ b/application/city/main/tasks/daemon/building/class_CityDaemonBuildingGrowthTask.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 CityDaemonBuildingGrowthTask 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 createCityDaemonBuildingGrowthTask () { + // Get new instance + $taskInstance = new CityDaemonBuildingGrowthTask(); + + // 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/docs/tasks.txt b/docs/tasks.txt index 475910c..a974e91 100644 --- a/docs/tasks.txt +++ b/docs/tasks.txt @@ -5,6 +5,7 @@ The following tasks are used: ------------------+------+-------------------------------- map_expander | 0% | Expands the city map if needed household_growth | 0% | Growths a single household + building_growth | 0% | Growths building ------------------+------+-------------------------------- - - - - - @@ -46,16 +47,63 @@ zone is given and several pre-conditions are met: 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 +5) There is an empty 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. +6) The demand for resitential is not below or zero. Below zero means that + people may give up their home (e.g. high taxes). Vacant appartments or + buildings are put on sale for the player (for a reduced price). + 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. +Simulating reproduction conditions is very complex as it depends on many +factors. Both poor and rich people (including "middle rich") are repducing +under same conditions for now. + +The task is also responsible for splitting large households (after the child +has become adult) into smaller as adult "children" move out. It may happen that +from the same "parents" adult "children" are moving into one household as +relationships are *NOT* simulated. So even incest is possible and not prevent +by the simulation as this is (again) a city growth simulation. + +- - - - - + +Task 'building_growth': +----------------------- + +The task is responsible for growing buildings up to maximum size which the +current "tech level" and density allows. For constructing a new building some +conditions must be met: + +1) A road/path way must be nearby (will be always given but checked anyway). + +2) A zone must have minimum size (2x1, as 1 square is needed for distance to + road). This should be pre-checked by the user's client. + +3) No other building is already constructed on the zone, only one building per + zone is possible. + +4) The building type depends on "tech level" and density setting of the zone. + +Expansion of an existing building depends on other conditions: + +1) The bulding has not reached maximum size, depending on "tech level" and land + value. E.g. rich people will likely build a villa on the zone while poor + people may only build a small simple house on it. + +2) Zone density must be high enough to allow more stores being added, this has + a maximum depending on "tech level" and land value, see above. + +3) Demand for resitential is high enough, if nothing is demanded, no new + buildings are constructed and households are funded or expanded. + +4) A household has 3 or more adult members and they wish to move out. + [EOF] -- 2.39.5