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){
Nombre de navires de 4 cases:
Nombre de navires de 5 cases:
Nombre de navires de 6 cases:
- !
+
-
+
\ 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 ''.$bots[$i]['name'].' ';
+ echo ''.$bots[$i]['name'].' ';
}
?>
-
+
\ 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 ''.$bots[$i]['name'].' ';
+ echo ''.$bots[$i]['name'].' ';
}
?>
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 ''.$bots[$i]['name'].' ';
}
?>
@@ -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'));