public static function FromIDResource(IDResource $resource, $position, $oldPosition, $scheduledTime, $level, BuildGroup $bg = NULL)
 {
     return new BuildingBuildItem($resource->Name(), $resource->Cost(), $resource->NextCostModifier(), $resource->Prerequisite(), $resource->Amount(), $resource->ID(), $position, $oldPosition, $scheduledTime, $level, $bg);
 }
예제 #2
0
 public static function FromList(array $list, Colony $colony)
 {
     return BuildingGroup::FromResourceGroup(IDResource::CreateListFrom($list), $colony);
 }
예제 #3
0
 private function ParseIDResource($item)
 {
     $id = $item["database_id"];
     $unitname = $item["name"];
     $this->_itemIDs[$id] = $unitname;
     return IDResource::FromResource(self::ParseResource($item), $id);
 }
예제 #4
0
 public function __toString()
 {
     return parent::__toString();
 }
예제 #5
0
 public function BuildCost(IDResource $itemObject, $buildLevel)
 {
     return $itemObject->BuildCost($this->BuildGroup()->Colony(), $buildLevel);
 }
예제 #6
0
 public static function FromList(array $list, Colony $colony)
 {
     $resourceGroup = new ResourceGroup(IDResource::MakeListFrom($list));
     return CombatGroup::FromResourceGroup($resourceGroup, $colony);
 }
예제 #7
0
 private function RenderRow(IDResource $building)
 {
     $vars['id'] = $building->ID();
     $vars['image'] = $building->Image("..", $this->_user->Skin());
     $vars['building_name'] = $this->_text[$building->Name()];
     $vars['description'] = $this->_text[$building->Name() . "_description"];
     // Calculate build cost
     // TODO: probably wrong, correct this
     $highestLevel = $this->_queue->BuildList()->GetHighestLevelForItem($building->Name());
     $buildCost = $building->BuildCost($this->_user->CurrentColony(), $highestLevel + 1);
     $cost = "";
     if ($building->Cost()->Metal() > 0) {
         $cost .= $this->_text['metal'] . ": " . $buildCost->Metal();
     }
     if ($building->Cost()->Crystal() > 0) {
         $cost .= " " . $this->_text['crystal'] . ": " . $buildCost->Crystal();
     }
     if ($building->Cost()->Deuterium() > 0) {
         $cost .= " " . $this->_text['deut'] . ": " . $buildCost->Deuterium();
     }
     if ($building->Cost()->Energy() > 0) {
         $cost .= " " . $this->_text['energy'] . ": " . $buildCost->Energy();
     }
     $vars['cost'] = $cost;
     // Calculate build time
     $time = Helper::ConvertToString($building->BuildTime($this->_user->CurrentColony(), $buildCost), $this->_user->Language());
     $vars['time'] = $this->_text['build_time'] . ": " . $time;
     // Determine build button text and behaviour
     if ($building->Name() === "research_lab") {
         // See if we're allowed to upgrade
         //global $NN_config;
         // TODO: implement research
         //$id = $this->_user->ID();
         //$query = "SELECT researchID FROM research WHERE userID = $id LIMIT 1;";
         //$result = Database::Instance()->ExecuteQuery( $query, "SELECT" );
         //if( isset( $result['researchID'] ) && $NN_config['research_lab_upgrade_during_research'] === false )
         //{
         //    $vars['build_button'] = $this->_text['research_lab_researching'];
         //    return Page::StaticRender( "buildings/building_row", $vars, $this->_user->AuthorisationLevelName() );
         //}
     }
     $fieldsLeft = $this->_user->CurrentColony()->FieldsRemaining() > 0;
     if (!$fieldsLeft) {
         // Is there enough space left?
         $vars['build_button'] = $this->_text['no_fields_available'];
     } else {
         $nextBuildLevel = $building->Amount() + 1;
         if ($fieldsLeft) {
             if ($this->_queue->BuildList()->Count() == 0) {
                 if ($nextBuildLevel == 1) {
                     if ($building->CanBePaidFor($this->_user->CurrentColony(), $nextBuildLevel)) {
                         $coloredText = $this->ColorText($this->_text['build_first_level'], "green");
                         $vars['build_button'] = $this->MakeBuildButton($building, $coloredText);
                     } else {
                         $vars['build_button'] = $this->ColorText($this->_text['build_first_level'], "red");
                     }
                 } else {
                     $text = $this->_text['build_next_level'] . " " . $nextBuildLevel;
                     if ($building->CanBePaidFor($this->_user->CurrentColony(), $nextBuildLevel)) {
                         $coloredText = $this->ColorText($text, "green");
                         $vars['build_button'] = $this->MakeBuildButton($building, $coloredText);
                     } else {
                         $vars['build_button'] = $this->ColorText($text, "red");
                     }
                 }
             } else {
                 $coloredText = $this->ColorText($this->_text['put_in_build_queue'], "green");
                 $vars['build_button'] = $this->MakeBuildButton($building, $coloredText);
             }
         } else {
             if ($nextBuildLevel == 1) {
                 $vars['build_button'] = $this->ColorText($this->_text['build_first_level'], "red");
             } else {
                 $text = $this->_text['build_next_level'] . " " . $nextBuildLevel;
                 $vars['build_button'] = $this->ColorText($text, "red");
             }
         }
     }
     return Page::StaticRender("buildings/building_row", $vars, $this->_user->AuthorisationLevelName());
 }
예제 #8
0
 public static function FromIDResource(IDResource $r, $type)
 {
     return new ProductionUnit($r->Name(), $r->Cost(), $r->NextCostModifier(), $r->Prerequisite(), $r->Amount(), $r->ID(), $type);
 }