Example #1
0
<?php

require_once '../../lib/inclusion.php';
require_once '../../config/units.cfg.php';
require_once_model('Player');
require_once_model('Unit');
require_once_model('Division');
require_once_model('DivisionMovement');
require_once_model('Sector');
session_start();
$divisionConn = new DivisionDAO();
$divisionMovementConn = new DivisionMovementDAO();
$player = $_SESSION['player'];
$unitList = explode(",", $_POST['unitList']);
$quantityList = explode(",", $_POST['quantityList']);
$startX = $_POST['startX'];
$startY = $_POST['startY'];
$endX = $_POST['endX'];
$endY = $_POST['endY'];
$speed = $_POST['speed'];
$startOK = false;
$endOK = false;
$divisionsOK = false;
$speedOK = false;
$playerSectors = array();
foreach ($player->getSectors() as $playerSector) {
    if ($playerSector->getCoordinateX() == $startX && $playerSector->getCoordinateY() == $startY) {
        $startOK = true;
        $startId = $playerSector->getId();
    }
}
require_once_model('DivisionMovement');
require_once_model('Player');
require_once_model('StaticData');
require_once '../../config/paths.php';
require_once '../../config/map.cfg.php';
session_start();
$staticData = $_SESSION['staticData'];
$allSectors = $staticData->getSectors();
$allUnits = $staticData->getUnits();
$allPlayers = $staticData->getPlayers();
$player = $_SESSION['player'];
$resources = $player->getResources();
$coordinateX = $_POST['coordinateX'];
$coordinateY = $_POST['coordinateY'];
$msg = "";
$divisionMovementConn = new DivisionMovementDAO();
$sector = $allSectors[$coordinateX . "," . $coordinateY];
$divisionMovementsArr = $divisionMovementConn->getDivisionMovement($sector->getId(), $sector->getId(), 0);
$divisionMovements = array();
foreach ($divisionMovementsArr as $divisionMovementArr) {
    unset($startSector);
    unset($endSector);
    //Get origin and destiny sectors of current DivisionMovement
    foreach ($allSectors as $targetSector) {
        if (!(isset($startSector) && isset($endSector))) {
            if ($divisionMovementArr[4] == $targetSector->getId()) {
                $startSector = $targetSector;
            } elseif ($divisionMovementArr[5] == $targetSector->getId()) {
                $endSector = $targetSector;
            }
        } else {