more infos if non conform awnser
This commit is contained in:
parent
27b04754fd
commit
72df4b4bd1
|
|
@ -61,6 +61,12 @@ switch ($_POST['act']){
|
||||||
'player-index' => $player
|
'player-index' => $player
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
'messageSend' => $data_string,
|
||||||
|
'httpStatus' => $curl_getinfo($ch)['http_code'],
|
||||||
|
'response' => $output,
|
||||||
|
'responseArr' => $arr
|
||||||
|
*/
|
||||||
get_IA_Response($_SESSION['bot1']['url'],$params[0]); //don't care about result
|
get_IA_Response($_SESSION['bot1']['url'],$params[0]); //don't care about result
|
||||||
get_IA_Response($_SESSION['bot2']['url'],$params[1]); //don't care about result
|
get_IA_Response($_SESSION['bot2']['url'],$params[1]); //don't care about result
|
||||||
|
|
||||||
|
|
@ -118,9 +124,14 @@ switch ($_POST['act']){
|
||||||
'board' => $_SESSION['map'],
|
'board' => $_SESSION['map'],
|
||||||
'player-index' => $_SESSION['currentPlayer'] - 1
|
'player-index' => $_SESSION['currentPlayer'] - 1
|
||||||
);
|
);
|
||||||
|
|
||||||
//send query
|
//send query
|
||||||
$tempPlayer = get_IA_Response($botUrl,$postDatas);
|
$tempPlayer = get_IA_Response($botUrl,$postDatas);
|
||||||
$anwserPlayer = $tempPlayer['play'];
|
if(isset($tempPlayer['arrponseArr']['play'])){
|
||||||
|
$anwserPlayer = $tempPlayer['arrponseArr']['play'];
|
||||||
|
}else{
|
||||||
|
$anwserPlayer = -1;
|
||||||
|
}
|
||||||
|
|
||||||
//vérifier la validité de la réponse
|
//vérifier la validité de la réponse
|
||||||
if((isset($_SESSION['map'][5][$anwserPlayer])) && ($_SESSION['map'][5][$anwserPlayer] == "")){
|
if((isset($_SESSION['map'][5][$anwserPlayer])) && ($_SESSION['map'][5][$anwserPlayer] == "")){
|
||||||
|
|
@ -273,34 +284,38 @@ switch ($_POST['act']){
|
||||||
|
|
||||||
save_battle('connectFou',$_SESSION['bot1']['name'],$_SESSION['bot2']['name'],0);
|
save_battle('connectFou',$_SESSION['bot1']['name'],$_SESSION['bot2']['name'],0);
|
||||||
$anwserToJS=array(
|
$anwserToJS=array(
|
||||||
'continue' => 0,
|
'continue' => 0,
|
||||||
'strikeX' => $strikeX,
|
'strikeX' => $strikeX,
|
||||||
'strikeY' => $strikeY,
|
'strikeY' => $strikeY,
|
||||||
'strikeSymbol'=> $you,
|
'strikeSymbol'=> $you,
|
||||||
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer." match nul",
|
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer." match nul",
|
||||||
'gameId' => $_SESSION['matchId']
|
'gameId' => $_SESSION['matchId']
|
||||||
);
|
);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$anwserToJS=array(
|
$anwserToJS=array(
|
||||||
'continue' => 1,
|
'continue' => 1,
|
||||||
'strikeX' => $strikeX,
|
'strikeX' => $strikeX,
|
||||||
'strikeY' => $strikeY,
|
'strikeY' => $strikeY,
|
||||||
'strikeSymbol'=> $you,
|
'strikeSymbol'=> $you,
|
||||||
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer,
|
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer,
|
||||||
'gameId' => $_SESSION['matchId']
|
'gameId' => $_SESSION['matchId']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
//reponse non conforme
|
//reponse non conforme
|
||||||
|
|
||||||
$anwserToJS=array(
|
$anwserToJS=array(
|
||||||
'continue' =>0,
|
'continue' =>0,
|
||||||
'strikeX' => -1,
|
'strikeX' => -1,
|
||||||
'strikeY' => -1,
|
'strikeY' => -1,
|
||||||
'log' => $you." ".$currentBotName." a fait une réponse non conforme, il perd".json_encode($tempPlayer),
|
'log' => $you." ".$currentBotName." made a non conform anwser: <br/>
|
||||||
|
Bots Arena sent:".$tempPlayer['messageSend']."<br/>
|
||||||
|
".$currentBotName." HTTP STATUS: ".$tempPlayer['httpStatus']."<br/>
|
||||||
|
His response: ".html_entities($tempPlayer['response']),
|
||||||
'gameId' => $_SESSION['matchId']
|
'gameId' => $_SESSION['matchId']
|
||||||
);
|
);
|
||||||
if($_SESSION['currentPlayer']==1){
|
if($_SESSION['currentPlayer']==1){
|
||||||
|
|
|
||||||
|
|
@ -332,8 +332,9 @@ function does_arena_exist($string,$arenasArr){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_IA_Response($iaUrl,$postParams,$verbose=false){
|
function get_IA_Response($iaUrl,$postParams){
|
||||||
//send params JSON as body
|
// send params JSON as body
|
||||||
|
// return query detail on an array
|
||||||
|
|
||||||
$data_string = json_encode($postParams);
|
$data_string = json_encode($postParams);
|
||||||
|
|
||||||
|
|
@ -347,23 +348,17 @@ function get_IA_Response($iaUrl,$postParams,$verbose=false){
|
||||||
'Content-Type: application/json',
|
'Content-Type: application/json',
|
||||||
'Content-Length: ' . strlen($data_string))
|
'Content-Length: ' . strlen($data_string))
|
||||||
);
|
);
|
||||||
|
//$httpCode = curl_getinfo($ch)['http_code'];
|
||||||
if ($output= curl_exec($ch)){
|
$output= curl_exec($ch);
|
||||||
$queryOk = true;
|
|
||||||
|
|
||||||
|
|
||||||
}else{
|
|
||||||
$queryOk = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
//echo $iaUrl." ".$data_string." ".$output.'<br/>';
|
if(! $arr = json_decode($output,TRUE)){
|
||||||
|
$arr=array();
|
||||||
if($verbose){
|
|
||||||
|
|
||||||
}else{
|
|
||||||
return json_decode($output,TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'messageSend' => $data_string,
|
||||||
|
'httpStatus' => $curl_getinfo($ch)['http_code'],
|
||||||
|
'response' => $output,
|
||||||
|
'responseArr' => $arr
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user