starts dev connect four full json

This commit is contained in:
Gnieark 2016-06-17 19:17:09 +02:00
parent ca40bddae2
commit d48c81dce2
2 changed files with 6 additions and 5 deletions

View File

@ -19,7 +19,7 @@ function createElem(type,attributes)
{elem.setAttribute(i,attributes[i]);}
return elem;
}
function fight(xd_check){
function fight(xd_check,fullLogs,gameId){
var xhr = Ajx();
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) {
@ -46,11 +46,11 @@ function fight(xd_check){
}};
xhr.open("POST", '/Battleship', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send('act=fight&xd_check=' + xd_check);
xhr.send('act=fight&xd_check=' + xd_check + '&fullLogs=' + fullLogs);
}
function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShip4,nbShip5,nbShip6,xd_check){
function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShip4,nbShip5,nbShip6,xd_check,fullLogs){
var shipsArea= parseInt(nbShip1) + 2 * parseInt(nbShip2) + 3 * parseInt(nbShip3) + 4 * parseInt(nbShip4) + 5 * parseInt(nbShip5) + 6 * parseInt(nbShip6);
if(shipsArea > parseInt(gridWidth * gridHeight / 2) ){
@ -134,7 +134,7 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi
var p=createElem("p");
p.innerHTML='players placed theirs ships';
document.getElementById('logs').appendChild(p);
fight(xd_check);
fight(xd_check,fullLogs);
}
}};
@ -152,6 +152,7 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi
+ '&nbShip5=' + nbShip5
+ '&nbShip6=' + nbShip6
+ '&xd_check=' + xd_check
+ '&fullLogs=' + fullLogs
);
}

View File

@ -22,6 +22,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>
<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,document.getElementById(fullLogs).checked);"></p>
<div id="fightResult"></div>
</article>