$sector->setBattle($battle); } $sectorBuildingsArr = $sectorConn->getSectorBuildings($sector->getId()); $sectorBuildings = array(); foreach ($sectorBuildingsArr as $sectorBuildingArr) { $buildingClass = $sectorBuildingArr[1]; $building = clone $allBuildings[$buildingClass]; $building->setLevel($sectorBuildingArr[3]); $building->setDateStarted($sectorBuildingArr[4]); $building->setDateStopped($sectorBuildingArr[5]); $sectorBuildings[$building->getId()] = $building; } $sector->setBuildings($sectorBuildings); $isCapitol = isset($sectorBuildings[0]) && $sectorBuildings[0]->getLevel(); if ($isCapitol) { $sector->setIsCapitol(true); if ($sector->getOwner() == $sessionPlayer->getId()) { $_SESSION['capitolSector'] = $sector; } } if ($sectorArr[5] == $sessionPlayer->getId()) { array_push($owned_sectors, $sector); } $allSectors[$sector->getCoordinateX() . "," . $sector->getCoordinateY()] = $sector; $x = $sector->getCoordinateX(); $y = $sector->getCoordinateY(); if ($x >= 0 && $x <= $MAP_WIDTH - 1 + $originX && $y >= 0 && $y <= $MAP_HEIGHT - 1 + $originY && $x >= $originX && $y >= $originY) { array_push($visibleSectors, $sector); } } $sessionPlayer->setSectors($owned_sectors);