Пример #1
0
require '../../config/map.cfg.php';
require_once_model('StaticData');
require_once_model('Sector');
require_once_model('Building');
require_once_model('Technology');
require_once_model('Battle');
require_once_model('Player');
require_once_model('Message');
require_once_model('Resource');
session_start();
$staticData = $_SESSION['staticData'];
$allPlayers = $staticData->getPlayers();
$allBuildings = $staticData->getBuildings();
$sessionPlayer = $_SESSION['player'];
$playerConn = new PlayerDAO();
$sectorConn = new SectorDAO();
$newMessages = false;
$messagesArr = $playerConn->getMessages($sessionPlayer->getId(), true, 0);
if (count($messagesArr)) {
    $newMessages = true;
}
if ($_POST['height'] != 'undefined' && $_POST['width'] != 'undefined') {
    $height = $_POST['height'];
    $width = $_POST['width'];
} else {
    $lastMapViewArr = $playerConn->getLastMapView($sessionPlayer->getId());
    $coordinates = explode(",", $lastMapViewArr[0]);
    $originX = $coordinates[0];
    $originY = $coordinates[1];
    $height = $lastMapViewArr[1];
    $width = $height * 2;
Пример #2
0
<?php

if (defined("MODEL_ROUTE")) {
    require_once_model('Sector', MODEL_ROUTE);
} else {
    require_once_model('Sector');
}
$sectorConn = new SectorDAO();
$dimensions = $sectorConn->getMapDimensions();
//js limits on zoom. width=2*height
$MIN_WIDTH = 4;
$MAX_WIDTH = $dimensions[0] + 1;
$MIN_HEIGHT = 2;
$MAX_HEIGHT = $dimensions[1] + 1;
// --- Define some constants (initial zoom level)
$MAP_WIDTH = 10;
$MAP_HEIGHT = 5;
$HEX_HEIGHT = 80;
// --- Use this to scale the hexes smaller or larger than the actual graphics
$HEX_SCALED_HEIGHT = $HEX_HEIGHT * 1.0;
$HEX_SIDE = $HEX_SCALED_HEIGHT / 2;
require_once_model('Sector');
require_once_model('Building');
require_once_model('Player');
session_start();
$player = $_SESSION['player'];
$staticData = $_SESSION['staticData'];
$allSectors = $staticData->getSectors();
$allBuildings = $staticData->getBuildings();
$resources = $staticData->getResources();
if (isset($_SESSION['capitolSector'])) {
    $capitolSector = $_SESSION['capitolSector'];
}
$coordinateX = $_POST['coordinateX'];
$coordinateY = $_POST['coordinateY'];
$sector = $allSectors[$coordinateX . "," . $coordinateY];
$sectorConn = new SectorDAO();
//NEW SYSTEM STARTPOINT
/*$buildings = $staticData->getBuildings();
foreach ($sector->getBuildings() as $building)
        $buildings[$building->getId()] = $building;

$activeBuildingId = -1;
$activeBuildingTime = 0;
$percentList = array();*/
//NEW SYSTEM END
$availableBuildingsArr = $sectorConn->getAvailableBuildings($sector->getId());
$buildings = array();
$startTime = 0;
$now = $_SERVER['REQUEST_TIME'];
$percentList = array();
$activeBuildingId = -1;
Пример #4
0
<?php

require_once '../../lib/inclusion.php';
require_once '../../config/paths.php';
require_once '../../config/map.cfg.php';
require_once '../../config/buildings.cfg.php';
require_once_model('Resource');
require_once_model('Sector');
require_once_model('Building');
require_once_model('Battle');
require_once_model('Unit');
require_once_model('Division');
require_once_model('Player');
require_once_model('StaticData');
session_start();
$sectorConn = new SectorDAO();
$divisionConn = new DivisionDAO();
$staticData = $_SESSION['staticData'];
$player = $_SESSION['player'];
$resources = $staticData->getResources();
$coordinateX = $_POST['coordinateX'];
$coordinateY = $_POST['coordinateY'];
$allSectors = $staticData->getSectors();
$sector = $allSectors[$coordinateX . "," . $coordinateY];
$sectorBuildings = $sector->getBuildings();
$haveHeadquarters = isset($sectorBuildings[COMMAND_CENTER_ID]) && $sectorBuildings[COMMAND_CENTER_ID]->getLevel() >= 1;
$haveBarracks = isset($sectorBuildings[BARRACKS_ID]) && $sectorBuildings[BARRACKS_ID]->getLevel() >= 1;
$unitQueueListArr = $sectorConn->getUnitQueueLists($coordinateX, $coordinateY, $player->getId());
$auxUnits = $unitQueueListArr[0];
$auxTimes = $unitQueueListArr[1];
$queuedUnits = explode(",", $auxUnits);
Пример #5
0
<?php

require_once '../../lib/inclusion.php';
require_once '../../config/units.cfg.php';
require_once_model('Player');
require_once_model('Unit');
require_once_model('Sector');
session_start();
$sectorConn = new SectorDAO();
$playerConn = new PlayerDAO();
$player = $_SESSION['player'];
$action = $_POST['action'];
$unitId = $_POST['unitId'];
$coordinateX = $_POST['coordinateX'];
$coordinateY = $_POST['coordinateY'];
$quantity = $_POST['quantity'];
$playerSectors = array();
foreach ($player->getSectors() as $playerSector) {
    $sectorC = $playerSector->getCoordinateX() . "," . $playerSector->getCoordinateY();
    $playerSectors[] = $sectorC;
}
$sectorOK = in_array($coordinateX . "," . $coordinateY, $playerSectors);
$unitOK = array_key_exists($unitId, $player->getAvailableUnits());
$resourcesOK = true;
$available_units = $player->getAvailableUnits();
$unit_resources = $available_units[$unitId]->getProductionCost();
$player_resources = $player->getResources();
$leftResources = array();
for ($i = 0; $i < count($unit_resources); $i++) {
    $leftResources[$i] = $player_resources[$i] - $unit_resources[$i] * $quantity;
    if ($leftResources[$i] < 0 && $unit_resources[$i] > 0) {
Пример #6
0
require_once_model('Building', $MPATH, $absolute_path);
require_once_model('Unit', $MPATH, $absolute_path);
require_once_model('Division', $MPATH, $absolute_path);
require_once_model('DivisionMovement', $MPATH, $absolute_path);
require_once_model('Technology', $MPATH, $absolute_path);
require_once_model('Player', $MPATH, $absolute_path);
require_once_model('Battle', $MPATH, $absolute_path);
require_once_model('BattleRound', $MPATH, $absolute_path);
require_once_model('Message', $MPATH, $absolute_path);
require_once_model('Resource', $MPATH, $absolute_path);
require_once_model('Term', $MPATH, $absolute_path);
require_once_model('StaticData', $MPATH, $absolute_path);
require_once_model('Batch', $MPATH, $absolute_path);
require_once_model('ProductionMod', $MPATH, $absolute_path);
require_once_model('BattleMod', $MPATH, $absolute_path);
$sectorConn = new SectorDAO();
$buildingConn = new BuildingDAO();
$unitConn = new UnitDAO();
$divisionConn = new DivisionDAO();
$divisionMovementConn = new DivisionMovementDAO();
$technologyConn = new TechnologyDAO();
$playerConn = new PlayerDAO();
$battleConn = new BattleDAO();
$battleRoundConn = new BattleRoundDAO();
$messageConn = new MessageDAO();
$resourceConn = new ResourceDAO();
$termConn = new TermDAO();
$batchConn = new BatchDAO();
/*Battle
 * Building
 * DivisionMovement
Пример #7
0
<?php

require_once '../../lib/inclusion.php';
require_once '../../config/paths.php';
require_once '../../config/sector.cfg.php';
require_once_model('Sector');
//session_start();
if (!isset($sectorConn)) {
    $sectorConn = new SectorDAO();
}
$mapDimensionsArr = $sectorConn->getMapDimensions();
if ($mapDimensionsArr[0] && $mapDimensionsArr[1]) {
    $startX = $mapDimensionsArr[0] + 1;
    $startY = $mapDimensionsArr[1] + 1;
} else {
    $startX = 0;
    $startY = 0;
}
$inc_x = $MAP_INCREMENTX;
$inc_y = $MAP_INCREMENTY;
for ($i = 0; $i < $startY + $inc_y; $i++) {
    for ($j = $startX; $j < $startX + $inc_x; $j++) {
        Sector::insertRandomSector($j, $i);
    }
}
for ($i = $startY; $i < $startY + $inc_y; $i++) {
    for ($j = 0; $j < $startX; $j++) {
        Sector::insertRandomSector($j, $i);
    }
}
Пример #8
0
<?php

require_once '../../lib/inclusion.php';
require_once '../../config/paths.php';
require '../../config/map.cfg.php';
require_once_model('Sector');
require_once_model('Building');
if (!isset($sectorConn)) {
    $sectorConn = new SectorDAO();
}
if (!isset($buildingConn)) {
    $buildingConn = new BuildingDAO();
}
$sectorsArr = $sectorConn->getAllSectors();
foreach ($sectorsArr as $sectorArr) {
    $sector = new Sector($sectorArr[0], $sectorArr[1], $sectorArr[2], $sectorArr[3], $sectorArr[4], $sectorArr[5], $sectorArr[6], $sectorArr[7], explode(",", $sectorArr[8]), explode(",", $sectorArr[9]), $sectorArr[10]);
    $allSectors[] = $sector;
}
$allSectors = Sector::indexByCoordinate($allSectors);
$suitableSectors = array();
$origins = array();
$minDistance = 3;
$suitableSectors = array_diff_key($allSectors, Sector::getForbidden($allSectors));
if (count($suitableSectors) > 0) {
    $sector = $suitableSectors[array_rand($suitableSectors)];
    $rs = $sectorConn->updateSector($sector->getId(), $playerId, $playerId, 0);
    $startCoordinates = $sector->getCoordinateX() . "," . $sector->getCoordinateY();
    //Create Command center and capitol in initial sector
    $now = $_SERVER['REQUEST_TIME'];
    $sectorConn->insertBuilding(0, $sector->getId(), 0);
    $buildingConn->updateBuilding(1, 0, $sector->getId());
Пример #9
0
<?php

require_once '../../lib/inclusion.php';
require_once_model('Player');
require_once_model('Building');
require_once_model('Sector');
session_start();
$sectorConn = new SectorDAO();
$buildingConn = new BuildingDAO();
$playerConn = new PlayerDAO();
$player = $_SESSION['player'];
$action = $_POST['action'];
$buildingId = $_POST['buildingId'];
$sectorId = $_POST['sectorId'];
$pausing = $_POST['pausing'];
$playerSectors = array();
foreach ($player->getSectors() as $playerSector) {
    $sector_id = $playerSector->getId();
    $playerSectors[] = $sector_id;
    if ($sector_id == $sectorId) {
        $coordinateX = $playerSector->getCoordinateX();
        $coordinateY = $playerSector->getCoordinateY();
    }
}
$sectorOK = in_array($sectorId, $playerSectors);
$buildingOK = array_key_exists($buildingId, $player->getAvailableBuildings());
if ($pausing && $sectorOK && $buildingOK) {
    $success = $buildingConn->pauseBuilding($sectorId, $buildingId);
    //if ($success)
    echo "1;" . $coordinateX . ";" . $coordinateY;
    die;