+++ /dev/null
-<?php
-/**
- * A general ship class for all other kinds of ships even small sail ships
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu 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 BaseShip extends BaseSimulator {
- // Name des Shipes
- private $shipName = "Unbekanntes Schiff";
-
- // Anzahl Anker
- private $numAnchor = 0;
-
- // Tiefgang in Meter
- private $draught = 0;
-
- // Besatzung-Objekte
- private $crewList = null;
-
- // Aufbauten-Objekte
- private $structures = null;
-
- // Namenloses Ship generieren
- protected function __construct($className) {
- // Call parent constructor
- parent::__construct($className);
-
- // Prepare array object for all structures
- $this->createStructuresArray();
-
- // Clean-up a little
- $this->removePartInstance();
- }
-
- // Array-Objekt anlegen
- private function createStructuresArray () {
- $this->structures = new FrameworkArrayObject("FakedShipStructures");
- }
-
- // Schiffsteil generieren (kann alles sein)
- // buildInstance = Das was in das Schiffsteil evtl. eingebaut werden soll (null = kein besonderes Teil einbauen!)
- // partClass = Das zu konstruierende Schiffsteil
- public function createShipPart (ConstructableShipPart $buildInstance, $partClass) {
- if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> erhält ein neues Schiffsteil (%s).",
- __CLASS__,
- __LINE__,
- $this->getShipName(),
- $partClass
- ));
-
- // Ist die gewuenschte Klasse vorhanden?
- if (!class_exists($partClass)) {
- // Nicht vorhanden, dann Ausnahme werfen!
- throw new NoClassException($partClass, self::EXCEPTION_CLASS_NOT_FOUND);
- } // END - if
-
- // Get an instance back from our object factory
- $partInstance = ObjectFactory::createObjectByName($partClass);
-
- // Das Einbauen versuchen...
- try {
- $partInstance->addShipPartToShip($this, $buildInstance);
- } catch (MotorShipMismatchException $e) {
- if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> hat keinen Motor erhalten! Grund: <strong>%s</strong>",
- __CLASS__,
- __LINE__,
- $this->getShipName(),
- $e->getMessage()
- ));
- return false;
- } catch (RoomShipMismatchException $e) {
- if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> hat keinen Maschinenraum erhalten! Grund: <strong>%s</strong>",
- __CLASS__,
- __LINE__,
- $this->getShipName(),
- $e->getMessage()
- ));
- return false;
-
- } catch (StructureShipMismatchException $e) {
- if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> hat keine Aufbauten erhalten! Grund: <strong>%s</strong>",
- __CLASS__,
- __LINE__,
- $this->getShipName(),
- $e->getMessage()
- ));
- return false;
- } catch (CabinShipMismatchException $e) {
- if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> hat keine Kabine erhalten! Grund: <strong>%s</strong>",
- __CLASS__,
- __LINE__,
- $this->getShipName(),
- $e->getMessage()
- ));
- return false;
- } catch (DeckShipMismatchException $e) {
- if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das Schiff <strong>%s</strong> hat kein Deck erhalten! Grund: <strong>%s</strong>",
- __CLASS__,
- __LINE__,
- $this->getShipName(),
- $e->getMessage()
- ));
- return false;
- }
-
- // Instanz im Aufbauten-Array vermerken
- $this->structures->append($partInstance);
-
- // Alles klar!
- return true;
- }
-
- // Getter-Methode fuer Strukturen-Array
- public final function getStructuresArray () {
- return $this->structures;
- }
-
- // STUB: Getter-Methode Anzahl Betten
- public function calcTotalBeds () {
- $this->partialStub("Please implement this stub in your ship!");
- }
-
- // Setter-Methode fuer Schiffsnamen
- public final function setShipName ($shipName) {
- $this->shipName = (string) $shipName;
- }
-
- // Getter-Methode fuer Schiffsnamen
- public final function getShipName () {
- return $this->shipName;
- }
-
- // Setter-Methode fuer Tiefgang
- public final function setDraught ($draught) {
- $this->draught = (int) $draught;
- }
-
- // Getter-Methode fuer Tiefgang
- public final function getDraught() {
- return $this->draught;
- }
-
- // Setter-Methode fuer Anzahl Anker
- public final function setNumAnchor ($numAnchor) {
- $this->numAnchor = (int) $numAnchor;
- }
-}
-
-// [EOF]
-?>