affichage scores
This commit is contained in:
parent
13b80dd983
commit
45d497629a
|
@ -108,6 +108,19 @@ if($currentArena == ""){
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
include ("../src/arenas/".$currentArena."/public.php");
|
include ("../src/arenas/".$currentArena."/public.php");
|
||||||
|
|
||||||
|
//battle history for this arena
|
||||||
|
$hist=get_battles_history($currentArena);
|
||||||
|
echo '<aside id="history">';
|
||||||
|
foreach($hist as $sc){
|
||||||
|
echo '<h2>'.$sc['bot1'].' VS '.$sc['bot2'].'</h2>
|
||||||
|
<ul>
|
||||||
|
<li>'.$sc['bot1']." ".$lang['VICTORIES'].":".$sc['player1Wins'].'</li>
|
||||||
|
<li>'.$sc['bot2']." ".$lang['VICTORIES'].":".$sc['player2Wins'].'</li>
|
||||||
|
<li>'$lang['DRAW'].":".$sc['draws'].'</li>
|
||||||
|
</ul>';
|
||||||
|
}
|
||||||
|
echo '</aside>'
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -2,5 +2,7 @@
|
||||||
$lang=array(
|
$lang=array(
|
||||||
'SITE_NAME' => 'bots\'arena',
|
'SITE_NAME' => 'bots\'arena',
|
||||||
'SITE_DESCRIPTION' => 'blah blah blah but english',
|
'SITE_DESCRIPTION' => 'blah blah blah but english',
|
||||||
'HOME' => 'Home page'
|
'HOME' => 'Home page',
|
||||||
|
'VICTORIES' => 'victories',
|
||||||
|
'DRAW' => 'drawn match'
|
||||||
);
|
);
|
|
@ -5,5 +5,8 @@ $lang=array(
|
||||||
'<p>Bienvenue sur cette arène à bots.<br/>
|
'<p>Bienvenue sur cette arène à bots.<br/>
|
||||||
Plusieurs jeux sont proposés ici. Vous ne devez pas y jouer, mais dévolopper le "bot" qui jouera en votre nom.
|
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.</p>',
|
Ce site permet de faire s\'affronter les bots des différents développeurs.</p>',
|
||||||
'HOME' => 'accueil'
|
'HOME' => 'accueil',
|
||||||
|
'VICTORIES' => 'victoires',
|
||||||
|
'DRAW' => 'matchs nuls'
|
||||||
|
|
||||||
);
|
);
|
|
@ -111,6 +111,39 @@ function conn_bdd(){
|
||||||
return $linkMysql; //does PHP can do that?
|
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){
|
function save_battle($game,$bot1,$bot2,$resultat){
|
||||||
//resultat: 0 match nul, 1 bot1 gagne 2 bot 2 gagne
|
//resultat: 0 match nul, 1 bot1 gagne 2 bot 2 gagne
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user