]> git.mxchange.org Git - shipsimu.git/blob - application/ship-simu/main/constructions/harbors/class_Harbor.php
e414118b714c4811de8f38a208469c5ad252a447
[shipsimu.git] / application / ship-simu / main / constructions / harbors / class_Harbor.php
1 <?php
2 /**
3  * A harbor class suitable for all kind of harbors
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
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
10  *
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.
15  *
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.
20  *
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/>.
23  */
24 class Harbor extends BaseConstruction {
25         // Namen des Hafens (z.B. Hamburger Hafen)
26         private $harborName = "Unbekannter Hafen";
27
28         // Schiffsliste aller gebauten Schiffe
29         private $constructedShips = null;
30
31         // Liegeplatz-Liste
32         private $berthList = null;
33
34         // List of all assigned shipyards
35         private $shipyardList = null;
36
37         // Constructor
38         protected function __construct () {
39                 // Call parent constructor
40                 parent::__construct(__CLASS__);
41
42                 // Debug message
43                 if (((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output("[Harbor:] Konstruktor erreicht.<br />\n");
44
45                 // Set description
46                 $this->setObjectDescription("Hafen");
47
48                 // Generate unique ID number
49                 $this->createUniqueID();
50
51                 // Clean up a little
52                 $this->removeSystemArray();
53                 $this->removePartInstance();
54         }
55
56         // Creates a harbor
57         public final static function createHarbor ($harborName) {
58                 // Hafen-Instanz holen
59                 $harborInstance = new Harbor();
60
61                 // Debug message
62                 if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $harborInstance->getDebugInstance()->output(sprintf("[Harbor:] Der Hafen <strong>%s</strong> wird konstruiert.<br />\n", $harborName));
63
64                 // Hafenname setzen
65                 $harborInstance->setHarborName($harborName);
66
67                 // Werftliste initialisieren
68                 $harborInstance->createshipyardList();
69
70                 // Debug-Meldung ausgeben
71                 if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $harborInstance->getDebugInstance()->output(sprintf("[Harbor:] Der Hafen <strong>%s</strong> ist jetzt fertig gebaut.<br />\n", $harborName));
72
73                 // Instanz zurueckliefern
74                 return $harborInstance;
75         }
76
77         // Werft-Liste generieren
78         public function createshipyardList () {
79                 if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[Harbor:] Werft-Liste wird f&uuml;r den Hafen <strong>%s</strong> erstellt.<br />\n",
80                         $this->getHarborName()
81                 ));
82                 $this->shipyardList = new FrameworkArrayObject();
83         }
84
85         // Setter fuer Hafennamen
86         public final function setHarborName ($harborName) {
87                 if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[Harbor:] Der Hafen heisst jetzt <strong>%s</strong>.<br />\n", $harborName));
88                 $this->harborName = (string) $harborName;
89         }
90
91         // Getter fuer Hafennamen
92         public final function getHarborName () {
93                 if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[Harbor:] Hafenname <strong>%s</strong> wurde angefordert.<br />\n", $this->harborName));
94                 return $this->harborName;
95         }
96
97         // Werft in den Hafen einbauen und Werft->Reederei zuweisen
98         public function addNewShipyardNotify ($shipyardName, ShippingCompany $companyInstance) {
99                 if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[Harbor:] Die Werft <strong>%s</strong> wird im Hafen <strong>%s</strong> gebaut.<br />\n",
100                         $shipyardName, $this->getHarborName()
101                 ));
102
103                 // Werft generieren und in die Werftliste aufnehmen
104                 $this->shipyardList->append(Shipyard::createShipyardNotify($this, $shipyardName, $companyInstance));
105         }
106
107         // Werft in den Hafen einbauen ohne Zuweisung einer Reederei (gehoert der "Stadt" dann)
108         public function addNewShipyard ($shipyardName) {
109                 if ((defined('DEBUG_HARBOR')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[Harbor:] Die Werft <strong>%s</strong> wird im Hafen <strong>%s</strong> gebaut.<br />\n",
110                         $shipyardName, $this->getHarborName()
111                 ));
112
113                 // Werft generieren und in die Werftliste aufnehmen
114                 $this->shipyardList->append(Shipyard::createShipyard($this, $shipyardName));
115         }
116
117         /**
118          * Stub!
119          */
120         public function saveObjectToDatabase () {
121                 $this->getDebugInstance()->output(sprintf("[%s:] Stub <strong>%s</strong> erreicht.",
122                         $this->__toString(),
123                         __FUNCTION__
124                 ));
125         }
126
127         /**
128          * Limits this object with an ObjectLimits instance
129          */
130         public function limitObject (ObjectLimits $limitInstance) {
131                 ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
132         }
133 }
134
135 // [EOF]
136 ?>