From ebb300d6c3273370bcd14575ac329e5f8ec2fd0c Mon Sep 17 00:00:00 2001 From: Gnieark Date: Sun, 3 Jul 2016 14:50:50 +0200 Subject: [PATCH] . --- src/arenas/tron/act.php | 28 +++++++++++++++++++++------- src/arenas/tron/functions.php | 4 +++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/arenas/tron/act.php b/src/arenas/tron/act.php index ce3dd4c..8c60e0b 100644 --- a/src/arenas/tron/act.php +++ b/src/arenas/tron/act.php @@ -38,7 +38,7 @@ switch ($_POST['act']){ } } - $players = $botCount; + $_SESSION['players'] = $botCount; if ($botCount < 2){ error (500,"missing bots"); } @@ -55,7 +55,7 @@ switch ($_POST['act']){ 'action' => 'init', 'game' => 'tron', 'board' => '', - 'players' => $players, + 'players' => $_SESSION['players'], 'player-index' => $botCount ); @@ -90,13 +90,27 @@ switch ($_POST['act']){ die; } $bots = unserialize($_SESSION['bots']); - + $board= array(); + //make the board array for ($botCount = 0; $botCount < count($bots); $botCount ++){ - $sendMessage = array( - 'game-id' => '' - ); + $board[$botCount] = $bots[$botCount]->getTail(); } - 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; diff --git a/src/arenas/tron/functions.php b/src/arenas/tron/functions.php index 267651c..f8e9bf4 100644 --- a/src/arenas/tron/functions.php +++ b/src/arenas/tron/functions.php @@ -6,7 +6,9 @@ class TronPlayer{ private $tail = array(); private $direction; private $state; - + public function getTail(){ + return $this->tail; + } public function getStatus(){ return $this->state; }