|
|
|
@ -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
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|