From 99f18fe8436a3de148ac29900e03c350710cd65d Mon Sep 17 00:00:00 2001 From: Gnieark Date: Thu, 10 Dec 2015 20:39:32 +0100 Subject: [PATCH 01/41] when css fails edit html too --- html/style.css | 11 ++--------- src/arenas/tictactoe/public.php | 4 ++-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/html/style.css b/html/style.css index 9fb8c07..11847d3 100644 --- a/html/style.css +++ b/html/style.css @@ -1,18 +1,12 @@ -html { - height: 100%; -} body{ width:100%; font-size:100%; - top: 0px; line-height:140%; word-wrap:break-word; text-rendering:optimizelegibility; margin:0 auto; font-family : "lucida grande", "gill sans", arial, sans-serif; left:auto; -top:auto; - min-height:100%; } header{ background-color:#A60800; @@ -27,7 +21,7 @@ header h1{ width: 45%; margin-left: 5%;} - header nav{ +header nav{ display: block; width: 45%; color:#FFF; @@ -82,7 +76,6 @@ footer a { section{ margin: 0 auto; width: 90%; - padding-bottom: 40px; } article{ float: right; @@ -91,7 +84,7 @@ article{ aside{ float:left; width: 28%; - border-right: + border-right: 1px dashed green; } form textarea, form input, form select {width:40%;} diff --git a/src/arenas/tictactoe/public.php b/src/arenas/tictactoe/public.php index 106542c..8ed983d 100644 --- a/src/arenas/tictactoe/public.php +++ b/src/arenas/tictactoe/public.php @@ -41,5 +41,5 @@ if(!$postParams){

- -
\ No newline at end of file +
+ From 2c033e19cdf5bf349fab7907767f866416ff2502 Mon Sep 17 00:00:00 2001 From: gnieark Date: Thu, 10 Dec 2015 20:50:19 +0100 Subject: [PATCH 02/41] start battle ship arena dev --- src/arenas/Battleship/js.js | 26 ++++++++++++++++++ src/arenas/Battleship/public.php | 46 +++++++++++++++++++++++++++++++- src/arenas/tictactoe/doc-fr.html | 2 +- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/arenas/Battleship/js.js diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js new file mode 100644 index 0000000..4ffd58d --- /dev/null +++ b/src/arenas/Battleship/js.js @@ -0,0 +1,26 @@ +function Ajx(){ + var request = false; + try {request = new ActiveXObject('Msxml2.XMLHTTP');} + catch (err2) { + try {request = new ActiveXObject('Microsoft.XMLHTTP');} + catch (err3) { + try { request = new XMLHttpRequest();} + catch (err1) { + request = false; + } + } + } + return request; +} +function battleship(bot1,bot2,xd_check){ + document.getElementById('fightResult').innerHTML = '

Please wait...

'; + var xhr = Ajx(); + xhr.onreadystatechange = function(){if(xhr.readyState == 4){ + if(xhr.status == 200) { + document.getElementById('fightResult').innerHTML = xhr.responseText; + } + }}; + 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 61aa218..a5a20c0 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -1 +1,45 @@ -

Battle ship

\ No newline at end of file + +
+

+

+ +  VS  + +

+

+
+
\ No newline at end of file diff --git a/src/arenas/tictactoe/doc-fr.html b/src/arenas/tictactoe/doc-fr.html index de5151a..2e5feff 100644 --- a/src/arenas/tictactoe/doc-fr.html +++ b/src/arenas/tictactoe/doc-fr.html @@ -32,4 +32,4 @@ avec les coordonnées d'une case déjà jouée perd la partie.

Publier votre programme pour le tester puis le lâcher dans l'arène

-

Ce n'est pas encore possible. L'interface est en cours de developpement. Mais vous pouvez toujours me contacter, @gnieark sur twitter, je mettrai à la main votre bot dans l'arène.

\ No newline at end of file +

le formulaire est sur la page d'accueil du site

\ No newline at end of file From bed6efdf442eb664c1d046fe731f391fb6da4bc5 Mon Sep 17 00:00:00 2001 From: gnieark Date: Thu, 10 Dec 2015 20:53:13 +0100 Subject: [PATCH 03/41] battle ship functions --- src/arenas/Battleship/functions.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/arenas/Battleship/functions.php diff --git a/src/arenas/Battleship/functions.php b/src/arenas/Battleship/functions.php new file mode 100644 index 0000000..6d73da4 --- /dev/null +++ b/src/arenas/Battleship/functions.php @@ -0,0 +1,17 @@ + $botsCount)){ + error(400,"wrong parameters"); + die; + } + } + return array('bot1' => $_POST['bot1'],'bot2' => $_POST['bot2']); +} From 30ac60c24ec1961f7aceedd69fb361797c56870c Mon Sep 17 00:00:00 2001 From: gnieark Date: Thu, 10 Dec 2015 20:53:48 +0100 Subject: [PATCH 04/41] battle ship functions --- src/arenas/Battleship/public.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index a5a20c0..e1b8907 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -1,5 +1,5 @@ Date: Thu, 10 Dec 2015 20:55:58 +0100 Subject: [PATCH 05/41] page de doc vierge --- src/arenas/Battleship/doc-fr.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/arenas/Battleship/doc-fr.html diff --git a/src/arenas/Battleship/doc-fr.html b/src/arenas/Battleship/doc-fr.html new file mode 100644 index 0000000..88948db --- /dev/null +++ b/src/arenas/Battleship/doc-fr.html @@ -0,0 +1 @@ +

