commit
a7cc960be1
|
@ -1 +1 @@
|
|||
Subproject commit c2bde34e58caa500b8fb2f7e14fc9765596cdf6d
|
||||
Subproject commit 7c8b786228bb9e1561ff60a2d6f7f6ce91be6fee
|
|
@ -1,4 +1,15 @@
|
|||
<?php
|
||||
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||
#
|
||||
# This file is part of botsArena.
|
||||
#
|
||||
# Copyright (C) Gnieark https://blog-du-grouik.tinad.fr et contributeurs
|
||||
# Licensed under the GPL version 3.0 license.
|
||||
# See LICENSE file or
|
||||
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||
#
|
||||
# -- END LICENSE BLOCK -----------------------------------------
|
||||
|
||||
require_once(__DIR__."/functions.php");
|
||||
$bots=get_Bots_Array('Battleship');
|
||||
|
||||
|
|
|
@ -1,4 +1,15 @@
|
|||
<?php
|
||||
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||
#
|
||||
# This file is part of botsArena.
|
||||
#
|
||||
# Copyright (C) Gnieark https://blog-du-grouik.tinad.fr et contributeurs
|
||||
# Licensed under the GPL version 3.0 license.
|
||||
# See LICENSE file or
|
||||
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||
#
|
||||
# -- END LICENSE BLOCK -----------------------------------------
|
||||
|
||||
function is_it_possible_to_place_ships_on_grid($gridWidth,$gridHeight,$nbShipsSize1,$nbShipsSize2,$nbShipsSize3,$nbShipsSize4,$nbShipsSize5,$nbShipsSize6){
|
||||
//return false or true
|
||||
//not a perfect solution
|
||||
|
|
|
@ -132,7 +132,15 @@ switch ($_POST['act']){
|
|||
}else{
|
||||
$anwserPlayer = -1;
|
||||
}
|
||||
|
||||
|
||||
if($_POST['fullLogs'] == "true"){
|
||||
$fullLogs='Arena send to '.$currentBotName.'<em>'.htmlentities($tempPlayer['messageSend']).'</em><br/>
|
||||
HTTP status: <em>'.htmlentities($tempPlayer['httpStatus']).'</em><br/>
|
||||
Bot anwser: <em>'.htmlentities($tempPlayer['response']).'</em><br/>';
|
||||
|
||||
}else{
|
||||
$fullLogs='';
|
||||
}
|
||||
//vérifier la validité de la réponse
|
||||
if((isset($_SESSION['map'][5][$anwserPlayer])) && ($_SESSION['map'][5][$anwserPlayer] == "")){
|
||||
//reponse conforme
|
||||
|
@ -258,7 +266,7 @@ switch ($_POST['act']){
|
|||
'strikeX' => $strikeX,
|
||||
'strikeY' => $strikeY,
|
||||
'strikeSymbol'=> $you,
|
||||
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer." et a gagné",
|
||||
'log' => $fullLogs.$you." ".$currentBotName." joue colonne ". $anwserPlayer." et a gagné",
|
||||
'cellsWin' => json_encode($cellsWin),
|
||||
'gameId' => $_SESSION['matchId']
|
||||
);
|
||||
|
@ -288,7 +296,7 @@ switch ($_POST['act']){
|
|||
'strikeX' => $strikeX,
|
||||
'strikeY' => $strikeY,
|
||||
'strikeSymbol'=> $you,
|
||||
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer." match nul",
|
||||
'log' => $fullLogs.$you." ".$currentBotName." joue colonne ". $anwserPlayer." match nul",
|
||||
'gameId' => $_SESSION['matchId']
|
||||
);
|
||||
|
||||
|
@ -299,7 +307,7 @@ switch ($_POST['act']){
|
|||
'strikeX' => $strikeX,
|
||||
'strikeY' => $strikeY,
|
||||
'strikeSymbol'=> $you,
|
||||
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer,
|
||||
'log' => $fullLogs.$you." ".$currentBotName." joue colonne ". $anwserPlayer,
|
||||
'gameId' => $_SESSION['matchId']
|
||||
);
|
||||
}
|
||||
|
@ -312,10 +320,7 @@ switch ($_POST['act']){
|
|||
'continue' =>0,
|
||||
'strikeX' => -1,
|
||||
'strikeY' => -1,
|
||||
'log' => $you." ".$currentBotName." made a non conform anwser: <br/>
|
||||
Bots Arena sent:<em>".$tempPlayer['messageSend']."</em><br/>
|
||||
".$currentBotName." HTTP STATUS:<em> ".$tempPlayer['httpStatus']."</em><br/>
|
||||
His response: <em>".htmlentities($tempPlayer['response'])."</em>",
|
||||
'log' => $fullLogs.$you." ".$currentBotName." made a non conform anwser.",
|
||||
'gameId' => $_SESSION['matchId']
|
||||
);
|
||||
if($_SESSION['currentPlayer']==1){
|
||||
|
|
|
@ -13,9 +13,12 @@ function Ajx(){
|
|||
return request;
|
||||
}
|
||||
function addLog(message){
|
||||
var divLogs = document.getElementById("logs");
|
||||
var p=createElem('p',{});
|
||||
p.innerHTML=message;
|
||||
document.getElementById('logs').appendChild(p);
|
||||
divLogs.appendChild(p);
|
||||
divLogs.scrollTop = divLogs.scrollHeight;
|
||||
|
||||
}
|
||||
function createElem(type,attributes){
|
||||
var elem=document.createElement(type);
|
||||
|
@ -57,9 +60,6 @@ function connectFour(bot1,bot2,xd_check, gameId, newGame){
|
|||
var xhr = Ajx();
|
||||
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
|
||||
if(xhr.status == 200) {
|
||||
//for test
|
||||
// alert(xhr.responseText);
|
||||
|
||||
try{
|
||||
var reponse = JSON.parse(xhr.responseText);
|
||||
}catch(e){
|
||||
|
@ -85,7 +85,6 @@ function connectFour(bot1,bot2,xd_check, gameId, newGame){
|
|||
|
||||
}
|
||||
|
||||
|
||||
//if game isn't finished, continue
|
||||
if(reponse['continue'] == 1){
|
||||
connectFour(bot1,bot2,xd_check,reponse['gameId'], false);
|
||||
|
@ -108,5 +107,5 @@ function connectFour(bot1,bot2,xd_check, gameId, newGame){
|
|||
}else{
|
||||
var act='fight';
|
||||
}
|
||||
xhr.send('act=' + act + '&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check + '&gameId=' + gameId);
|
||||
xhr.send('act=' + act + '&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check + '&gameId=' + gameId + '&fullLogs=' + document.getElementById("fullLogs").checked);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
require_once(__DIR__."/functions.php");
|
||||
|
||||
$bots=get_Bots_Array('connectFou');
|
||||
|
||||
?>
|
||||
<article>
|
||||
<h2><?php echo $lang['MAKE_DUEL'];?></h2>
|
||||
|
@ -23,5 +21,6 @@ $bots=get_Bots_Array('connectFou');
|
|||
?>
|
||||
</select>
|
||||
</p>
|
||||
<p><input type="checkbox" id="fullLogs"/><label for="fullLogs">view the full logs</label></p>
|
||||
<p><input id="fightButton" type="button" value="<?php echo $lang['FIGHT']; ?>" onclick="connectFour(document.getElementById('bot1').value,document.getElementById('bot2').value,'<?php echo xd_check_input(2); ?>',0);"></p>
|
||||
<div id="fightResult"></div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user