class_Shipyard.php
Go to the documentation of this file.00001 <?php
00025 class Shipyard extends BaseConstruction {
00026
00027 private $shipyardName = "Namenlose Werft";
00028
00029
00030 private $staffList = null;
00031
00032
00033 private $queueList = null;
00034
00035
00036 private $currShipInConst = null;
00037
00038
00039 private $shipTypeList = null;
00040
00041
00042 private $harborInstance = null;
00043
00044
00045 private $shippingCompany = null;
00046
00047
00048 protected function __construct () {
00049
00050 parent::__construct(__CLASS__);
00051
00052
00053 $this->createStaffList();
00054 $this->createShipTypeList();
00055 }
00056
00057
00058 public final static function createShipyardNotify (Harbor $harborInstance, $shipyardName, ShippingCompany $companyInstance) {
00059
00060 $shipyardInstance = self::createShipyard($harborInstance, $shipyardName);
00061
00062
00063 $shipyardInstance->setCompanyInstance($companyInstance);
00064
00065
00066 $companyInstance->addNewShipyard($shipyardInstance);
00067
00068
00069 return $shipyardInstance;
00070 }
00071
00072
00073 public final static function createShipyard (Harbor $harborInstance, $shipyardName) {
00074
00075 $shipyardInstance = new Shipyard();
00076
00077
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
00086 $shipyardInstance->setShipyardName($shipyardName);
00087
00088
00089 $shipyardInstance->setHarborInstance($harborInstance);
00090
00091
00092 $shipyardInstance->setWidth(30);
00093 $shipyardInstance->setHeight(30);
00094 $shipyardInstance->setLength(100);
00095
00096
00097 $shipyardInstance->removeDraught();
00098 $shipyardInstance->removeSystemArray();
00099
00100
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
00108 return $shipyardInstance;
00109 }
00110
00111
00112 private function createStaffList () {
00113 $this->staffList = new FrameworkArrayObject("FakedStaffList");
00114 }
00115
00116
00117 private function createShipTypeList () {
00118 $this->shipTypeList = new FrameworkArrayObject("FakedShipTypeList");
00119 }
00120
00121
00122 public final function setShipyardName ($shipyardName) {
00123 $this->shipyardName = (string) $shipyardName;
00124 }
00125
00126
00127 public final function getShipyardName () {
00128 return $this->shipyardName;
00129 }
00130
00131
00132 public final function setHarborInstance (Harbor $harborInstance) {
00133 $this->harborInstance = $harborInstance;
00134 }
00135
00136
00137 public final function getHarborInstance () {
00138 return $this->harborInstance;
00139 }
00140
00141
00142 public final function setCompanyInstance (ShippingCompany $companyInstance) {
00143 $this->shippingCompany = $companyInstance;
00144 }
00145
00146
00147 public final function getCompanyInstance () {
00148 return $this->shippingCompany;
00149 }
00150
00151
00152 public function addNewPersonell ($personell) {
00153
00154 $this->staffList->append($personell);
00155 }
00156
00157
00158 public function addNewConstructableShipType ($shipType) {
00159
00160 $shipType = (string) $shipType;
00161
00162
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
00171 $this->shipTypeList->append($shipType);
00172 }
00173
00174
00175 public function isShipTypeConstructable ($shipType) {
00176
00177 $result = false;
00178
00179
00180 $shipType = (string) $shipType;
00181
00182
00183 if ((defined('DEBUG_SHIPYARD')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Werft <strong>%s</strong> prüft, ob Schiffe vom Typ <strong>%s</strong> baubar sind.",
00184 __CLASS__,
00185 __LINE__,
00186 $this->getShipyardName(),
00187 $shipType
00188 ));
00189
00190
00191 for ($idx = $this->shipTypeList->getIterator(); $idx->valid(); $idx->next()) {
00192
00193 $type = (string) $idx->current();
00194
00195
00196 $result = ($type == $shipType);
00197
00198
00199 if ($result) break;
00200 }
00201
00202
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
00211 return $result;
00212 }
00213 }
00214
00215
00216 ?>