--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>