} echo "^_^" . $percent . "^_^" . $auxUnits . "^_^" . $auxTimes . "^_^" . implode(",", $availableUnits) . "^_^" . implode(",", $speeds) . "^_^"; $queuedNumbers = array(); foreach ($player->getAvailableUnits() as $unit) { $queuedNumbers[$unit->getId()] = 0; } if ($unitQueueListArr) { foreach ($queuedUnits as $queuedUnit) { $queuedNumbers[$queuedUnit]++; } } $divisionsArr = $divisionConn->getOwnDivisionsBySector($coordinateX, $coordinateY); $divisions = array(); foreach ($divisionsArr as $divisionArr) { $division = new Division($divisionArr[0], $divisionArr[1], $divisionArr[3], $divisionArr[4]); $divisions[$division->getUnitId()] = $division; } $player->setVisibleSectors(Sector::indexByCoordinate($player->getVisibleSectors())); $reachableSectors = array(); $startX = $sector->getCoordinateX(); $startY = $sector->getCoordinateY(); Sector::getReachables($player->getVisibleSectors(), $sector->getCoordinateX(), $sector->getCoordinateY(), 0); $reachableSectors = Sector::sortByCoordinate($reachableSectors); $player->setReachableSectors($reachableSectors); $distances = array(); foreach ($player->getReachableSectors() as $reachableSector) { $distances[] = $reachableSector->getDistance(); } echo implode(",", $distances) . "^_^"; $detailType = 'units'; require "../../views/detailBox/unitsDetailsView.php";
static function getReachables($sectors, $x, $y, $distance) { global $reachableSectors; global $player; global $startX, $startY; if (array_key_exists($x . "," . $y, $sectors)) { $sector = $sectors[$x . "," . $y]; $isHQ = false; $sectorBuildings = $sector->getBuildings(); $sectorBattle = $sector->getBattle(); if (isset($sectorBattle)) { $attackerId = $sectorBattle->getAttackerId(); $denfenderId = $sectorBattle->getDefenderId(); } if (isset($sectorBuildings[1])) { $HQ = $sectorBuildings[1]; if ($HQ->getLevel() >= 1) { $isHQ = true; } } if ($sector != null && $sector->getIsLand() && (!$sector->getIsBattle() || $player->getId() == $attackerId || $player->getId() == $denfenderId)) { if (!array_key_exists($x . "," . $y, $reachableSectors) || $sector->getDistance() > $distance) { $sector->setDistance($distance); if (!($x == $startX && $y == $startY)) { $reachableSectors[$x . "," . $y] = $sector; } if ($sector->getOwner() == $player->getId() && $isHQ) { if ($x % 2 == 0) { $next = array($x . "," . ($y - 1), $x + 1 . "," . ($y - 1), $x + 1 . "," . $y, $x . "," . ($y + 1), $x - 1 . "," . $y, $x - 1 . "," . ($y - 1)); } else { $next = array($x . "," . ($y - 1), $x + 1 . "," . $y, $x + 1 . "," . ($y + 1), $x . "," . ($y + 1), $x - 1 . "," . ($y + 1), $x - 1 . "," . $y); } foreach ($next as $nxt) { $nxt = explode(",", $nxt); $y = $nxt[1]; $x = $nxt[0]; Sector::getReachables($sectors, $x, $y, $distance + 1); } } } } } }