Debug mailer finished and debug messages removed:
[shipsimu.git] / application / ship-simu / main / constructions / yards / class_Shipyard.php
index 9d555dd18465c73aaad13892553e79b885129d1a..474821a237f8118d0dc8dce20e5f5e94bc3d9488 100644 (file)
@@ -1,15 +1,36 @@
 <?php
-
-// Die Werft-Klasse
+/**
+ * A shipyard construction class which can be used for constructing all kinds of
+ * ships.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @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 Shipyard extends BaseConstruction {
        // Werft-Name
        private $shipyardName    = "Namenlose Werft";
 
        // Arbeiter-Liste
-       private $staffList       = null;
+       private $staffList = null;
 
        // Queue-Liste fuer zu bauende Schiffe
-       private $queueList       = null;
+       private $queueList = null;
 
        // Aktuell im Bau befindliches Schiff
        private $currShipInConst = null;
@@ -24,31 +45,23 @@ class Shipyard extends BaseConstruction {
        private $shippingCompany = null;
 
        // Constructor
-       private function __construct () {
-               // Eltern-Konstruktor aufrufen
-               parent::constructor(__CLASS__);
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
 
-               // Debug message
-               if (((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
-                       $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
-                               __CLASS__,
-                               __LINE__
-                       ));
-               }
-
-               // Beschreibung setzen
-               $this->setPartDescr("Werft");
+               // Set description
+               $this->setObjectDescription("Werft");
 
                // Staff-Liste/Schiffstyp-Liste erzeugen
                $this->createStaffList();
                $this->createShipTypeList();
 
-               // Unique-ID erzeugen
-               $this->createUniqueID();
+               // Generate unique ID number
+               $this->generateUniqueId();
        }
 
        // Create a shipyard and notify it about it's owner
-       public static function createShipyardNotify (Harbor $harborInstance, $shipyardName, ShippingCompany $companyInstance) {
+       public final static function createShipyardNotify (Harbor $harborInstance, $shipyardName, ShippingCompany $companyInstance) {
                // Werft-Instanz holen
                $shipyardInstance = self::createShipyard($harborInstance, $shipyardName);
 
@@ -68,7 +81,7 @@ class Shipyard extends BaseConstruction {
                $shipyardInstance = new Shipyard();
 
                // Debug message
-               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $shipyardInstance->getDebugInstance()->output(sprintf("[%s:%d] Eine Werft mit dem Namen <strong>%s</strong> wird im Hafen <strong>%s</strong> konstruiert.<br />\n",
+               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $shipyardInstance->debugOutput(sprintf("[%s:%d] Eine Werft mit dem Namen <strong>%s</strong> wird im Hafen <strong>%s</strong> konstruiert.",
                        __CLASS__,
                        __LINE__,
                        $shipyardName,
@@ -86,12 +99,12 @@ class Shipyard extends BaseConstruction {
                $shipyardInstance->setHeight(30);
                $shipyardInstance->setLength(100);
 
-               // Etwas aufraeumen
+               // Clean up a little
                $shipyardInstance->removeDraught();
                $shipyardInstance->removeSystemArray();
 
                // Debug-Meldung
-               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $shipyardInstance->getDebugInstance()->output(sprintf("[%s:%d] Die Werft <strong>%s</strong> wurde gebaut.<br />\n",
+               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $shipyardInstance->debugOutput(sprintf("[%s:%d] Die Werft <strong>%s</strong> wurde gebaut.",
                        __CLASS__,
                        __LINE__,
                        $shipyardName
@@ -103,61 +116,46 @@ class Shipyard extends BaseConstruction {
 
        // Create staff list
        private function createStaffList () {
-               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Werft <strong>%s</strong> erh&auml;lt eine Arbeiterliste.<br />\n",
-                       __CLASS__,
-                       __LINE__,
-                       $this->getShipyardName()
-               ));
-               $this->staffList = new FrameworkArrayObject();
+               $this->staffList = new FrameworkArrayObject("FakedStaffList");
        }
 
        // Create ship type list
        private function createShipTypeList () {
-               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Werft <strong>%s</strong> erh&auml;lt eine Typenliste.<br />\n",
-                       __CLASS__,
-                       __LINE__,
-                       $this->getShipyardName()
-               ));
-               $this->shipTypeList = new FrameworkArrayObject();
+               $this->shipTypeList = new FrameworkArrayObject("FakedShipTypeList");
        }
 
        // Setter-Methode fuer Werft-Name
-       public function setShipyardName ($shipyardName) {
+       public final function setShipyardName ($shipyardName) {
                $this->shipyardName = (string) $shipyardName;
        }
 
        // Getter-Methode fuer Werft-Name
-       public function getShipyardName () {
+       public final function getShipyardName () {
                return $this->shipyardName;
        }
 
        // Setter-Methode fuer Hafen-Instanz
-       public function setHarborInstance (Harbor $harborInstance) {
+       public final function setHarborInstance (Harbor $harborInstance) {
                $this->harborInstance = $harborInstance;
        }
 
        // Getter-Methode fuer Hafen-Instanz
-       public function getHarborInstance () {
+       public final function getHarborInstance () {
                return $this->harborInstance;
        }
 
        // Setter fuer Reederei-Instanz
-       public function setCompanyInstance (ShippingCompany $companyInstance) {
+       public final function setCompanyInstance (ShippingCompany $companyInstance) {
                $this->shippingCompany = $companyInstance;
        }
 
        // Getter fuer Reederei-Instanz
-       public function getCompanyInstance () {
+       public final function getCompanyInstance () {
                return $this->shippingCompany;
        }
 
        // Add new personell
        public function addNewPersonell ($personell) {
-               if (is_null($this->staffList)) {
-                       // Opps, not initialized!
-                       ApplicationEntryPoint::app_die("New personell: <pre>".print_r($this, true)."</pre>");
-               }
-
                // Add to list
                $this->staffList->append($personell);
        }
@@ -168,7 +166,7 @@ class Shipyard extends BaseConstruction {
                $shipType = (string) $shipType;
 
                // Debug message
-               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Werft <strong>%s</strong> kann bald Schiffe vom Typ <strong>%s</strong> bauen.<br />\n",
+               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Werft <strong>%s</strong> kann bald Schiffe vom Typ <strong>%s</strong> bauen.",
                        __CLASS__,
                        __LINE__,
                        $this->getShipyardName(),
@@ -188,7 +186,7 @@ class Shipyard extends BaseConstruction {
                $shipType = (string) $shipType;
 
                // Debug message
-               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Werft <strong>%s</strong> pr&uuml;ft, ob Schiffe vom Typ <strong>%s</strong> baubar sind.<br />\n",
+               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Werft <strong>%s</strong> pr&uuml;ft, ob Schiffe vom Typ <strong>%s</strong> baubar sind.",
                        __CLASS__,
                        __LINE__,
                        $this->getShipyardName(),
@@ -208,7 +206,7 @@ class Shipyard extends BaseConstruction {
                }
 
                // Debug message
-               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Die Werft <strong>%s</strong> hat die Suche nach dem Schiffstyp <strong>%s</strong> abgeschlossen.<br />\n",
+               if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Werft <strong>%s</strong> hat die Suche nach dem Schiffstyp <strong>%s</strong> abgeschlossen.",
                        __CLASS__,
                        __LINE__,
                        $this->getShipyardName(),
@@ -218,23 +216,6 @@ class Shipyard extends BaseConstruction {
                // Return result
                return $result;
        }
-
-       /**
-        * Stub!
-        */
-       public function saveObjectToDatabase () {
-               $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
-                       $this->__toString(),
-                       __FUNCTION__
-               ));
-       }
-
-       /**
-        * Limits this object with an ObjectLimits instance
-        */
-       public function limitObject (ObjectLimits $limitInstance) {
-               ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
-       }
 }
 
 // [EOF]