diff --git a/src/arenas/Battleship/act.php b/src/arenas/Battleship/act.php index 0a69db6..c18a81f 100644 --- a/src/arenas/Battleship/act.php +++ b/src/arenas/Battleship/act.php @@ -60,6 +60,29 @@ switch ($_POST['act']){ //vars checked, lets init the initGame $_SESSION['matchId']=get_unique_id(); + + + + // get_IA_Response($iaUrl,$postParams) + //array à envoyer au bot 1 + + $bot1ParamsToSend=array( + 'game' => 'Battleship', + 'act' => 'init', + 'match_id' => $_SESSION['matchId']."-1", + 'opponent' => $bot2['name'], + 'width' => $postValues['gridWidth'], + 'height' => $postValues['height'], + 'ship1' => $postValues['ship1'], + 'ship2' => $postValues['ship2'] + 'ship3' => $postValues['ship3'] + 'ship4' => $postValues['ship4'] + 'ship5' => $postValues['ship5'] + 'ship6' => $postValues['ship6'] + + ); + + $anwserPlayer1 = get_IA_Response($bot1['url'],$bot1ParamsToSend); break; diff --git a/src/arenas/Battleship/functions.php b/src/arenas/Battleship/functions.php index f57cd56..e570ee1 100644 --- a/src/arenas/Battleship/functions.php +++ b/src/arenas/Battleship/functions.php @@ -41,4 +41,15 @@ function generate_numeric_select($start,$end,$selected,$name,$id){ } return $out.""; +} + +function get_IA_Response($iaUrl,$postParams){ + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $iaUrl); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $postParams); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $output = curl_exec($ch); + curl_close($ch); + return htmlentities($output); } \ No newline at end of file