commit
f9330f33a0
|
@ -107,7 +107,19 @@ 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 '<aside id="history"><h2>Scores</h2>';
|
||||
foreach($hist as $sc){
|
||||
echo '<h3>'.$sc['bot1'].' VS '.$sc['bot2'].'</h3>
|
||||
<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>';
|
||||
include ("../src/arenas/".$currentArena."/public.php");
|
||||
break;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -54,3 +54,12 @@ section{
|
|||
overflow: hidden;
|
||||
width: 90%;
|
||||
}
|
||||
article{
|
||||
float: right;
|
||||
width:70%;
|
||||
}
|
||||
aside{
|
||||
float:left;
|
||||
width: 28%;
|
||||
}
|
||||
|
||||
|
|
|
@ -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`);
|
||||
|
|
|
@ -2,5 +2,8 @@
|
|||
$lang=array(
|
||||
'SITE_NAME' => 'bots\'arena',
|
||||
'SITE_DESCRIPTION' => 'blah blah blah but english',
|
||||
'HOME' => 'Home page'
|
||||
'HOME' => 'Home page',
|
||||
'VICTORIES' => 'victories',
|
||||
'DRAW' => 'drawn match',
|
||||
'MAKE_DUEL' => 'Organise a duel'
|
||||
);
|
|
@ -5,5 +5,9 @@ $lang=array(
|
|||
'<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.
|
||||
Ce site permet de faire s\'affronter les bots des différents développeurs.</p>',
|
||||
'HOME' => 'accueil'
|
||||
'HOME' => 'accueil',
|
||||
'VICTORIES' => 'victoires',
|
||||
'DRAW' => 'matchs nuls',
|
||||
'MAKE_DUEL' => 'Provoquer un duel'
|
||||
|
||||
);
|
|
@ -13,7 +13,7 @@ if(!$postParams){
|
|||
|
||||
?>
|
||||
<article>
|
||||
<h2>Lancer un combat</h2>
|
||||
<h2><?php echo $lang['MAKE_DUEL'];?></h2>
|
||||
<p>
|
||||
<select name="bot1" id="bot1">
|
||||
<?php
|
||||
|
|
|
@ -111,9 +111,44 @@ function conn_bdd(){
|
|||
return $linkMysql; //does PHP can do that?
|
||||
|
||||
}
|
||||
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
|
||||
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
|
||||
|
||||
$game=substr($game,0,8); //limit 8 char for limitting mysql index size
|
||||
|
||||
$lnMysql=conn_bdd();
|
||||
//chercher les id de bot 1 et bot2
|
||||
|
|
Loading…
Reference in New Issue
Block a user