Spécification pour faire votre bot à la bataille navale

\ No newline at end of file From ad133c5b296554045dcb5254ce13abce9c45d3ec Mon Sep 17 00:00:00 2001 From: gnieark Date: Thu, 10 Dec 2015 22:40:08 +0100 Subject: [PATCH 06/41] liste des parametres battleship --- src/arenas/Battleship/doc-fr.html | 8 +++- src/arenas/Battleship/functions.php | 27 ++++++++++++ src/arenas/Battleship/public.php | 65 +++++++++++++++++------------ 3 files changed, 73 insertions(+), 27 deletions(-) diff --git a/src/arenas/Battleship/doc-fr.html b/src/arenas/Battleship/doc-fr.html index 88948db..cd2f505 100644 --- a/src/arenas/Battleship/doc-fr.html +++ b/src/arenas/Battleship/doc-fr.html @@ -1 +1,7 @@ -

Spécification pour faire votre bot à la bataille navale

\ No newline at end of file +

Initialisation de la partie

+

Pour démarrer la partie, l'arène va envoyer une requette http(s) à votre programme contenant les paramètres POST suivants:

+
    +
  • +
  • +
  • +
\ No newline at end of file diff --git a/src/arenas/Battleship/functions.php b/src/arenas/Battleship/functions.php index 6d73da4..b9da5a5 100644 --- a/src/arenas/Battleship/functions.php +++ b/src/arenas/Battleship/functions.php @@ -15,3 +15,30 @@ function get_Post_Params($botsCount){ } return array('bot1' => $_POST['bot1'],'bot2' => $_POST['bot2']); } + +function generate_numeric_select($start,$end,$selected,$name,$id){ + $out="'.$i.''; + } + }else{ + for($i=$start; $i < $selected; $i++ ){ + $out.=''; + } + $out.=''; + for($i=$selected + 1; $i <= $end; $i++ ){ + $out.=''; + } + } + return $out.""; + +} \ No newline at end of file diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index e1b8907..ba79147 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -14,32 +14,45 @@ if(!$postParams){ ?>

-

- -  VS  - -

+

+ largeur: + +  Hauteur: + + +

+

+

+

+

+

+

+

+ +  VS  + +

\ No newline at end of file From cd8a03be9f9fa3b476a9902a0ed7056f8b6264ef Mon Sep 17 00:00:00 2001 From: gnieark Date: Thu, 10 Dec 2015 22:41:21 +0100 Subject: [PATCH 07/41] fix php Parse error --- src/arenas/Battleship/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/functions.php b/src/arenas/Battleship/functions.php index b9da5a5..6b4920e 100644 --- a/src/arenas/Battleship/functions.php +++ b/src/arenas/Battleship/functions.php @@ -19,7 +19,7 @@ function get_Post_Params($botsCount){ function generate_numeric_select($start,$end,$selected,$name,$id){ $out=" Date: Thu, 10 Dec 2015 22:41:45 +0100 Subject: [PATCH 08/41] fix php Parse error --- src/arenas/Battleship/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/functions.php b/src/arenas/Battleship/functions.php index 6b4920e..9dae55d 100644 --- a/src/arenas/Battleship/functions.php +++ b/src/arenas/Battleship/functions.php @@ -22,7 +22,7 @@ function generate_numeric_select($start,$end,$selected,$name,$id){ $out.=' name="'.$name.'"'; } if($id !== ""){ - $out.=' id="'.$id'"'; + $out.=' id="'.$id.'"'; } $out.=">"; From bedcf84bcf4801aff854d0c38c7bd47f67e07959 Mon Sep 17 00:00:00 2001 From: gnieark Date: Thu, 10 Dec 2015 22:42:16 +0100 Subject: [PATCH 09/41] fix php Parse error --- src/arenas/Battleship/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/functions.php b/src/arenas/Battleship/functions.php index 9dae55d..f57cd56 100644 --- a/src/arenas/Battleship/functions.php +++ b/src/arenas/Battleship/functions.php @@ -26,7 +26,7 @@ function generate_numeric_select($start,$end,$selected,$name,$id){ } $out.=">"; - if($select == -1){ + if($selected == -1){ for($i=$start; $i <= $end; $i++ ){ $out.=''; } From f6426bb7e2751c81988f8de1aec6b4a21c9b174b Mon Sep 17 00:00:00 2001 From: gnieark Date: Thu, 10 Dec 2015 22:43:50 +0100 Subject: [PATCH 10/41] css --- html/style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/html/style.css b/html/style.css index 11847d3..62ece79 100644 --- a/html/style.css +++ b/html/style.css @@ -18,7 +18,6 @@ header h1{ display: block; font-size:300%; color:#FFF;float: left; - width: 45%; margin-left: 5%;} header nav{ From 33e6798bca9c9d13cfe89e8efb844ea5776d0c76 Mon Sep 17 00:00:00 2001 From: gnieark Date: Thu, 10 Dec 2015 22:45:59 +0100 Subject: [PATCH 11/41] shorters titles --- html/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/html/index.php b/html/index.php index 1ea7818..1e1393e 100644 --- a/html/index.php +++ b/html/index.php @@ -44,7 +44,7 @@ if(isset($_GET['arena'])){ $hist=get_battles_history($currentArena); - $siteTitle=$currentArenaArr['title']." - bots Arena"; + $siteTitle=$currentArenaArr['title']; $siteDescription=$currentArenaArr['metaDescription']; $mainSectionScript="../src/arenas/".$currentArena."/public.php"; $asideSectionContent='

infos:

'.$lang['DEV-YOUR-OWN-BOT'].'
'.$lang['DOC_SPECS_LINKS'].'

@@ -85,7 +85,7 @@ if(isset($_GET['arena'])){ error(404,"Wrong parameter"); die; } - $siteTitle="Specifications ".$currentArenaArr['title']." - bots Arena"; + $siteTitle="Specifications ".$currentArenaArr['title']; $siteDescription="documentation, faites votre propre bot pour ".$currentArenaArr['metaDescription']; $mainSectionScript="../src/arenas/".$currentArenaArr['id']."/doc-".$lang['lang'].".html"; $asideSectionContent=''; //to do @@ -104,7 +104,7 @@ if(isset($_GET['arena'])){ $jsAdditionalScript=""; break; case "About": - $siteTitle="About - bots Arena"; + $siteTitle="About"; $siteDescription="bots arena about page"; $mainSectionScript="../src/about.html"; $asideSectionContent=''; //to do or not to do @@ -112,7 +112,7 @@ if(isset($_GET['arena'])){ $jsAdditionalScript=""; break; case "addBot": - $siteTitle="Valider l'ajout d'une IA - bots Arena"; + $siteTitle="Valider l'ajout d'une IA"; $siteDescription="bots arena about page"; $permitIndex=false; $mainSectionScript="../src/addBot.php"; From 4da2b0a5e88f1ed8ab1173dd85a9706f2b99c373 Mon Sep 17 00:00:00 2001 From: gnieark Date: Thu, 10 Dec 2015 22:50:38 +0100 Subject: [PATCH 12/41] harmony --- src/arenas/Battleship/public.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index ba79147..00a14cc 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -14,13 +14,8 @@ if(!$postParams){ ?>

-

- largeur: - -  Hauteur: - - -

+

+

From 421d3235d0b295232c30651d62ac5158d1b52e73 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 09:25:36 +0100 Subject: [PATCH 13/41] battleship --- src/arenas/Battleship/style.css | 3 +++ src/arenas_lists.php | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 src/arenas/Battleship/style.css diff --git a/src/arenas/Battleship/style.css b/src/arenas/Battleship/style.css new file mode 100644 index 0000000..cd1df47 --- /dev/null +++ b/src/arenas/Battleship/style.css @@ -0,0 +1,3 @@ +article p {width: 100%;} +article p label {float:left; text-align:right; width:70%} +article p select {float: left;} \ No newline at end of file diff --git a/src/arenas_lists.php b/src/arenas_lists.php index 70cda3c..2770c6f 100644 --- a/src/arenas_lists.php +++ b/src/arenas_lists.php @@ -12,7 +12,9 @@ $arenas=array( 'id' => "Battleship", 'url' => "/Battleship", 'title' => "bataille Navale", - 'metaDescription' => 'Affrontements de bots à la battaille navale' + 'metaDescription' => 'Affrontements de bots à la battaille navale', + 'jsFile'=> "js.js", + 'cssFile'=> "style.css" ) ); \ No newline at end of file From 888c6e808425c3e11d0685b98774d79703f79f25 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 09:40:40 +0100 Subject: [PATCH 14/41] fix css --- src/arenas/Battleship/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/style.css b/src/arenas/Battleship/style.css index cd1df47..3484071 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 select {float: left;} \ No newline at end of file +article p select {} \ No newline at end of file From d80db66ce01cfc6833891ba71d6855530f23bc01 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 09:42:46 +0100 Subject: [PATCH 15/41] heuteumeuleu --- src/arenas/Battleship/public.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index 00a14cc..243c8eb 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -22,7 +22,7 @@ if(!$postParams){

-

+

-

+

\ No newline at end of file From 45e4fa411e91d51228ebc2256d7ef2e9b4bfb194 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 09:46:52 +0100 Subject: [PATCH 16/41] heuteumeuleu --- src/arenas/Battleship/public.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index 243c8eb..41e3da0 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -14,15 +14,15 @@ if(!$postParams){ ?>

-

-

+

+

-

+

+

-

+

\ No newline at end of file From f613b0581219b5dda5c2956d9a4b6aa2b993e0ec Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 09:47:12 +0100 Subject: [PATCH 17/41] heuteumeuleu --- src/arenas/Battleship/public.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index 41e3da0..9cf469e 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -48,6 +48,6 @@ if(!$postParams){ ?>

-

+

\ No newline at end of file From fba016b65126a972acc1d826e729200a3fe58e06 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 09:47:48 +0100 Subject: [PATCH 18/41] heuteumeuleu --- src/arenas/Battleship/public.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index 9cf469e..1f40f56 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -22,7 +22,7 @@ if(!$postParams){

-

+

-

+

\ No newline at end of file From 00f4db16534c9127f198585e45abb3ebfc8a4b7b Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 11:40:36 +0100 Subject: [PATCH 19/41] affichage grilles --- src/arenas/Battleship/js.js | 35 ++++++++++++++++++++++++++++++-- src/arenas/Battleship/public.php | 3 ++- src/arenas/Battleship/style.css | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) 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 From fc3fcd0abfe41ac1b3975c2f75f3c750dd526b99 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 11:41:55 +0100 Subject: [PATCH 20/41] fix js --- src/arenas/Battleship/js.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index a8c1578..2b09d27 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -24,15 +24,15 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi document.getElementById('fightResult').innerHTML = ''; //dessiner les deux grilles - tableAdv=createElem("table",{"id":"tblAdv","className":"battleshipGrid"); - tableMe=createElem("table",{"id":"tblAdv","className":"battleshipGrid"); + 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"); + tdAdv=createElem("td",{"id":"adv" + i +"-" + j,"className": "empty"}); + tdMe=createElem("td",{"id":"me" + i +"-" + j,"className": "empty"}); trAdv.appendChild(tdAdv); trMe.appendChild(tdMe); } From f1bbda1fb6eda7d79ed63bf359edbe3314f56b6b Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 11:42:45 +0100 Subject: [PATCH 21/41] fix js --- src/arenas/Battleship/js.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index 2b09d27..0703140 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -30,7 +30,7 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi for (i=0; i < gridHeight ; i++){ trAdv=createElem("tr"); trMe=createElem("tr"); - for (j=0; j < gridwidth ; i++){ + 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); From 68eb3a1a5f6a6cd86a1b5f4c3876c734c582b9eb Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 11:43:47 +0100 Subject: [PATCH 22/41] fix js oups, infinite loop --- src/arenas/Battleship/js.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index 0703140..721d820 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -30,7 +30,7 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi for (i=0; i < gridHeight ; i++){ trAdv=createElem("tr"); trMe=createElem("tr"); - for (j=0; j < gridWidth ; i++){ + for (j=0; j < gridWidth ; j++){ tdAdv=createElem("td",{"id":"adv" + i +"-" + j,"className": "empty"}); tdMe=createElem("td",{"id":"me" + i +"-" + j,"className": "empty"}); trAdv.appendChild(tdAdv); From b7fcc83cb048a89c1cafb98028c14be187a816c7 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 11:56:34 +0100 Subject: [PATCH 23/41] battleship grid css --- src/arenas/Battleship/style.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/arenas/Battleship/style.css b/src/arenas/Battleship/style.css index b80d1cf..ecfdf24 100644 --- a/src/arenas/Battleship/style.css +++ b/src/arenas/Battleship/style.css @@ -1,3 +1,5 @@ article p {width: 100%;} article p label {float:left; text-align:right; width:60%} -article p select {} \ No newline at end of file +article p select {} +.battleshipGrid tr{} +.battleshipGrid tr td{width: 10 px; height:10 px; border: 1px dashed green;} \ No newline at end of file From 67812f15c1c652414abc0eba41adaee7c428db81 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 12:00:22 +0100 Subject: [PATCH 24/41] fix js --- src/arenas/Battleship/js.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index 721d820..c6a9711 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -24,15 +24,15 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi document.getElementById('fightResult').innerHTML = ''; //dessiner les deux grilles - tableAdv=createElem("table",{"id":"tblAdv","className":"battleshipGrid"}); - tableMe=createElem("table",{"id":"tblAdv","className":"battleshipGrid"}); + tableAdv=createElem("table",{"id":"tblAdv","class":"battleshipGrid"}); + tableMe=createElem("table",{"id":"tblAdv","class":"battleshipGrid"}); for (i=0; i < gridHeight ; i++){ trAdv=createElem("tr"); trMe=createElem("tr"); for (j=0; j < gridWidth ; j++){ - tdAdv=createElem("td",{"id":"adv" + i +"-" + j,"className": "empty"}); - tdMe=createElem("td",{"id":"me" + i +"-" + j,"className": "empty"}); + tdAdv=createElem("td",{"id":"adv" + i +"-" + j,"class": "empty"}); + tdMe=createElem("td",{"id":"me" + i +"-" + j,"class": "empty"}); trAdv.appendChild(tdAdv); trMe.appendChild(tdMe); } From 38d8148b2b7833af223b8e0af287e1a2a0b93d4b Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 12:01:19 +0100 Subject: [PATCH 25/41] fix css --- src/arenas/Battleship/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/style.css b/src/arenas/Battleship/style.css index ecfdf24..4410528 100644 --- a/src/arenas/Battleship/style.css +++ b/src/arenas/Battleship/style.css @@ -2,4 +2,4 @@ article p {width: 100%;} article p label {float:left; text-align:right; width:60%} article p select {} .battleshipGrid tr{} -.battleshipGrid tr td{width: 10 px; height:10 px; border: 1px dashed green;} \ No newline at end of file +.battleshipGrid tr td{width: 10px; height: 10px; border: 1px dashed green;} \ No newline at end of file From f85a561f64d7ebf18760fa51ca179aacd818c4bf Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 12:08:57 +0100 Subject: [PATCH 26/41] fix css --- src/arenas/Battleship/style.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/arenas/Battleship/style.css b/src/arenas/Battleship/style.css index 4410528..9dfb194 100644 --- a/src/arenas/Battleship/style.css +++ b/src/arenas/Battleship/style.css @@ -1,5 +1,7 @@ article p {width: 100%;} article p label {float:left; text-align:right; width:60%} article p select {} +td{min-width: 10px; height: 10px;} +.battleshipGrid{float: left;} .battleshipGrid tr{} -.battleshipGrid tr td{width: 10px; height: 10px; border: 1px dashed green;} \ No newline at end of file +.battleshipGrid tr td{border: 1px dashed green;} \ No newline at end of file From 2785af89e900f0b91afaba9d5d90c6f3a787a7b7 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 12:11:24 +0100 Subject: [PATCH 27/41] fix css --- src/arenas/Battleship/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/style.css b/src/arenas/Battleship/style.css index 9dfb194..8b4746c 100644 --- a/src/arenas/Battleship/style.css +++ b/src/arenas/Battleship/style.css @@ -2,6 +2,6 @@ article p {width: 100%;} article p label {float:left; text-align:right; width:60%} article p select {} td{min-width: 10px; height: 10px;} -.battleshipGrid{float: left;} +.battleshipGrid{float: left; border-collapse:collapse;} .battleshipGrid tr{} .battleshipGrid tr td{border: 1px dashed green;} \ No newline at end of file From c886d8983a94c0aa2f005fef79c97e41dd0b95bc Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 12:12:49 +0100 Subject: [PATCH 28/41] fix css --- src/arenas/Battleship/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arenas/Battleship/style.css b/src/arenas/Battleship/style.css index 8b4746c..3a0bd6a 100644 --- a/src/arenas/Battleship/style.css +++ b/src/arenas/Battleship/style.css @@ -1,7 +1,7 @@ article p {width: 100%;} article p label {float:left; text-align:right; width:60%} article p select {} -td{min-width: 10px; height: 10px;} -.battleshipGrid{float: left; border-collapse:collapse;} +td{min-width: 15px; height: 15px;} +.battleshipGrid{float: left; border-collapse:collapse; margin: 20px 20px 20px 20px;} .battleshipGrid tr{} .battleshipGrid tr td{border: 1px dashed green;} \ No newline at end of file From 82790c37d0b3461a8a49c5b800435b06cc1899b3 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 12:16:17 +0100 Subject: [PATCH 29/41] fix php lis of availabes bots on battleship arena --- src/arenas/Battleship/public.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index 3978916..d3eaad2 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -1,7 +1,7 @@ Date: Fri, 11 Dec 2015 12:35:34 +0100 Subject: [PATCH 30/41] does javascript permit it? --- src/arenas/Battleship/js.js | 5 ++++- src/arenas/Battleship/public.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index c6a9711..9f33363 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -20,7 +20,7 @@ function createElem(type,attributes) return elem; } -function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShip4,nbShip5,nbShip6,xd_check){ +function battleship(botsArray,bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShip4,nbShip5,nbShip6,xd_check){ document.getElementById('fightResult').innerHTML = ''; //dessiner les deux grilles @@ -28,6 +28,9 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi tableMe=createElem("table",{"id":"tblAdv","class":"battleshipGrid"}); for (i=0; i < gridHeight ; i++){ + //ligne de titre + + trAdv=createElem("tr"); trMe=createElem("tr"); for (j=0; j < gridWidth ; j++){ diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index d3eaad2..c4c3e2d 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -49,6 +49,6 @@ if(!$postParams){

-

+

\ No newline at end of file From c23f5e5bb38802d0290fea0ea3fbbfb89fb86b17 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 12:57:48 +0100 Subject: [PATCH 31/41] awnser is no --- src/arenas/Battleship/js.js | 32 +++++++++++++++++++++----------- src/arenas/Battleship/public.php | 4 ++-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index 9f33363..400921a 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -20,22 +20,32 @@ function createElem(type,attributes) return elem; } -function battleship(botsArray,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){ + var bot1IdName = bot1.split("-"); + var bot2IdName = bot2.split("-"); document.getElementById('fightResult').innerHTML = ''; //dessiner les deux grilles - tableAdv=createElem("table",{"id":"tblAdv","class":"battleshipGrid"}); - tableMe=createElem("table",{"id":"tblAdv","class":"battleshipGrid"}); + var tableAdv=createElem("table",{"id":"tblAdv","class":"battleshipGrid"}); + var tableMe=createElem("table",{"id":"tblAdv","class":"battleshipGrid"}); - for (i=0; i < gridHeight ; i++){ + for (var i=0; i < gridHeight ; i++){ //ligne de titre - + var trTitre1=createElem("tr"); + var trTitre2=createElem("tr"); + var tdTitre1=createElem("td",{"collspan":gridWidth}); + var tdTitre2=createElem("td",{"collspan":gridWidth}); + tdTitre1.innerHTML = bot1IdName[1]; + tdTitre2.innerHTML = bot2IdName[1]; + trTitre1.appendChild(tdTitre1); + tableAdv.appendChild(trTitre1); + trTitre2.appendChild(tdTitre2); + tableMe.appendChild(trTitre2); - trAdv=createElem("tr"); - trMe=createElem("tr"); - for (j=0; j < gridWidth ; j++){ - tdAdv=createElem("td",{"id":"adv" + i +"-" + j,"class": "empty"}); - tdMe=createElem("td",{"id":"me" + i +"-" + j,"class": "empty"}); + var trAdv=createElem("tr"); + var trMe=createElem("tr"); + for (var j=0; j < gridWidth ; j++){ + var tdAdv=createElem("td",{"id":"adv" + i +"-" + j,"class": "empty"}); + var tdMe=createElem("td",{"id":"me" + i +"-" + j,"class": "empty"}); trAdv.appendChild(tdAdv); trMe.appendChild(tdMe); } diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index c4c3e2d..2a42236 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -43,12 +43,12 @@ if(!$postParams){ $selected='selected="selected"'; else $selected=''; - echo ''; + echo ''; } ?>

-

+

\ No newline at end of file From 89b2149045611efe9b4b494bffd29b505f9fc2bf Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 12:58:38 +0100 Subject: [PATCH 32/41] fix php parse error --- src/arenas/Battleship/public.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index 2a42236..e6f5750 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -43,7 +43,7 @@ if(!$postParams){ $selected='selected="selected"'; else $selected=''; - echo ''; + echo ''; } ?> From 4bc10371a79b7f33006ff343c7647f7ac9bc0c08 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 11 Dec 2015 13:16:40 +0100 Subject: [PATCH 33/41] fix js names of bots --- src/arenas/Battleship/public.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php index e6f5750..f62943a 100644 --- a/src/arenas/Battleship/public.php +++ b/src/arenas/Battleship/public.php @@ -27,11 +27,11 @@ if(!$postParams){ '.$bots[$i]['name'].''; + echo ''; } ?> @@ -40,9 +40,10 @@ if(!$postParams){ '.$bots[$i]['name'].''; } ?> From 7fe4570c56cce951b421355eb151ce8d1444a074 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 11 Dec 2015 13:17:53 +0100 Subject: [PATCH 34/41] fix double appendchild --- src/arenas/Battleship/js.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index 400921a..2d12856 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -37,9 +37,7 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi tdTitre1.innerHTML = bot1IdName[1]; tdTitre2.innerHTML = bot2IdName[1]; trTitre1.appendChild(tdTitre1); - tableAdv.appendChild(trTitre1); trTitre2.appendChild(tdTitre2); - tableMe.appendChild(trTitre2); var trAdv=createElem("tr"); var trMe=createElem("tr"); From 2d3eccec4db0230cec392399f51fcc29cdbf607a Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 11 Dec 2015 13:20:45 +0100 Subject: [PATCH 35/41] fix js --- src/arenas/Battleship/js.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index 2d12856..e4d5adc 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -27,18 +27,19 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi //dessiner les deux grilles var tableAdv=createElem("table",{"id":"tblAdv","class":"battleshipGrid"}); var tableMe=createElem("table",{"id":"tblAdv","class":"battleshipGrid"}); + //ligne de titre + var trTitre1=createElem("tr"); + var trTitre2=createElem("tr"); + var tdTitre1=createElem("td",{"collspan":gridWidth}); + var tdTitre2=createElem("td",{"collspan":gridWidth}); + tdTitre1.innerHTML = bot1IdName[1]; + tdTitre2.innerHTML = bot2IdName[1]; + trTitre1.appendChild(tdTitre1); + tableAdv.appendChild(trTitre1); + trTitre2.appendChild(tdTitre2); + tableMe.appendChild(trTitre2); for (var i=0; i < gridHeight ; i++){ - //ligne de titre - var trTitre1=createElem("tr"); - var trTitre2=createElem("tr"); - var tdTitre1=createElem("td",{"collspan":gridWidth}); - var tdTitre2=createElem("td",{"collspan":gridWidth}); - tdTitre1.innerHTML = bot1IdName[1]; - tdTitre2.innerHTML = bot2IdName[1]; - trTitre1.appendChild(tdTitre1); - trTitre2.appendChild(tdTitre2); - var trAdv=createElem("tr"); var trMe=createElem("tr"); for (var j=0; j < gridWidth ; j++){ From e1d16b1cb5e91d66d5986ed52c93daaf1e4a0240 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 11 Dec 2015 13:21:06 +0100 Subject: [PATCH 36/41] fix js --- src/arenas/Battleship/js.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index e4d5adc..2a5a2de 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -30,8 +30,8 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi //ligne de titre var trTitre1=createElem("tr"); var trTitre2=createElem("tr"); - var tdTitre1=createElem("td",{"collspan":gridWidth}); - var tdTitre2=createElem("td",{"collspan":gridWidth}); + var tdTitre1=createElem("td",{"colspan":gridWidth}); + var tdTitre2=createElem("td",{"colspan":gridWidth}); tdTitre1.innerHTML = bot1IdName[1]; tdTitre2.innerHTML = bot2IdName[1]; trTitre1.appendChild(tdTitre1); From 7f71d281f231630bf3dc5fb645758be773a08cde Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 11 Dec 2015 13:22:29 +0100 Subject: [PATCH 37/41] grid with title per bot --- src/arenas/Battleship/js.js | 4 ++-- src/arenas/Battleship/style.css | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index 2a5a2de..0e394d7 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -30,8 +30,8 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi //ligne de titre var trTitre1=createElem("tr"); var trTitre2=createElem("tr"); - var tdTitre1=createElem("td",{"colspan":gridWidth}); - var tdTitre2=createElem("td",{"colspan":gridWidth}); + var tdTitre1=createElem("th",{"colspan":gridWidth}); + var tdTitre2=createElem("th",{"colspan":gridWidth}); tdTitre1.innerHTML = bot1IdName[1]; tdTitre2.innerHTML = bot2IdName[1]; trTitre1.appendChild(tdTitre1); diff --git a/src/arenas/Battleship/style.css b/src/arenas/Battleship/style.css index 3a0bd6a..4c97286 100644 --- a/src/arenas/Battleship/style.css +++ b/src/arenas/Battleship/style.css @@ -4,4 +4,5 @@ article p select {} td{min-width: 15px; height: 15px;} .battleshipGrid{float: left; border-collapse:collapse; margin: 20px 20px 20px 20px;} .battleshipGrid tr{} -.battleshipGrid tr td{border: 1px dashed green;} \ No newline at end of file +.battleshipGrid tr td{border: 1px dashed green;} +.battleshipGrid tr th{text-align: center;} \ No newline at end of file From 27a068cdf31173c560a8efa7d9cd9db53c480bb1 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 11 Dec 2015 13:59:14 +0100 Subject: [PATCH 38/41] ajax --- src/arenas/Battleship/act.php | 7 +++++++ src/arenas/Battleship/js.js | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 src/arenas/Battleship/act.php diff --git a/src/arenas/Battleship/act.php b/src/arenas/Battleship/act.php new file mode 100644 index 0000000..9eae0c9 --- /dev/null +++ b/src/arenas/Battleship/act.php @@ -0,0 +1,7 @@ + Date: Fri, 11 Dec 2015 14:03:25 +0100 Subject: [PATCH 39/41] fix js --- src/arenas/Battleship/js.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/arenas/Battleship/js.js b/src/arenas/Battleship/js.js index 02a30af..e5d752b 100644 --- a/src/arenas/Battleship/js.js +++ b/src/arenas/Battleship/js.js @@ -66,6 +66,18 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi }}; xhr.open("POST", '/Battleship', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xhr.send('act=initGame&bot1=' + bot1 + '&bot2=' + bot2 + '&gridWidth=' + gridWidth + '&gridHeight=' + gridHeight + '&nbShip1=' + nbShip1 + '&nbShip1=' + nbShip2 + '&nbShip3=' + nbShip3 + '&nbShip4=' + nbShip4 + '&nbShip5=' + nbShip5 '&nbShip6=' + nbShip6 + '&xd_check=' + xd_check); + xhr.send( + 'act=initGame&bot1=' + bot1 + + '&bot2=' + bot2 + + '&gridWidth=' + gridWidth + + '&gridHeight=' + gridHeight + + '&nbShip1=' + nbShip1 + + '&nbShip1=' + nbShip2 + + '&nbShip3=' + nbShip3 + + '&nbShip4=' + nbShip4 + + '&nbShip5=' + nbShip5 + + '&nbShip6=' + nbShip6 + + '&xd_check=' + xd_check + ); } \ No newline at end of file From 06637cee3d6c0bb93d3909bbc3edf06221d4f892 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 17:22:43 +0100 Subject: [PATCH 40/41] clean post vars --- .gitignore | 1 + src/arenas/Battleship/act.php | 61 +++++++++++++++++++++++++++++++++++ src/functions.php | 13 ++++++++ 3 files changed, 75 insertions(+) diff --git a/.gitignore b/.gitignore index 38942cb..149ba46 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ src/config.php +src/countBattles.txt \ No newline at end of file diff --git a/src/arenas/Battleship/act.php b/src/arenas/Battleship/act.php index 9eae0c9..0a69db6 100644 --- a/src/arenas/Battleship/act.php +++ b/src/arenas/Battleship/act.php @@ -1,6 +1,67 @@ $p[2]) + ) + { + error(500,'wrong parameters'); + die; + } + $postValues[$p[0]]=$value; + + } + //check if bots exists + $bot1Exists = false; + $bot2Exists = false; + foreach($bots as $bot){ + if($bot['id'] == $_POST['bot1']){ + $bot1 = $bot; + $bot1Exists =true; + } + if($bot['id'] == $_POST['bot2']){ + $bot2 = $bot; + $bot2Exists =true; + } + if ($bot1Exists && $bot2Exists){ + break; + } + } + if ((!$bot1Exists) OR (!$bot2Exists)){ + error (500,"missing parameter"; + } + + //vars checked, lets init the initGame + + $_SESSION['matchId']=get_unique_id(); + + break; default: break; diff --git a/src/functions.php b/src/functions.php index 1e09187..ed1d5be 100644 --- a/src/functions.php +++ b/src/functions.php @@ -213,3 +213,16 @@ function save_battle($game,$bot1,$bot2,$resultat){ '1') ON DUPLICATE KEY UPDATE ".$field." = ".$field." + 1;"); } +function get_unique_id(){ + $fp = fopen(__DIR__'countBattles.txt', 'c+'); + flock($fp, LOCK_EX); + + $count = (int)fread($fp, filesize('count.txt')); + ftruncate($fp, 0); + fseek($fp, 0); + fwrite($fp, $count + 1); + + flock($fp, LOCK_UN); + fclose($fp); + return $count; +} From 2a1461e2f65b054d1359c7eff43987cd8566441b Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 11 Dec 2015 17:23:58 +0100 Subject: [PATCH 41/41] fix php parse error --- src/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions.php b/src/functions.php index ed1d5be..fb776da 100644 --- a/src/functions.php +++ b/src/functions.php @@ -214,7 +214,7 @@ function save_battle($game,$bot1,$bot2,$resultat){ ON DUPLICATE KEY UPDATE ".$field." = ".$field." + 1;"); } function get_unique_id(){ - $fp = fopen(__DIR__'countBattles.txt', 'c+'); + $fp = fopen(__DIR__.'countBattles.txt', 'c+'); flock($fp, LOCK_EX); $count = (int)fread($fp, filesize('count.txt'));