From edb64356183b8d55cb60c18adcd3af70fb59ccf2 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 09:38:02 +0200
Subject: [PATCH 13/87] documentation json format
---
src/arenas/connectFour/doc-fr.html | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/arenas/connectFour/doc-fr.html b/src/arenas/connectFour/doc-fr.html
index 30c1f48..a9ef362 100644
--- a/src/arenas/connectFour/doc-fr.html
+++ b/src/arenas/connectFour/doc-fr.html
@@ -31,12 +31,12 @@ L'arène fait une requête http(s) avec les parametres POST suivants vers v
grid tableau à deux dimmensions au format JSON vous indiquant l'état de la grille
Exemple:
- [{"","","","X","0","",""},
- {"","","","X","","",""},
- {"","","","","","",""},
- {"","","","","","",""},
- {"","","","","","",""},
- {"","","","","","",""}]
+ [["","","","X","0","",""],
+ ["","","","X","","",""],
+ ["","","","","","",""],
+ ["","","","","","",""],
+ ["","","","","","",""],
+ ["","","","","","",""]]
From ecfc59b4620a36e53c482f8480cda3345415d5b0 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 10:33:32 +0200
Subject: [PATCH 14/87] init game
---
html/StupidIAconnectFour.php | 3 ++
src/arenas/connectFour/act.php | 74 +++++++++++++++++++++++++++++--
src/arenas/connectFour/public.php | 2 +-
3 files changed, 74 insertions(+), 5 deletions(-)
create mode 100644 html/StupidIAconnectFour.php
diff --git a/html/StupidIAconnectFour.php b/html/StupidIAconnectFour.php
new file mode 100644
index 0000000..f96fdd6
--- /dev/null
+++ b/html/StupidIAconnectFour.php
@@ -0,0 +1,3 @@
+ "connectFou"){
+ erreur(500,"game non found");
+ }
+
+ //What player has to play?
+ if(!isset($_SESSION['currentPlayer']){
+ $_SESSION['currentPlayer']=1;
+ $you="X";
+ }else{
+ if($_SESSION['currentPlayer']==1){
+ $_SESSION['currentPlayer']=2;
+ $you="O";
+ }else{
+ $_SESSION['currentPlayer']=1;
+ $you="X";
+ }
+ }
+
+ //make post datas to send
+ $postDatas=array(
+ 'game' => 'conectFour',
+ 'match_id' => $_SESSION['matchId']. $_SESSION['currentPlayer'],
+ //'opponent' => $opponentName,
+ 'you' => $you
+ 'grid' => json_encode( $_SESSION['map'])
+
+ );
+ //debug
+ print_r($postDatas);
+ print_r($_SESSION['bot1']);
+
+
+
die;
break;
default:
diff --git a/src/arenas/connectFour/public.php b/src/arenas/connectFour/public.php
index aa5ed1b..852c0e9 100644
--- a/src/arenas/connectFour/public.php
+++ b/src/arenas/connectFour/public.php
@@ -1,7 +1,7 @@
Date: Wed, 11 May 2016 10:56:34 +0200
Subject: [PATCH 15/87] init game
---
src/arenas/connectFour/act.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php
index 6cca1cd..97057dd 100644
--- a/src/arenas/connectFour/act.php
+++ b/src/arenas/connectFour/act.php
@@ -56,7 +56,7 @@ switch ($_POST['act']){
}
//What player has to play?
- if(!isset($_SESSION['currentPlayer']){
+ if(!isset($_SESSION['currentPlayer'])){
$_SESSION['currentPlayer']=1;
$you="X";
}else{
From 88c337981031db2bd1cfb7915b41c03893a53f0b Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 10:57:22 +0200
Subject: [PATCH 16/87] fix php parse error
---
src/arenas/connectFour/act.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php
index 97057dd..914e32c 100644
--- a/src/arenas/connectFour/act.php
+++ b/src/arenas/connectFour/act.php
@@ -74,7 +74,7 @@ switch ($_POST['act']){
'game' => 'conectFour',
'match_id' => $_SESSION['matchId']. $_SESSION['currentPlayer'],
//'opponent' => $opponentName,
- 'you' => $you
+ 'you' => $you,
'grid' => json_encode( $_SESSION['map'])
);
From 2d44329de3a4e0f54c7472188baab19a584790fd Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 11:01:48 +0200
Subject: [PATCH 17/87] debug
---
src/arenas/connectFour/public.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/arenas/connectFour/public.php b/src/arenas/connectFour/public.php
index 852c0e9..54b3dd0 100644
--- a/src/arenas/connectFour/public.php
+++ b/src/arenas/connectFour/public.php
@@ -3,6 +3,7 @@ require_once(__DIR__."/functions.php");
$bots=get_Bots_Array('connectFou');
$postParams=get_Post_Params(count($bots));
+print_r($bots); die;
if(!$postParams){
$bot1="";
$bot2="";
From 8433823cd44eb0a4c9a225b35c5855aa9fb58592 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 11:05:53 +0200
Subject: [PATCH 18/87] debug
---
src/arenas/connectFour/public.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/public.php b/src/arenas/connectFour/public.php
index 54b3dd0..953f03c 100644
--- a/src/arenas/connectFour/public.php
+++ b/src/arenas/connectFour/public.php
@@ -3,7 +3,7 @@ require_once(__DIR__."/functions.php");
$bots=get_Bots_Array('connectFou');
$postParams=get_Post_Params(count($bots));
-print_r($bots); die;
+
if(!$postParams){
$bot1="";
$bot2="";
From 2aff5db1685547ad0cc5d8b060460b746071429f Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 11:07:39 +0200
Subject: [PATCH 19/87] js gestion erreur ajax
---
src/arenas/connectFour/js.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index 5a7df54..11b0ed8 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -18,6 +18,9 @@ function connectFour(bot1,bot2,xd_check){
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) {
document.getElementById('fightResult').innerHTML = xhr.responseText;
+ }else{
+ alert ('error ' + xhr.status);
+ break;
}
}};
xhr.open("POST", '/connectFour', true);
From 138835235565a684c8c1530d4c1eb97fe2ea06d0 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 11:08:20 +0200
Subject: [PATCH 20/87] js gestion erreur ajax
---
src/arenas/connectFour/js.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index 11b0ed8..0bc5896 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -20,7 +20,7 @@ function connectFour(bot1,bot2,xd_check){
document.getElementById('fightResult').innerHTML = xhr.responseText;
}else{
alert ('error ' + xhr.status);
- break;
+ return;
}
}};
xhr.open("POST", '/connectFour', true);
From bc4a44894b3bba11b3afb2838ae96fa9bd819f3b Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 11:16:40 +0200
Subject: [PATCH 21/87] del useless code
---
src/arenas/connectFour/public.php | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
diff --git a/src/arenas/connectFour/public.php b/src/arenas/connectFour/public.php
index 953f03c..0ff01cf 100644
--- a/src/arenas/connectFour/public.php
+++ b/src/arenas/connectFour/public.php
@@ -2,15 +2,6 @@
require_once(__DIR__."/functions.php");
$bots=get_Bots_Array('connectFou');
-$postParams=get_Post_Params(count($bots));
-
-if(!$postParams){
- $bot1="";
- $bot2="";
-}else{
- $bot1=$postParams['bot1'];
- $bot2=$postParams['bot2'];
-}
?>
@@ -19,12 +10,7 @@ if(!$postParams){
'.$bots[$i]['name'].'';
+ echo ''.$bots[$i]['name'].' ';
}
?>
@@ -32,11 +18,7 @@ if(!$postParams){
'.$bots[$i]['name'].'';
+ echo ''.$bots[$i]['name'].' ';
}
?>
From ae48bd4576f7ed561ee4473d98a199363cd9c78d Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 11:20:02 +0200
Subject: [PATCH 22/87] fix
---
src/arenas/connectFour/public.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/arenas/connectFour/public.php b/src/arenas/connectFour/public.php
index 0ff01cf..3e3dd95 100644
--- a/src/arenas/connectFour/public.php
+++ b/src/arenas/connectFour/public.php
@@ -9,16 +9,16 @@ $bots=get_Bots_Array('connectFou');
'.$bots[$i]['name'].'';
+ foreach($bots as $bot){
+ echo ''.$bot['name'].' ';
}
?>
VS
'.$bots[$i]['name'].'';
+ foreach($bots as $bot){
+ echo ''.$bot['name'].' ';
}
?>
From d2ccf4741f4217a2ceaca9b2ea87c87916f0c0c0 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 11:20:59 +0200
Subject: [PATCH 23/87] fix
---
src/arenas/connectFour/act.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php
index 914e32c..036cd50 100644
--- a/src/arenas/connectFour/act.php
+++ b/src/arenas/connectFour/act.php
@@ -46,13 +46,13 @@ switch ($_POST['act']){
//get a match id
$_SESSION['matchId']=get_unique_id();
- $_SESSION['game']="conectFou";
+ $_SESSION['game']="connectFou";
//echo "plop".json_encode($_SESSION['map']);
case "fight":
if($_SESSION['game'] <> "connectFou"){
- erreur(500,"game non found");
+ error(500,"game non found");
}
//What player has to play?
From 72bd49f825f68e262ffa9a7635f16fa1ac2d84eb Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 11:21:50 +0200
Subject: [PATCH 24/87] fix
---
src/arenas/connectFour/act.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php
index 036cd50..d60c5ac 100644
--- a/src/arenas/connectFour/act.php
+++ b/src/arenas/connectFour/act.php
@@ -71,8 +71,8 @@ switch ($_POST['act']){
//make post datas to send
$postDatas=array(
- 'game' => 'conectFour',
- 'match_id' => $_SESSION['matchId']. $_SESSION['currentPlayer'],
+ 'game' => 'connectFour',
+ 'match_id' => $_SESSION['matchId']."-".$_SESSION['currentPlayer'],
//'opponent' => $opponentName,
'you' => $you,
'grid' => json_encode( $_SESSION['map'])
From f701b8d633f202011308b20d404287fec5d74585 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 12:20:34 +0200
Subject: [PATCH 25/87] query to bot
---
src/arenas/connectFour/act.php | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php
index d60c5ac..5f373ef 100644
--- a/src/arenas/connectFour/act.php
+++ b/src/arenas/connectFour/act.php
@@ -59,12 +59,18 @@ switch ($_POST['act']){
if(!isset($_SESSION['currentPlayer'])){
$_SESSION['currentPlayer']=1;
$you="X";
+ $opponentName=$_SESSION['bot2']['name'];
+ $botUrl=$_SESSION['bot1']['url'];
}else{
if($_SESSION['currentPlayer']==1){
$_SESSION['currentPlayer']=2;
$you="O";
+ $opponentName=$_SESSION['bot1']['name'];
+ $botUrl=$_SESSION['bot2']['url'];
}else{
$_SESSION['currentPlayer']=1;
+ $opponentName=$_SESSION['bot2']['name'];
+ $botUrl=$_SESSION['bot1']['url'];
$you="X";
}
}
@@ -73,14 +79,14 @@ switch ($_POST['act']){
$postDatas=array(
'game' => 'connectFour',
'match_id' => $_SESSION['matchId']."-".$_SESSION['currentPlayer'],
- //'opponent' => $opponentName,
+ 'opponent' => $opponentName,
'you' => $you,
'grid' => json_encode( $_SESSION['map'])
);
- //debug
- print_r($postDatas);
- print_r($_SESSION['bot1']);
+ //send query
+ $anwserPlayer=get_IA_Response($botUrl,$postDatas);
+ echo "player ".$_SESSION['currentPlayer']." répond ".$anwserPlayer;
From 66a119689c5d4b2f490e89064d97488883d64730 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 12:21:47 +0200
Subject: [PATCH 26/87] query to bot
---
src/arenas/connectFour/functions.php | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/functions.php b/src/arenas/connectFour/functions.php
index 1f60e7e..e2633b4 100644
--- a/src/arenas/connectFour/functions.php
+++ b/src/arenas/connectFour/functions.php
@@ -1,5 +1,14 @@
Date: Wed, 11 May 2016 12:23:19 +0200
Subject: [PATCH 27/87] query to bot
---
src/functions.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/functions.php b/src/functions.php
index e1af02b..2745efb 100644
--- a/src/functions.php
+++ b/src/functions.php
@@ -227,6 +227,7 @@ function get_unique_id(){
fclose($fp);
return $count;
}
+
function does_arena_exist($string,$arenasArr){
foreach($arenasArr as $arena){
if($string == $arena['id']){
From 9091a4615148b6b8df326abf66f280e5854169c4 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 14:49:38 +0200
Subject: [PATCH 28/87] stupidIa
---
html/StupidIAconnectFour.php | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/html/StupidIAconnectFour.php b/html/StupidIAconnectFour.php
index f96fdd6..aa3f5c2 100644
--- a/html/StupidIAconnectFour.php
+++ b/html/StupidIAconnectFour.php
@@ -1,3 +1,18 @@
Date: Wed, 11 May 2016 14:50:31 +0200
Subject: [PATCH 29/87] debog stupidIa
---
html/StupidIAconnectFour.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html/StupidIAconnectFour.php b/html/StupidIAconnectFour.php
index aa3f5c2..bd0a3d7 100644
--- a/html/StupidIAconnectFour.php
+++ b/html/StupidIAconnectFour.php
@@ -5,7 +5,7 @@
*/
$grid=json_decode($_POST['grid']);
-
+print_r($grid);
$colAvailable=array();
for($i=0;$i<7;$i++){
From 74d43261678ac283ad0e2426ed689d5b8460a206 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 14:51:58 +0200
Subject: [PATCH 30/87] debog stupidIa
---
html/StupidIAconnectFour.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html/StupidIAconnectFour.php b/html/StupidIAconnectFour.php
index bd0a3d7..f017083 100644
--- a/html/StupidIAconnectFour.php
+++ b/html/StupidIAconnectFour.php
@@ -9,7 +9,7 @@ print_r($grid);
$colAvailable=array();
for($i=0;$i<7;$i++){
- if($colAvailable[5][$i] == ""){
+ if($colAvailable[4][$i] == ""){
$colAvailable[]=$i;
}
}
From 22609cf0b0580bb363736aaea3d386c0f81ca0b1 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 14:52:26 +0200
Subject: [PATCH 31/87] debog stupidIa
---
html/StupidIAconnectFour.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/html/StupidIAconnectFour.php b/html/StupidIAconnectFour.php
index f017083..43a9deb 100644
--- a/html/StupidIAconnectFour.php
+++ b/html/StupidIAconnectFour.php
@@ -5,11 +5,11 @@
*/
$grid=json_decode($_POST['grid']);
-print_r($grid);
+
$colAvailable=array();
for($i=0;$i<7;$i++){
- if($colAvailable[4][$i] == ""){
+ if($grid[5][$i] == ""){
$colAvailable[]=$i;
}
}
From 5a1636a0fa0e1f58cb5fa606ae6f20320b227f0a Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 14:53:10 +0200
Subject: [PATCH 32/87] debog stupidIa
---
html/StupidIAconnectFour.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html/StupidIAconnectFour.php b/html/StupidIAconnectFour.php
index 43a9deb..fda1d04 100644
--- a/html/StupidIAconnectFour.php
+++ b/html/StupidIAconnectFour.php
@@ -14,5 +14,5 @@ for($i=0;$i<7;$i++){
}
}
shuffle($colAvailable);
-echo $i;
+echo $colAvailable[0];
die;
From 828f1a4492892fbc696eab0e7b89b9ad4305e12a Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Wed, 11 May 2016 15:05:33 +0200
Subject: [PATCH 33/87] debog stupidIa
---
src/arenas/connectFour/act.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php
index 5f373ef..e73beda 100644
--- a/src/arenas/connectFour/act.php
+++ b/src/arenas/connectFour/act.php
@@ -86,6 +86,9 @@ switch ($_POST['act']){
);
//send query
$anwserPlayer=get_IA_Response($botUrl,$postDatas);
+ $anwserToJS=array(
+
+ )
echo "player ".$_SESSION['currentPlayer']." répond ".$anwserPlayer;
From b85498c1c9798f479294cf7dddb068414fa3ecd6 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Thu, 12 May 2016 17:05:44 +0200
Subject: [PATCH 34/87] arbiter
---
src/arenas/connectFour/act.php | 84 ++++++++++++++++++++++++++++++++--
1 file changed, 81 insertions(+), 3 deletions(-)
diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php
index e73beda..bdbc3b0 100644
--- a/src/arenas/connectFour/act.php
+++ b/src/arenas/connectFour/act.php
@@ -59,6 +59,7 @@ switch ($_POST['act']){
if(!isset($_SESSION['currentPlayer'])){
$_SESSION['currentPlayer']=1;
$you="X";
+ $currentBotName=$_SESSION['bot1']['name'];
$opponentName=$_SESSION['bot2']['name'];
$botUrl=$_SESSION['bot1']['url'];
}else{
@@ -66,10 +67,12 @@ switch ($_POST['act']){
$_SESSION['currentPlayer']=2;
$you="O";
$opponentName=$_SESSION['bot1']['name'];
+ $currentBotName=$_SESSION['bot2']['name'];
$botUrl=$_SESSION['bot2']['url'];
}else{
$_SESSION['currentPlayer']=1;
$opponentName=$_SESSION['bot2']['name'];
+ $currentBotName=$_SESSION['bot1']['name'];
$botUrl=$_SESSION['bot1']['url'];
$you="X";
}
@@ -86,10 +89,85 @@ switch ($_POST['act']){
);
//send query
$anwserPlayer=get_IA_Response($botUrl,$postDatas);
- $anwserToJS=array(
+
+ //vérifier la validité de la réponse
+
+
+ if(isset($_SESSION['map'][5][$anwserPlayer])) && ($_SESSION['map'][5][$anwserPlayer] == ""){
+ //reponse conforme
- )
- echo "player ".$_SESSION['currentPlayer']." répond ".$anwserPlayer;
+ for($y = 0; $_SESSION['map'][$y][$anwserPlayer] <> ""; $y++){
+ }
+ $_SESSION['map'][$y][$anwserPlayer]=$you;
+
+ //does he win?
+ for($i=0;$i < 7;$i++){
+ for($j=0;$j < 6;$j++){
+ if($_SESSION['map'][$j][$i]== $you){
+
+ $wins=false;
+ //tester si 4 pions allignés vers la droite
+ if($i<4){
+ $wins=true;
+ for($x = $i+1; $x < $i+4; $x++){
+ if($_SESSION['map'][$j][$x] <> $you){
+ $wins=false;
+ break;
+ }
+ }
+ }
+
+ //tester si 4 pions allignés diagonale vers la droite
+ if((!$wins) && ($i < 4) && ($j < 3)){
+ $wins=true;
+ for($x = $i+1; $y = $j+1; $x < $i+4 ; $x++; $y++){
+ if($_SESSION['map'][$j][$x] <> $you){
+ $wins=false;
+ break;
+ }
+ }
+ }
+ //tester si 4 pions allignés diagonale vers la gauche
+ if((!$wins) && ($i > 3) && ($j < 3)){
+ $wins=true;
+ for($x = $i-1; $y = $j+1; $x > $i - 4 ; $x++; $y++){
+ if($_SESSION['map'][$j][$x] <> $you){
+ $wins=false;
+ break;
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ if($wins){
+ $anwserToJS=array(
+ 'continue' => 0,
+ 'grid' => $_SESSION['map'],
+ 'log' => $you." ".$currentBotName." a gagné"
+ );
+ }else{
+ $anwserToJS=array(
+ 'continue' => 1,
+ 'grid' => $_SESSION['map'],
+ 'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer
+ );
+
+
+ }
+
+ }else{
+ //reponse non conforme
+ $anwserToJS=array(
+ 'continue' =>0,
+ 'grid' => $_SESSION['map'],
+ 'log' => $you." ".$currentBotName." a fait une réponse non conforme, il perd"
+ );
+ }
+
+ echo json_encode($anwserToJS);
From 0ccdfd604748441a96c9180014e6d71921888aa8 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Thu, 12 May 2016 17:07:06 +0200
Subject: [PATCH 35/87] fix php parse error
---
src/arenas/connectFour/act.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php
index bdbc3b0..f7007c8 100644
--- a/src/arenas/connectFour/act.php
+++ b/src/arenas/connectFour/act.php
@@ -93,7 +93,7 @@ switch ($_POST['act']){
//vérifier la validité de la réponse
- if(isset($_SESSION['map'][5][$anwserPlayer])) && ($_SESSION['map'][5][$anwserPlayer] == ""){
+ if((isset($_SESSION['map'][5][$anwserPlayer])) && ($_SESSION['map'][5][$anwserPlayer] == "")){
//reponse conforme
for($y = 0; $_SESSION['map'][$y][$anwserPlayer] <> ""; $y++){
From 2865b4b384448286e622ce4c9eacdf9014683893 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Thu, 12 May 2016 17:08:20 +0200
Subject: [PATCH 36/87] fix php parse error
---
src/arenas/connectFour/act.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php
index f7007c8..2be0e44 100644
--- a/src/arenas/connectFour/act.php
+++ b/src/arenas/connectFour/act.php
@@ -120,7 +120,7 @@ switch ($_POST['act']){
//tester si 4 pions allignés diagonale vers la droite
if((!$wins) && ($i < 4) && ($j < 3)){
$wins=true;
- for($x = $i+1; $y = $j+1; $x < $i+4 ; $x++; $y++){
+ for($x = $i+1, $y = $j+1; $x < $i+4 ; $x++, $y++){
if($_SESSION['map'][$j][$x] <> $you){
$wins=false;
break;
@@ -130,7 +130,7 @@ switch ($_POST['act']){
//tester si 4 pions allignés diagonale vers la gauche
if((!$wins) && ($i > 3) && ($j < 3)){
$wins=true;
- for($x = $i-1; $y = $j+1; $x > $i - 4 ; $x++; $y++){
+ for($x = $i-1, $y = $j+1; $x > $i - 4 ; $x++, $y++){
if($_SESSION['map'][$j][$x] <> $you){
$wins=false;
break;
From 73440f63fdd4c19cafdd244bc72da33e6bf17226 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:30:49 +0200
Subject: [PATCH 37/87] test retour js
---
src/arenas/connectFour/js.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index 0bc5896..b0ed57c 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -17,7 +17,10 @@ function connectFour(bot1,bot2,xd_check){
var xhr = Ajx();
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) {
- document.getElementById('fightResult').innerHTML = xhr.responseText;
+
+ var reponse = eval(xhr.responseText;);
+ alert (reponse['continue']);
+
}else{
alert ('error ' + xhr.status);
return;
From 4b4f20283aa290793fd66cef26240985b680e024 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:31:49 +0200
Subject: [PATCH 38/87] test retour js
---
src/arenas/connectFour/js.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index b0ed57c..d574c38 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -18,7 +18,7 @@ function connectFour(bot1,bot2,xd_check){
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) {
- var reponse = eval(xhr.responseText;);
+ var reponse = eval(xhr.responseText);
alert (reponse['continue']);
}else{
From 2d0413e5b7592b10776a6c1a150d83b2e50719be Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:33:12 +0200
Subject: [PATCH 39/87] test retour js
---
src/arenas/connectFour/js.js | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index d574c38..0bc5896 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -17,10 +17,7 @@ function connectFour(bot1,bot2,xd_check){
var xhr = Ajx();
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) {
-
- var reponse = eval(xhr.responseText);
- alert (reponse['continue']);
-
+ document.getElementById('fightResult').innerHTML = xhr.responseText;
}else{
alert ('error ' + xhr.status);
return;
From 085e89a032a078992fd66554ce69ba0bc23fab31 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:37:18 +0200
Subject: [PATCH 40/87] test retour js
---
src/arenas/connectFour/js.js | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index 0bc5896..f0ebcf3 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -17,7 +17,13 @@ function connectFour(bot1,bot2,xd_check){
var xhr = Ajx();
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) {
- document.getElementById('fightResult').innerHTML = xhr.responseText;
+ try{
+ var reponse = JSON.parse(xhr.responseText);
+ }catch(e){
+ document.getElementById('logs').innerHTML += 'erreur' +xhr.responseText;
+ return;
+ }
+ alert (reponse['continue']);
}else{
alert ('error ' + xhr.status);
return;
From 93a424369b0d9f395e97ee57d285543666f92f7c Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:45:15 +0200
Subject: [PATCH 41/87] draw table
---
src/arenas/connectFour/js.js | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index f0ebcf3..d7faf7d 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -12,8 +12,28 @@ function Ajx(){
}
return request;
}
+function createElem(type,attributes){
+ var elem=document.createElement(type);
+ for (var i in attributes)
+ {elem.setAttribute(i,attributes[i]);}
+ return elem;
+}
function connectFour(bot1,bot2,xd_check){
- document.getElementById('fightResult').innerHTML = 'Please wait...
';
+ document.getElementById('fightResult').innerHTML = '';
+ //create grid
+
+ var table=createElem('table',{'className':'tabledoc'});
+ for (var i=0; i<6; i++){
+ var tr=createElem('tr');
+ for (var j=0;j<7: j++){
+ var td=createElem('td',{'id': 'td' + i + '-' + j});
+ tr.appendChild (td);
+ }
+
+ table.appendChild(tr);
+ }
+ document.getElementById('fightResult').appendChild(table);
+
var xhr = Ajx();
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) {
@@ -23,7 +43,11 @@ function connectFour(bot1,bot2,xd_check){
document.getElementById('logs').innerHTML += 'erreur' +xhr.responseText;
return;
}
- alert (reponse['continue']);
+ alert (reponse['continue']);
+
+
+
+
}else{
alert ('error ' + xhr.status);
return;
From 0fe79fe8c04d28c7ae155660bde76e5e4be4a518 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:45:49 +0200
Subject: [PATCH 42/87] draw table
---
src/arenas/connectFour/js.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index d7faf7d..f5f0da3 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -25,7 +25,7 @@ function connectFour(bot1,bot2,xd_check){
var table=createElem('table',{'className':'tabledoc'});
for (var i=0; i<6; i++){
var tr=createElem('tr');
- for (var j=0;j<7: j++){
+ for (var j=0;j<7; j++){
var td=createElem('td',{'id': 'td' + i + '-' + j});
tr.appendChild (td);
}
From 5999d87b285b022398f5bc4a5331949bf9eeef95 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:46:33 +0200
Subject: [PATCH 43/87] draw table
---
src/arenas/connectFour/js.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index f5f0da3..02c4f02 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -22,7 +22,7 @@ function connectFour(bot1,bot2,xd_check){
document.getElementById('fightResult').innerHTML = '';
//create grid
- var table=createElem('table',{'className':'tabledoc'});
+ var table=createElem('table',{'class':'tabledoc'});
for (var i=0; i<6; i++){
var tr=createElem('tr');
for (var j=0;j<7; j++){
From dabb45431009f3db402fdb07460cf94e394f6945 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:49:13 +0200
Subject: [PATCH 44/87] css
---
src/arenas/connectFour/js.js | 2 +-
src/arenas/connectFour/style.css | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index 02c4f02..2501c7b 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -22,7 +22,7 @@ function connectFour(bot1,bot2,xd_check){
document.getElementById('fightResult').innerHTML = '';
//create grid
- var table=createElem('table',{'class':'tabledoc'});
+ var table=createElem('table',{'class':'battleGrid'});
for (var i=0; i<6; i++){
var tr=createElem('tr');
for (var j=0;j<7; j++){
diff --git a/src/arenas/connectFour/style.css b/src/arenas/connectFour/style.css
index 6ef9606..ea33177 100644
--- a/src/arenas/connectFour/style.css
+++ b/src/arenas/connectFour/style.css
@@ -1,2 +1,7 @@
.tabledoc{border-collapse:collapse;}
-.tabledoc tr td,.tabledoc tr th{border: 1px solid green; padding-left: 5px;}
\ No newline at end of file
+.tabledoc tr td,.tabledoc tr th{border: 1px solid green; padding-left: 5px;}
+
+.battleGrid{display:table-cell; padding-left:10px; border-collapse:collapse; margin: 20px 20px 20px 20px;}
+.nofloat{float: none;}
+.battleGrid tr{}
+.battleGrid tr td{border: 1px dashed green; text-align: center; font-weight: bold;}
\ No newline at end of file
From 0b7daa701e508ab5b99b53d3e66db8d713e6cae7 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:51:18 +0200
Subject: [PATCH 45/87] css
---
src/arenas/connectFour/style.css | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/arenas/connectFour/style.css b/src/arenas/connectFour/style.css
index ea33177..247f3b0 100644
--- a/src/arenas/connectFour/style.css
+++ b/src/arenas/connectFour/style.css
@@ -2,6 +2,5 @@
.tabledoc tr td,.tabledoc tr th{border: 1px solid green; padding-left: 5px;}
.battleGrid{display:table-cell; padding-left:10px; border-collapse:collapse; margin: 20px 20px 20px 20px;}
-.nofloat{float: none;}
.battleGrid tr{}
-.battleGrid tr td{border: 1px dashed green; text-align: center; font-weight: bold;}
\ No newline at end of file
+.battleGrid tr td{border: 1px dashed green; text-align: center; font-weight: bold;min-width:10px; min-height:10px;}
\ No newline at end of file
From fcd252297470f214be1541e81cb1710bf0ebe1d4 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:53:06 +0200
Subject: [PATCH 46/87] css
---
src/arenas/connectFour/style.css | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/style.css b/src/arenas/connectFour/style.css
index 247f3b0..8058b46 100644
--- a/src/arenas/connectFour/style.css
+++ b/src/arenas/connectFour/style.css
@@ -3,4 +3,4 @@
.battleGrid{display:table-cell; padding-left:10px; border-collapse:collapse; margin: 20px 20px 20px 20px;}
.battleGrid tr{}
-.battleGrid tr td{border: 1px dashed green; text-align: center; font-weight: bold;min-width:10px; min-height:10px;}
\ No newline at end of file
+.battleGrid tr td{border: 1px dashed green; text-align: center; font-weight: bold;min-width:20px; height:20px;}
\ No newline at end of file
From fe7905d82c7cfb89812f090413df15df8a69b44f Mon Sep 17 00:00:00 2001
From: gnieark
Date: Thu, 12 May 2016 19:53:51 +0200
Subject: [PATCH 47/87] css
---
src/arenas/connectFour/js.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index 2501c7b..2e51274 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -43,7 +43,7 @@ function connectFour(bot1,bot2,xd_check){
document.getElementById('logs').innerHTML += 'erreur' +xhr.responseText;
return;
}
- alert (reponse['continue']);
+ //alert (reponse['continue']);
From 8caa44abab9499dd09a5528d8b14f1ae2b345e68 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Fri, 13 May 2016 19:48:41 +0200
Subject: [PATCH 48/87] dont send full map
---
src/arenas/connectFour/act.php | 16 +++++++++++-----
src/arenas/connectFour/js.js | 8 +++++---
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php
index 2be0e44..73f0a02 100644
--- a/src/arenas/connectFour/act.php
+++ b/src/arenas/connectFour/act.php
@@ -99,6 +99,8 @@ switch ($_POST['act']){
for($y = 0; $_SESSION['map'][$y][$anwserPlayer] <> ""; $y++){
}
$_SESSION['map'][$y][$anwserPlayer]=$you;
+ $strikeX=$anwserPlayer;
+ $strikeY=$y;
//does he win?
for($i=0;$i < 7;$i++){
@@ -145,24 +147,28 @@ switch ($_POST['act']){
if($wins){
$anwserToJS=array(
'continue' => 0,
- 'grid' => $_SESSION['map'],
+ 'strikeX' => $strikeX,
+ 'strikeY' => $strikeY,
+ 'strikeSymbol'=> $you,
'log' => $you." ".$currentBotName." a gagné"
);
}else{
$anwserToJS=array(
'continue' => 1,
- 'grid' => $_SESSION['map'],
+ 'strikeX' => $strikeX,
+ 'strikeY' => $strikeY,
+ 'strikeSymbol'=> $you,
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer
);
-
-
+
}
}else{
//reponse non conforme
$anwserToJS=array(
'continue' =>0,
- 'grid' => $_SESSION['map'],
+ 'strikeX' => -1,
+ 'strikeY' => -1,
'log' => $you." ".$currentBotName." a fait une réponse non conforme, il perd"
);
}
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index 2e51274..942928d 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -26,7 +26,7 @@ function connectFour(bot1,bot2,xd_check){
for (var i=0; i<6; i++){
var tr=createElem('tr');
for (var j=0;j<7; j++){
- var td=createElem('td',{'id': 'td' + i + '-' + j});
+ var td=createElem('td',{'id': 'td' + j + '-' + i});
tr.appendChild (td);
}
@@ -43,9 +43,11 @@ function connectFour(bot1,bot2,xd_check){
document.getElementById('logs').innerHTML += 'erreur' +xhr.responseText;
return;
}
- //alert (reponse['continue']);
-
+ //fill the grid
+ if( reponse['strikeX'] > -1){
+ document.getElementById('td' + reponse['strikeX'] + '-' + reponse['strikeY']).innerHTML=reponse['strikeSymbol'];
+ }
}else{
From 2db615e44e56519bfdf63d91522298dc9e832205 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Fri, 13 May 2016 19:50:27 +0200
Subject: [PATCH 49/87] change sense
---
src/arenas/connectFour/js.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index 942928d..d456943 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -23,7 +23,7 @@ function connectFour(bot1,bot2,xd_check){
//create grid
var table=createElem('table',{'class':'battleGrid'});
- for (var i=0; i<6; i++){
+ for (var i=6; i > -1; i--){
var tr=createElem('tr');
for (var j=0;j<7; j++){
var td=createElem('td',{'id': 'td' + j + '-' + i});
From 6b10980a869bb5692305aae845d667deae722f4c Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sat, 14 May 2016 22:53:46 +0200
Subject: [PATCH 50/87] loop
---
src/arenas/connectFour/js.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index d456943..fe7885b 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -18,7 +18,7 @@ function createElem(type,attributes){
{elem.setAttribute(i,attributes[i]);}
return elem;
}
-function connectFour(bot1,bot2,xd_check){
+function connectFour(bot1,bot2,xd_check, newGame=true){
document.getElementById('fightResult').innerHTML = '';
//create grid
@@ -48,6 +48,9 @@ function connectFour(bot1,bot2,xd_check){
if( reponse['strikeX'] > -1){
document.getElementById('td' + reponse['strikeX'] + '-' + reponse['strikeY']).innerHTML=reponse['strikeSymbol'];
}
+ if(reponse['continue'] == 1){
+ connectFour(bot1,bot2,xd_check, false);
+ }
}else{
@@ -57,5 +60,10 @@ function connectFour(bot1,bot2,xd_check){
}};
xhr.open("POST", '/connectFour', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ if(newGame){
+ var act=newFight;
+ }else{
+ var act=fight;
+ }
xhr.send('act=newFight&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check);
}
From a1b5a6626f4d18e58f98217f85d164c66db005e3 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sat, 14 May 2016 22:59:22 +0200
Subject: [PATCH 51/87] function default parameters in javascript
---
src/arenas/connectFour/js.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index fe7885b..5db57ba 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -18,7 +18,10 @@ function createElem(type,attributes){
{elem.setAttribute(i,attributes[i]);}
return elem;
}
-function connectFour(bot1,bot2,xd_check, newGame=true){
+function connectFour(bot1,bot2,xd_check, newGame){
+ if (newGame === undefined){
+ newGame = true;
+ }
document.getElementById('fightResult').innerHTML = '';
//create grid
From b370cf2f9131593ad6f3550e261b6aeaac2708d1 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sat, 14 May 2016 23:00:28 +0200
Subject: [PATCH 52/87] loop
---
src/arenas/connectFour/js.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index 5db57ba..b9d6595 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -68,5 +68,5 @@ function connectFour(bot1,bot2,xd_check, newGame){
}else{
var act=fight;
}
- xhr.send('act=newFight&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check);
+ xhr.send('act=' + act + '&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check);
}
From 30d41fa5fab14c04701df1a01d6eba32279bcc29 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sat, 14 May 2016 23:01:51 +0200
Subject: [PATCH 53/87] erf
---
src/arenas/connectFour/js.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js
index b9d6595..0e9d7ce 100644
--- a/src/arenas/connectFour/js.js
+++ b/src/arenas/connectFour/js.js
@@ -64,9 +64,9 @@ function connectFour(bot1,bot2,xd_check, newGame){
xhr.open("POST", '/connectFour', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
if(newGame){
- var act=newFight;
+ var act='newFight';
}else{
- var act=fight;
+ var act='fight';
}
xhr.send('act=' + act + '&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check);
}
From 535e13392559facaf7de48d4e016787d01cffc51 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sat, 14 May 2016 23:02:58 +0200
Subject: [PATCH 54/87] erf
---
src/arenas/connectFour/public.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arenas/connectFour/public.php b/src/arenas/connectFour/public.php
index 3e3dd95..54a584c 100644
--- a/src/arenas/connectFour/public.php
+++ b/src/arenas/connectFour/public.php
@@ -24,5 +24,5 @@ $bots=get_Bots_Array('connectFou');
-
+
From f73053339abb8e5395b0c455278c284782ff627e Mon Sep 17 00:00:00 2001
From: gnieark