/** FLEET BUILD FUNCTIONS **/ function BuildShipyard() { global $resource, $reslist, $SHIPYARD; $ActualCount = $this->GetHangerQueueInfo(); $Try = 1; do { if ($ActualCount >= self::BOTS_MAX_ELEMENTS_SHIPYARD || $Try >= self::BOTS_MAX_TRY_SHIPYARD) { break; } $Try++; $List = $this->getMultiplyRandomList(array(self::CHANCE_SHIPYARD_FLEET_BASIC, self::CHANCE_SHIPYARD_FLEET_ATTACK, self::CHANCE_SHIPYARD_DEF_BASIC, self::CHANCE_SHIPYARD_DEF_SHIELD), array(self::$FleetBasicIDs, self::$FleetAttackIDs, self::$DefBasicIDs, self::$DefShieldIDs)); $Element = $this->getRandomList($List); if (!$this->getChance($List[$Element]) || !BuildFunctions::IsTechnologieAccessible($this->USER, $this->PLANET, $Element)) { continue; } $MaxElements = $this->GetMaxConstructibleElements($this->USER, $this->PLANET, $Element); $Mode = $this->randomNum(0, 20); $Count = 1; if ($Mode === 20) { $Count = $this->randomNum(0, 10); } elseif ($Mode >= 18) { $Count = $this->randomNum(10, 20); } elseif ($Mode >= 16) { $Count = $this->randomNum(20, 30); } elseif ($Mode >= 13) { $Count = $this->randomNum(30, 40); } elseif ($Mode >= 9) { $Count = $this->randomNum(40, 60); } elseif ($Mode >= 6) { $Count = $this->randomNum(60, 70); } elseif ($Mode >= 4) { $Count = $this->randomNum(70, 80); } elseif ($Mode >= 2) { $Count = $this->randomNum(80, 90); } elseif ($Mode >= 1) { $Count = $this->randomNum(90, 100); } $MaxFactor = array(); $MaxFactor[] = round(3600 / BuildFunctions::GetBuildingTime($this->USER, $this->PLANET, $Element)); $MaxFactor[] = $MaxElements * $Count; $this->HangarBuild($Element, min($MaxFactor)); $ActualCount++; } while ($this->getChance(self::CHANCE_SHIPYARD_NEXT)); }