This commit is contained in:
gnieark 2016-06-19 22:59:57 +02:00
parent 4c29f1a574
commit eeb7ab9713

View File

@ -137,7 +137,7 @@ switch ($_POST['act']){
;
if(!isset($anwserPlayerJson['responseArr']['boats'])){
@ -256,8 +256,10 @@ switch ($_POST['act']){
$botParamsToSend=array(
'game' => 'Battleship',
'match_id' => $_SESSION['matchId']."-".$currentPlayer,
'act' => 'fight',
'game-id' => $_SESSION['matchId']."-".$currentPlayer,
'action' => 'play-turn',
'player-index' => $currentPlayer - 1,
'board' => array(
'opponent' => $opponentName,
'width' => $_SESSION['width'],
'height' => $_SESSION['height'],
@ -267,17 +269,24 @@ switch ($_POST['act']){
'ship4' => $_SESSION['ship4'],
'ship5' => $_SESSION['ship5'],
'ship6' => $_SESSION['ship6'],
'your_strikes' => json_encode($_SESSION['strikes'][$currentPlayer]),
'his_strikes' => json_encode($_SESSION['strikes'][$opponent])
'your_strikes' => $_SESSION['strikes'][$currentPlayer],
'his_strikes' => $_SESSION['strikes'][$opponent]
);
$anwserPlayer=get_IA_Response($currentBot['url'],$botParamsToSend);
$anwserPlayerJson=get_IA_Response($currentBot['url'],$botParamsToSend);
if($fullLogs){
$fullLogs='Arena send to '.$currentBot['name'].'<em>'.htmlentities($anwserPlayerJson['messageSend']).'</em><br/>
HTTP status: <em>'.htmlentities($anwserPlayerJson['httpStatus']).'</em><br/>
Bot anwser: <em>'.htmlentities($anwserPlayerJson['response']).'</em><br/>';
}else{
$fullLogs="";
}
if(!preg_match('/^[0-9]+,[0-9]+$/',$anwserPlayer)){
if(!preg_match('/^[0-9]+,[0-9]+$/',$anwserPlayer['responseArr']['play'])){
echo json_encode(array(
'target' => '',
'log' => $currentBot['name']." a fait une réponse non conforme, il perd.".$anwserPlayer
));
'log' => $fullLogs.$currentBot['name']." a fait une réponse non conforme, il perd."));
save_battle('Battleship',$_SESSION['bot1']['name'],$_SESSION['bot2']['name'],$opponent);
die;
}