class_Shipyard.php

Go to the documentation of this file.
00001 <?php
00025 class Shipyard extends BaseConstruction {
00026         // Werft-Name
00027         private $shipyardName    = "Namenlose Werft";
00028 
00029         // Arbeiter-Liste
00030         private $staffList = null;
00031 
00032         // Queue-Liste fuer zu bauende Schiffe
00033         private $queueList = null;
00034 
00035         // Aktuell im Bau befindliches Schiff
00036         private $currShipInConst = null;
00037 
00038         // Liste konstruierbarer Schiffstypen
00039         private $shipTypeList = null;
00040 
00041         // Zugewiesener Hafen
00042         private $harborInstance = null;
00043 
00044         // Zugewiesene Reederei
00045         private $shippingCompany = null;
00046 
00047         // Constructor
00048         protected function __construct () {
00049                 // Call parent constructor
00050                 parent::__construct(__CLASS__);
00051 
00052                 // Staff-Liste/Schiffstyp-Liste erzeugen
00053                 $this->createStaffList();
00054                 $this->createShipTypeList();
00055         }
00056 
00057         // Create a shipyard and notify it about it's owner
00058         public final static function createShipyardNotify (Harbor $harborInstance, $shipyardName, ShippingCompany $companyInstance) {
00059                 // Werft-Instanz holen
00060                 $shipyardInstance = self::createShipyard($harborInstance, $shipyardName);
00061 
00062                 // Reederei der Werft zuweisen
00063                 $shipyardInstance->setCompanyInstance($companyInstance);
00064 
00065                 // Die Reederei ueber ihre Werft informieren
00066                 $companyInstance->addNewShipyard($shipyardInstance);
00067 
00068                 // Instanz zurueckgeben
00069                 return $shipyardInstance;
00070         }
00071 
00072         // Create a shipyard, first we need to create a harbor
00073         public final static function createShipyard (Harbor $harborInstance, $shipyardName) {
00074                 // Instanz temporaer holen
00075                 $shipyardInstance = new Shipyard();
00076 
00077                 // Debug message
00078                 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.",
00079                         __CLASS__,
00080                         __LINE__,
00081                         $shipyardName,
00082                         $harborInstance->getHarborName()
00083                 ));
00084 
00085                 // Werft-Name setzen
00086                 $shipyardInstance->setShipyardName($shipyardName);
00087 
00088                 // Hafen-Instanz setzen
00089                 $shipyardInstance->setHarborInstance($harborInstance);
00090 
00091                 // Abmasse setzen in Meter
00092                 $shipyardInstance->setWidth(30);
00093                 $shipyardInstance->setHeight(30);
00094                 $shipyardInstance->setLength(100);
00095 
00096                 // Clean up a little
00097                 $shipyardInstance->removeDraught();
00098                 $shipyardInstance->removeSystemArray();
00099 
00100                 // Debug-Meldung
00101                 if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $shipyardInstance->debugOutput(sprintf("[%s:%d] Die Werft <strong>%s</strong> wurde gebaut.",
00102                         __CLASS__,
00103                         __LINE__,
00104                         $shipyardName
00105                 ));
00106 
00107                 // Instanz zurueckliefern
00108                 return $shipyardInstance;
00109         }
00110 
00111         // Create staff list
00112         private function createStaffList () {
00113                 $this->staffList = new FrameworkArrayObject("FakedStaffList");
00114         }
00115 
00116         // Create ship type list
00117         private function createShipTypeList () {
00118                 $this->shipTypeList = new FrameworkArrayObject("FakedShipTypeList");
00119         }
00120 
00121         // Setter-Methode fuer Werft-Name
00122         public final function setShipyardName ($shipyardName) {
00123                 $this->shipyardName = (string) $shipyardName;
00124         }
00125 
00126         // Getter-Methode fuer Werft-Name
00127         public final function getShipyardName () {
00128                 return $this->shipyardName;
00129         }
00130 
00131         // Setter-Methode fuer Hafen-Instanz
00132         public final function setHarborInstance (Harbor $harborInstance) {
00133                 $this->harborInstance = $harborInstance;
00134         }
00135 
00136         // Getter-Methode fuer Hafen-Instanz
00137         public final function getHarborInstance () {
00138                 return $this->harborInstance;
00139         }
00140 
00141         // Setter fuer Reederei-Instanz
00142         public final function setCompanyInstance (ShippingCompany $companyInstance) {
00143                 $this->shippingCompany = $companyInstance;
00144         }
00145 
00146         // Getter fuer Reederei-Instanz
00147         public final function getCompanyInstance () {
00148                 return $this->shippingCompany;
00149         }
00150 
00151         // Add new personell
00152         public function addNewPersonell ($personell) {
00153                 // Add to list
00154                 $this->staffList->append($personell);
00155         }
00156 
00157         // Add a new ship type to our list
00158         public function addNewConstructableShipType ($shipType) {
00159                 // This must be a string!
00160                 $shipType = (string) $shipType;
00161 
00162                 // Debug message
00163                 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.",
00164                         __CLASS__,
00165                         __LINE__,
00166                         $this->getShipyardName(),
00167                         $shipType
00168                 ));
00169 
00170                 // Add to list
00171                 $this->shipTypeList->append($shipType);
00172         }
00173 
00174         // Is the specified ship type in our list?
00175         public function isShipTypeConstructable ($shipType) {
00176                 // First we can't build this ship
00177                 $result = false;
00178 
00179                 // This must be a string!
00180                 $shipType = (string) $shipType;
00181 
00182                 // Debug message
00183                 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.",
00184                         __CLASS__,
00185                         __LINE__,
00186                         $this->getShipyardName(),
00187                         $shipType
00188                 ));
00189 
00190                 // Iterate through all types
00191                 for ($idx = $this->shipTypeList->getIterator(); $idx->valid(); $idx->next()) {
00192                         // Get current ship type
00193                         $type = (string) $idx->current();
00194 
00195                         // Is both the same?
00196                         $result = ($type == $shipType);
00197 
00198                         // Type is found?
00199                         if ($result) break; // Then abort the search!
00200                 }
00201 
00202                 // Debug message
00203                 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.",
00204                         __CLASS__,
00205                         __LINE__,
00206                         $this->getShipyardName(),
00207                         $shipType
00208                 ));
00209 
00210                 // Return result
00211                 return $result;
00212         }
00213 }
00214 
00215 // [EOF]
00216 ?>

Generated on Mon Dec 8 01:06:44 2008 for Ship-Simulator by  doxygen 1.5.6