From 13b80dd98388afeb98efbd9c0538486fceb0c01d Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sun, 29 Nov 2015 08:26:19 +0100
Subject: [PATCH 1/9] structure BDD
---
install.sql | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/install.sql b/install.sql
index 22baddd..816fc00 100644
--- a/install.sql
+++ b/install.sql
@@ -3,7 +3,8 @@ CREATE TABLE IF NOT EXISTS `arena_history` (
`player1_id` int(11) NOT NULL,
`player2_id` int(11) NOT NULL,
`player1_winsCount` int(11) NOT NULL,
- `player2_winsCount` int(11) NOT NULL
+ `player2_winsCount` int(11) NOT NULL,
+ `nulCount` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `arena_history`
ADD PRIMARY KEY (`game`,`player1_id`,`player2_id`);
From 45d497629aa3273eb5dfd8f2eeafa78e677a2aeb Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sun, 29 Nov 2015 09:42:34 +0100
Subject: [PATCH 2/9] affichage scores
---
html/index.php | 13 +++++++++++++
lang/en.php | 4 +++-
lang/fr.php | 5 ++++-
src/functions.php | 33 +++++++++++++++++++++++++++++++++
4 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/html/index.php b/html/index.php
index cc3cb91..d7256c4 100644
--- a/html/index.php
+++ b/html/index.php
@@ -108,6 +108,19 @@ if($currentArena == ""){
break;
default:
include ("../src/arenas/".$currentArena."/public.php");
+
+ //battle history for this arena
+ $hist=get_battles_history($currentArena);
+ echo '';
+ foreach($hist as $sc){
+ echo ''.$sc['bot1'].' VS '.$sc['bot2'].'
+
+ '.$sc['bot1']." ".$lang['VICTORIES'].":".$sc['player1Wins'].'
+ '.$sc['bot2']." ".$lang['VICTORIES'].":".$sc['player2Wins'].'
+ '$lang['DRAW'].":".$sc['draws'].'
+ ';
+ }
+ echo ' '
break;
}
?>
diff --git a/lang/en.php b/lang/en.php
index a5a1cf5..482f0a7 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -2,5 +2,7 @@
$lang=array(
'SITE_NAME' => 'bots\'arena',
'SITE_DESCRIPTION' => 'blah blah blah but english',
- 'HOME' => 'Home page'
+ 'HOME' => 'Home page',
+ 'VICTORIES' => 'victories',
+ 'DRAW' => 'drawn match'
);
\ No newline at end of file
diff --git a/lang/fr.php b/lang/fr.php
index 28d83f3..87b30a5 100644
--- a/lang/fr.php
+++ b/lang/fr.php
@@ -5,5 +5,8 @@ $lang=array(
'Bienvenue sur cette arène à bots.
Plusieurs jeux sont proposés ici. Vous ne devez pas y jouer, mais dévolopper le "bot" qui jouera en votre nom.
Ce site permet de faire s\'affronter les bots des différents développeurs.
',
- 'HOME' => 'accueil'
+ 'HOME' => 'accueil',
+ 'VICTORIES' => 'victoires',
+ 'DRAW' => 'matchs nuls'
+
);
\ No newline at end of file
diff --git a/src/functions.php b/src/functions.php
index fe4b7f0..88af273 100644
--- a/src/functions.php
+++ b/src/functions.php
@@ -111,6 +111,39 @@ function conn_bdd(){
return $linkMysql; //does PHP can do that?
}
+function get_battles_history($game){
+ $lnMysql=conn_bdd();
+ $rs=mysqli_query($lnMysql,
+ " SELECT
+ player1.name,
+ player2.name,
+ arena_history.player1_winsCount,
+ arena_history.player2_winsCount,
+ arena_history.nulCount
+ FROM
+ bots as player1,
+ bots as player2,
+ arena_history
+ WHERE
+ player1.id=arena_history.player1_id
+ AND player2.id=arena_history.player2_id
+ AND arena_history.game='".mysqli_real_escape_string($lnMysql,$game)."';"
+ );
+
+ $results=array();
+ while($r=mysqli_fetch_row($rs)){
+ $results[]= array(
+ 'bot1' => $r[0],
+ 'bot2' => $r[1],
+ 'player1Wins' => $r[2],
+ 'player2Wins' => $r[3],
+ 'draws' => $r[4]
+ );
+
+ }
+ mysqli_close($lnMysql);
+ return $results;
+}
function save_battle($game,$bot1,$bot2,$resultat){
//resultat: 0 match nul, 1 bot1 gagne 2 bot 2 gagne
From 4cb6a439f3f730bc02ab146aecbfd7e866eb9cbd Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sun, 29 Nov 2015 09:44:54 +0100
Subject: [PATCH 3/9] fix dot missing
---
html/index.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html/index.php b/html/index.php
index d7256c4..b6d8543 100644
--- a/html/index.php
+++ b/html/index.php
@@ -117,7 +117,7 @@ if($currentArena == ""){
'.$sc['bot1']." ".$lang['VICTORIES'].":".$sc['player1Wins'].'
'.$sc['bot2']." ".$lang['VICTORIES'].":".$sc['player2Wins'].'
- '$lang['DRAW'].":".$sc['draws'].'
+ '.$lang['DRAW'].":".$sc['draws'].'
';
}
echo ''
From 7d9881d78787c4580425f99ef0ddae0f3529bca3 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sun, 29 Nov 2015 09:45:32 +0100
Subject: [PATCH 4/9] fix ; missing
---
html/index.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/html/index.php b/html/index.php
index b6d8543..3c89aa3 100644
--- a/html/index.php
+++ b/html/index.php
@@ -120,7 +120,7 @@ if($currentArena == ""){
'.$lang['DRAW'].":".$sc['draws'].'
';
}
- echo ''
+ echo '';
break;
}
?>
From cbab579ea64e86ed93e8efb9a5119952c41adc72 Mon Sep 17 00:00:00 2001
From: Gnieark
Date: Sun, 29 Nov 2015 10:42:54 +0100
Subject: [PATCH 5/9] css a ameliorer, apres que je me sois fait une citronade
---
html/style.css | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/html/style.css b/html/style.css
index 137e61e..a97a8b6 100644
--- a/html/style.css
+++ b/html/style.css
@@ -54,3 +54,12 @@ section{
overflow: hidden;
width: 90%;
}
+article{
+ float: left;
+ width:70%;
+}
+aside{
+ float:right;
+ width: 28%;
+}
+
From 1dd06b939cc08c644a546cec31fa21097cb54262 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sun, 29 Nov 2015 11:12:47 +0100
Subject: [PATCH 6/9] achehteumeuleu
---
html/index.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/html/index.php b/html/index.php
index 3c89aa3..3ce4ee5 100644
--- a/html/index.php
+++ b/html/index.php
@@ -111,9 +111,9 @@ if($currentArena == ""){
//battle history for this arena
$hist=get_battles_history($currentArena);
- echo '';
+ echo 'Scores ';
foreach($hist as $sc){
- echo ''.$sc['bot1'].' VS '.$sc['bot2'].'
+ echo ''.$sc['bot1'].' VS '.$sc['bot2'].'
'.$sc['bot1']." ".$lang['VICTORIES'].":".$sc['player1Wins'].'
'.$sc['bot2']." ".$lang['VICTORIES'].":".$sc['player2Wins'].'
From 812d270e0d399374480ca1b3cdd2894aac86cbb2 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sun, 29 Nov 2015 11:16:36 +0100
Subject: [PATCH 7/9] mise en page
---
html/index.php | 3 +--
html/style.css | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/html/index.php b/html/index.php
index 3ce4ee5..f0a1db2 100644
--- a/html/index.php
+++ b/html/index.php
@@ -107,8 +107,6 @@ if($currentArena == ""){
include ("../src/home.php");
break;
default:
- include ("../src/arenas/".$currentArena."/public.php");
-
//battle history for this arena
$hist=get_battles_history($currentArena);
echo 'Scores ';
@@ -121,6 +119,7 @@ if($currentArena == ""){
';
}
echo ' ';
+ include ("../src/arenas/".$currentArena."/public.php");
break;
}
?>
diff --git a/html/style.css b/html/style.css
index a97a8b6..32a9b55 100644
--- a/html/style.css
+++ b/html/style.css
@@ -55,11 +55,11 @@ section{
width: 90%;
}
article{
- float: left;
+ float: right;
width:70%;
}
aside{
- float:right;
+ float:left;
width: 28%;
}
From 143e59a9ed659f1659e8ad606aeb729bee98a555 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sun, 29 Nov 2015 11:25:47 +0100
Subject: [PATCH 8/9] limit and fix mysql index
---
src/functions.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/functions.php b/src/functions.php
index 88af273..c778b74 100644
--- a/src/functions.php
+++ b/src/functions.php
@@ -112,6 +112,7 @@ function conn_bdd(){
}
function get_battles_history($game){
+ $game=substr($game,0,8); //limit 8 char for limitting mysql index size
$lnMysql=conn_bdd();
$rs=mysqli_query($lnMysql,
" SELECT
@@ -147,6 +148,7 @@ function get_battles_history($game){
function save_battle($game,$bot1,$bot2,$resultat){
//resultat: 0 match nul, 1 bot1 gagne 2 bot 2 gagne
+ $game=substr($game,0,8); //limit 8 char for limitting mysql index size
$lnMysql=conn_bdd();
//chercher les id de bot 1 et bot2
From 9efe398b6d20aa9cbcc2e780ed640c27d5a4b776 Mon Sep 17 00:00:00 2001
From: gnieark
Date: Sun, 29 Nov 2015 11:39:01 +0100
Subject: [PATCH 9/9] trad
---
lang/en.php | 3 ++-
lang/fr.php | 3 ++-
src/arenas/tictactoe/public.php | 2 +-
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lang/en.php b/lang/en.php
index 482f0a7..f0603ed 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -4,5 +4,6 @@ $lang=array(
'SITE_DESCRIPTION' => 'blah blah blah but english',
'HOME' => 'Home page',
'VICTORIES' => 'victories',
- 'DRAW' => 'drawn match'
+ 'DRAW' => 'drawn match',
+ 'MAKE_DUEL' => 'Organise a duel'
);
\ No newline at end of file
diff --git a/lang/fr.php b/lang/fr.php
index 87b30a5..890596b 100644
--- a/lang/fr.php
+++ b/lang/fr.php
@@ -7,6 +7,7 @@ $lang=array(
Ce site permet de faire s\'affronter les bots des différents développeurs.
',
'HOME' => 'accueil',
'VICTORIES' => 'victoires',
- 'DRAW' => 'matchs nuls'
+ 'DRAW' => 'matchs nuls',
+ 'MAKE_DUEL' => 'Provoquer un duel'
);
\ No newline at end of file
diff --git a/src/arenas/tictactoe/public.php b/src/arenas/tictactoe/public.php
index 9a043f9..066674c 100644
--- a/src/arenas/tictactoe/public.php
+++ b/src/arenas/tictactoe/public.php
@@ -13,7 +13,7 @@ if(!$postParams){
?>
- Lancer un combat
+