3 * A harbor class suitable for all kind of harbors
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class Harbor extends BaseConstruction {
25 // Namen des Hafens (z.B. Hamburger Hafen)
26 private $harborName = "Unbekannter Hafen";
28 // Schiffsliste aller gebauten Schiffe
29 private $constructedShips = null;
32 private $berthList = null;
34 // List of all assigned shipyards
35 private $shipyardList = null;
38 protected function __construct () {
39 // Call parent constructor
40 parent::__construct(__CLASS__);
43 $this->setObjectDescription("Hafen");
45 // Generate unique ID number
46 $this->generateUniqueId();
49 $this->removeSystemArray();
50 $this->removePartInstance();
54 public final static function createHarbor ($harborName) {
55 // Hafen-Instanz holen
56 $harborInstance = new Harbor();
59 if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $harborInstance->getDebugInstance()->output(sprintf("[Harbor:] Der Hafen <strong>%s</strong> wird konstruiert.", $harborName));
62 $harborInstance->setHarborName($harborName);
64 // Werftliste initialisieren
65 $harborInstance->createshipyardList();
67 // Debug-Meldung ausgeben
68 if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $harborInstance->getDebugInstance()->output(sprintf("[Harbor:] Der Hafen <strong>%s</strong> ist jetzt fertig gebaut.", $harborName));
70 // Instanz zurueckliefern
71 return $harborInstance;
74 // Werft-Liste generieren
75 public function createshipyardList () {
76 $this->shipyardList = new FrameworkArrayObject("FakedShipyardList");
79 // Setter fuer Hafennamen
80 public final function setHarborName ($harborName) {
81 $this->harborName = (string) $harborName;
84 // Getter fuer Hafennamen
85 public final function getHarborName () {
86 return $this->harborName;
89 // Werft in den Hafen einbauen und Werft->Reederei zuweisen
90 public function addNewShipyardNotify ($shipyardName, ShippingCompany $companyInstance) {
91 // Werft generieren und in die Werftliste aufnehmen
92 $this->shipyardList->append(Shipyard::createShipyardNotify($this, $shipyardName, $companyInstance));
95 // Werft in den Hafen einbauen ohne Zuweisung einer Reederei (gehoert der "Stadt" dann)
96 public function addNewShipyard ($shipyardName) {
97 // Werft generieren und in die Werftliste aufnehmen
98 $this->shipyardList->append(Shipyard::createShipyard($this, $shipyardName));