dodo
This commit is contained in:
parent
73f5dd4e37
commit
2892d62519
|
@ -51,6 +51,16 @@ switch ($_POST['act']){
|
||||||
}
|
}
|
||||||
$postValues[$p[0]]=$value;
|
$postValues[$p[0]]=$value;
|
||||||
}
|
}
|
||||||
|
if(($_POST['fullLogs'] <> 'true') && ($_POST['fullLogs'] <> 'false')){
|
||||||
|
error(500, 'wrong POST parameters');
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
if($_POST['fullLogs'] == 'true'){
|
||||||
|
$fullLogs = true;
|
||||||
|
}else{
|
||||||
|
$fullLogs = false;
|
||||||
|
}
|
||||||
|
|
||||||
//check if bots exists
|
//check if bots exists
|
||||||
$bot1Exists = false;
|
$bot1Exists = false;
|
||||||
$bot2Exists = false;
|
$bot2Exists = false;
|
||||||
|
@ -74,11 +84,15 @@ switch ($_POST['act']){
|
||||||
error (500,"missing parameter 2");
|
error (500,"missing parameter 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_it_possible_to_place_ships_on_grid($postValues['gridWidth'],$postValues['gridHeight'],$postValues['nbShip1'],$postValues['nbShip2'],$postValues['nbShip3'],$postValues['nbShip4'],$postValues['nbShip5'],$postValues['nbShip6'])){
|
|
||||||
|
if(!is_it_possible_to_place_ships_on_grid($postValues['gridWidth'],$postValues['gridHeight'],
|
||||||
|
$postValues['nbShip1'],$postValues['nbShip2'],$postValues['nbShip3'],
|
||||||
|
$postValues['nbShip4'],$postValues['nbShip5'],$postValues['nbShip6']))
|
||||||
|
{
|
||||||
error (404,"grid is too little for these ships");
|
error (404,"grid is too little for these ships");
|
||||||
}
|
}
|
||||||
|
|
||||||
//vars checked, lets init the initGame
|
//******vars checked, lets init the initGame *******
|
||||||
|
|
||||||
$_SESSION['matchId']=get_unique_id();
|
$_SESSION['matchId']=get_unique_id();
|
||||||
|
|
||||||
|
@ -94,9 +108,12 @@ switch ($_POST['act']){
|
||||||
}
|
}
|
||||||
|
|
||||||
$botParamsToSend=array(
|
$botParamsToSend=array(
|
||||||
'game' => 'Battleship',
|
'game-id' => $_SESSION['matchId'],
|
||||||
'match_id' => $_SESSION['matchId']."-1",
|
'game' => 'battleship',
|
||||||
'act' => 'init',
|
'action' => 'init',
|
||||||
|
'players' => 2
|
||||||
|
'player-index' => $player -1,
|
||||||
|
'board' => array(
|
||||||
'opponent' => $opponentName,
|
'opponent' => $opponentName,
|
||||||
'width' => $postValues['gridWidth'],
|
'width' => $postValues['gridWidth'],
|
||||||
'height' => $postValues['gridHeight'],
|
'height' => $postValues['gridHeight'],
|
||||||
|
@ -106,9 +123,20 @@ switch ($_POST['act']){
|
||||||
'ship4' => $postValues['nbShip4'],
|
'ship4' => $postValues['nbShip4'],
|
||||||
'ship5' => $postValues['nbShip5'],
|
'ship5' => $postValues['nbShip5'],
|
||||||
'ship6' => $postValues['nbShip6']
|
'ship6' => $postValues['nbShip6']
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$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="";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$boatsPlayer = json_decode( html_entity_decode($anwserPlayer));
|
$boatsPlayer = json_decode( html_entity_decode($anwserPlayer));
|
||||||
if(!$boatsPlayer){
|
if(!$boatsPlayer){
|
||||||
echo $currentBot['name']." a fait une réponse non conforme, il perd.".$anwserPlayer;
|
echo $currentBot['name']." a fait une réponse non conforme, il perd.".$anwserPlayer;
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<li><em>players</em> Int indicating the number of players in the game, still 2 on connect Four.</li>
|
<li><em>players</em> Int indicating the number of players in the game, still 2 on connect Four.</li>
|
||||||
<li><em>board</em> The map, i'll explain it at next chapter</li>
|
<li><em>board</em> The map, i'll explain it at next chapter</li>
|
||||||
<li><em>you</em> String, Your bot's character on the grid</li>
|
<li><em>you</em> String, Your bot's character on the grid</li>
|
||||||
<li><em>player-index</em> Int The order of your bot in turns. The first player is 0, second is 2.</li>
|
<li><em>player-index</em> Int The order of your bot in turns. The first player is 0, second is 1.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h4>The map</h4>
|
<h4>The map</h4>
|
||||||
<p> It is represented by a sub-array, on the "board" parameter.<br/>Exemple:</p>
|
<p> It is represented by a sub-array, on the "board" parameter.<br/>Exemple:</p>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user