Continued a bit:
authorRoland Haeder <roland@mxchange.org>
Tue, 15 Nov 2016 19:10:17 +0000 (20:10 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 15 Nov 2016 19:10:17 +0000 (20:10 +0100)
- added class/interface for game options (like pause/unpause flag, et cetera)
- maybe also gaming difficulty will come, if computable?
- added missing database "tables"

Signed-off-by: Roland Haeder <roland@mxchange.org>
application/city/classes/database/frontend/game_options/.htaccess [new file with mode: 0644]
application/city/classes/database/frontend/game_options/class_CityGameOptionsDatabaseWrapper.php [new file with mode: 0644]
application/city/classes/manager/game/.htaccess [new file with mode: 0644]
application/city/classes/manager/game/class_GameManager.php [new file with mode: 0644]
application/city/interfaces/database/frontend/game_options/.htaccess [new file with mode: 0644]
application/city/interfaces/database/frontend/game_options/class_CityGameOptionsWrapper.php [new file with mode: 0644]
db/city_section/.htaccess [new file with mode: 0644]
db/game_options/.htaccess [new file with mode: 0644]

diff --git a/application/city/classes/database/frontend/game_options/.htaccess b/application/city/classes/database/frontend/game_options/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/city/classes/database/frontend/game_options/class_CityGameOptionsDatabaseWrapper.php b/application/city/classes/database/frontend/game_options/class_CityGameOptionsDatabaseWrapper.php
new file mode 100644 (file)
index 0000000..f0a42f8
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * A database wrapper for game options
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2015, 2016 City Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.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 <http://www.gnu.org/licenses/>.
+ */
+class CityGameOptionsDatabaseWrapper extends BaseDatabaseWrapper implements CityGameOptionsWrapper, Registerable {
+       // Constants for database table names
+       const DB_TABLE_GAME_OPTION_INFORMATION = 'game_options';
+
+       // Constants for database column names
+       const DB_COLUMN_GAME_OPTION_ID          = 'game_id';
+       const DB_COLUMN_GAME_OPTION_USER_ID     = 'game_user_id';
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this database wrapper by a provided user class
+        *
+        * @return      $wrapperInstance        An instance of the created wrapper class
+        */
+       public static final function createCityGameOptionsDatabaseWrapper () {
+               // Get a new instance
+               $wrapperInstance = new CityGameOptionsDatabaseWrapper();
+
+               // Set (primary!) table name
+               $wrapperInstance->setTableName(self::DB_TABLE_GAME_OPTION_INFORMATION);
+
+               // Return the instance
+               return $wrapperInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/city/classes/manager/game/.htaccess b/application/city/classes/manager/game/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/city/classes/manager/game/class_GameManager.php b/application/city/classes/manager/game/class_GameManager.php
new file mode 100644 (file)
index 0000000..7e109cd
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+/**
+ * A game manager
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2015, 2016 City 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 <http://www.gnu.org/licenses/>.
+ */
+class RegionManager extends BaseManager implements ManageableRegion {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $managerInstance        An instance of a ManageableRegion class
+        */
+       public final static function createRegionManager () {
+               // Get new instance
+               $managerInstance = new RegionManager();
+
+               // Get database wrapper
+               $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('region_info_db_wrapper_class');
+
+               // And set it here
+               $managerInstance->setWrapperInstance($wrapperInstance);
+
+               // Return the prepared instance
+               return $managerInstance;
+       }
+
+       /**
+        * Checks whether the current user has already founded a region
+        *
+        * @return      $isFounded      Whether the current user has already founded a region
+        */
+       public function ifUserHasCreatedRegion () {
+               // Check if the currently set user has already founded a region
+               $isFounded = $this->getWrapperInstance()->ifUserHasCreatedRegion();
+
+               // Return result
+               return $isFounded;
+       }
+
+       /**
+        * Checks whether the given region name is already taken
+        *
+        * @para        $regionName             Name of region
+        * @return      $isTaken                Whether the given region name is already taken
+        */
+       public function ifRegionNameExists ($regionName) {
+               // Check if the given region name is taken
+               $isTaken = $this->getWrapperInstance()->ifRegionExists($regionName);
+
+               // Return result
+               return $isTaken;
+       }
+
+       /**
+        * Founds the first region. A dummy region will also be created
+        *
+        * @return      $resultInstance         Found result after creating it
+        */
+       public function createFirstRegion () {
+               // Dummy name
+               // @TODO Move to language system
+               $regionName = 'Region 1';
+
+               // Some pre-checks
+               assert(!$this->ifUserHasCreatedRegion());
+               assert(!$this->ifRegionNameExists($regionName));
+
+               // First region can now be created
+               $this->getWrapperInstance()->createRegionByName($regionName);
+
+               // Then try to find it
+               assert($this->ifRegionNameExists($regionName));
+
+               // Get result instance
+               $resultInstance = $this->getResultInstance();
+
+               // And return it
+               return $resultInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/city/interfaces/database/frontend/game_options/.htaccess b/application/city/interfaces/database/frontend/game_options/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/city/interfaces/database/frontend/game_options/class_CityGameOptionsWrapper.php b/application/city/interfaces/database/frontend/game_options/class_CityGameOptionsWrapper.php
new file mode 100644 (file)
index 0000000..f02197b
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * An interface for game options (database) wrapper
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2015, 2016 City Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.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 <http://www.gnu.org/licenses/>.
+ */
+interface CityGameOptionsWrapper extends DatabaseWrapper {
+}
+
+// [EOF]
+?>
diff --git a/db/city_section/.htaccess b/db/city_section/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/db/game_options/.htaccess b/db/game_options/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all