Ejemplo n.º 1
0
 private function RenderRows()
 {
     $galaxy = $this->_coords->Galaxy();
     $system = $this->_coords->System();
     $query = "SELECT * FROM colony WHERE galaxy_position = {$galaxy} AND system_position = {$system};";
     $results = Database::Instance()->ExecuteQuery($query, "SELECT");
     // Fill up the rows array with actual colonies
     $rows = array();
     if (isset($results['ID'])) {
         // Single result
         $rows[$results['planet_position']] = $this->RenderRowOfColony(Colony::FromDatabaseByID($results['ID']));
     } elseif ($results != NULL) {
         // Not null, not single --> list of arrays
         foreach ($results as $row) {
             $rows[$row['planet_position']] = $this->RenderRowOfColony(Colony::FromDatabaseByID($row['ID']));
         }
     }
     // Fill up the gaps with empty rows
     global $NN_config;
     for ($i = 1; $i <= $NN_config['max_planets']; $i++) {
         if (!isset($rows[$i])) {
             $rows[$i] = $this->RenderEmptyRow($i);
         }
     }
     // Concatenate everything together
     $text = "";
     for ($i = 1; $i <= $NN_config['max_planets']; $i++) {
         $text .= $rows[$i];
     }
     return $text;
 }
Ejemplo n.º 2
0
 public static function FromDatabase(array $row, Colony $colony = NULL)
 {
     // Slice off fleetID, colonyID, mission type and cargo data
     $shipList = array_slice($row, 6);
     if ($colony === NULL) {
         $colony = Colony::FromDatabaseByID($row['colonyID'], User::GetCurrentUser());
     }
     $members = CombatUnit::MakeListFrom($shipList);
     $missiontype = $row['mission_type'];
     $id = $row['fleetID'];
     $cargo = new Cost($row['metal_in_cargo'], $row['crystal_in_cargo'], $row['deuterium_in_cargo'], 0);
     return new ShipFleet($members, $colony, $missiontype, $cargo, $id);
 }
Ejemplo n.º 3
0
 public static function FromDatabase(array $row, Colony $colony = NULL)
 {
     $transport = new Transportation();
     $fleet = ShipFleet::FromDatabaseByID($row['fleetID']);
     $transport->Fleet($fleet);
     $transport->ID($row['transportID']);
     if ($colony === NULL) {
         $colony = Colony::FromDatabaseByID($row['colonyID'], User::GetCurrentUser());
     }
     $transport->ReceivingColony($colony);
     $transport->ScheduledTime($row['scheduled_time']);
     $transport->IsValid(true);
     // Anything that gets into the database is valid.
     return $transport;
 }
Ejemplo n.º 4
0
 public function ThinkForColony($colonyID)
 {
     $colony = Colony::FromDatabaseByID($colonyID);
     $this->ConstructUnitsOf($colony);
 }