This commit is contained in:
Gnieark 2016-07-03 14:50:50 +02:00
parent 2338d8bd7e
commit ebb300d6c3
2 changed files with 24 additions and 8 deletions

View File

@ -38,7 +38,7 @@ switch ($_POST['act']){
} }
} }
$players = $botCount; $_SESSION['players'] = $botCount;
if ($botCount < 2){ if ($botCount < 2){
error (500,"missing bots"); error (500,"missing bots");
} }
@ -55,7 +55,7 @@ switch ($_POST['act']){
'action' => 'init', 'action' => 'init',
'game' => 'tron', 'game' => 'tron',
'board' => '', 'board' => '',
'players' => $players, 'players' => $_SESSION['players'],
'player-index' => $botCount 'player-index' => $botCount
); );
@ -90,13 +90,27 @@ switch ($_POST['act']){
die; die;
} }
$bots = unserialize($_SESSION['bots']); $bots = unserialize($_SESSION['bots']);
$board= array();
//make the board array
for ($botCount = 0; $botCount < count($bots); $botCount ++){ for ($botCount = 0; $botCount < count($bots); $botCount ++){
$sendMessage = array( $board[$botCount] = $bots[$botCount]->getTail();
'game-id' => ''
);
} }
print_r($_SESSION);
$responses = array();
for ($botCount = 0; $botCount < count($bots); $botCount ++){
$messageArr = array(
'game-id' => '',
'action' => 'play-turn',
'game' => 'tron',
'board' => $board,
'player-index' => $botCount, // To do: verifier que ça restera le même à chaque tour
'players' => $_SESSION['players']
);
$responses[$botCount] = get_IA_Response($bots[$botCount]->getURL(),$messageArr);
}
print_r($responses);
die; die;

View File

@ -6,7 +6,9 @@ class TronPlayer{
private $tail = array(); private $tail = array();
private $direction; private $direction;
private $state; private $state;
public function getTail(){
return $this->tail;
}
public function getStatus(){ public function getStatus(){
return $this->state; return $this->state;
} }