diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index 4ffd58d..a8c1578 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -12,8 +12,38 @@ function Ajx(){ } return request; } -function battleship(bot1,bot2,xd_check){ - document.getElementById('fightResult').innerHTML = '

Please wait...

'; +function createElem(type,attributes) +{ + var elem=document.createElement(type); + for (var i in attributes) + {elem.setAttribute(i,attributes[i]);} + return elem; +} + +function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShip4,nbShip5,nbShip6,xd_check){ + + document.getElementById('fightResult').innerHTML = ''; + //dessiner les deux grilles + tableAdv=createElem("table",{"id":"tblAdv","className":"battleshipGrid"); + tableMe=createElem("table",{"id":"tblAdv","className":"battleshipGrid"); + + for (i=0; i < gridHeight ; i++){ + trAdv=createElem("tr"); + trMe=createElem("tr"); + for (j=0; j < gridwidth ; i++){ + tdAdv=createElem("td",{"id":"adv" + i +"-" + j,"className": "empty"); + tdMe=createElem("td",{"id":"me" + i +"-" + j,"className": "empty"); + trAdv.appendChild(tdAdv); + trMe.appendChild(tdMe); + } + tableAdv.appendChild(trAdv); + tableMe.appendChild(trMe); + } + document.getElementById('fightResult').appendChild(tableAdv); + document.getElementById('fightResult').appendChild(tableMe); + + /* + var xhr = Ajx(); xhr.onreadystatechange = function(){if(xhr.readyState == 4){ if(xhr.status == 200) { @@ -23,4 +53,5 @@ function battleship(bot1,bot2,xd_check){ xhr.open("POST", '/Battleship', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send('act=fight&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check); + */ } \ No newline at end of file diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index 1f40f56..3978916 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -48,6 +48,7 @@ if(!$postParams){ ?>

-

+ +

\ No newline at end of file diff --git a/src/arenas/Battleship/style.css b/src/arenas/Battleship/style.css index 3484071..b80d1cf 100644 --- a/src/arenas/Battleship/style.css +++ b/src/arenas/Battleship/style.css @@ -1,3 +1,3 @@ article p {width: 100%;} -article p label {float:left; text-align:right; width:70%} +article p label {float:left; text-align:right; width:60%} article p select {} \ No newline at end of file