commit
78ad5ac2a3
|
@ -13,7 +13,7 @@
|
|||
@session_start();
|
||||
|
||||
require_once("../src/functions.php");
|
||||
|
||||
$lnMysql=conn_bdd();
|
||||
$arenas=get_arenas_list();
|
||||
$lang=get_language_array();
|
||||
|
||||
|
@ -45,6 +45,8 @@ if (isset($_POST['xd_check'])){
|
|||
//call the good act.php
|
||||
if(($currentArena <> "") && (file_exists("../src/arenas/".$currentArena."/act.php"))){
|
||||
require_once("../src/arenas/".$currentArena."/act.php");
|
||||
}else{
|
||||
require_once("../src/act.php");
|
||||
}
|
||||
}
|
||||
//title
|
||||
|
@ -88,7 +90,7 @@ if($currentArena == ""){
|
|||
<h1><?php echo $siteTitle; ?></h1>
|
||||
|
||||
<nav id="languages"><a href="<?php echo $currentArena; ?>-fr">fr</a> <a href="<?php echo $currentArena; ?>-en">en</a></nav>
|
||||
<nav id="menus"><a href="/"<?php if($currentArena == "") echo ' class="selected"'; ?>><?php echo $lang['HOME']; ?></a>
|
||||
<nav id="menus"><a href="/"<?php if(($currentArena == "") && (!isset($_GET['doc']))) echo ' class="selected"'; ?>><?php echo $lang['HOME']; ?></a>
|
||||
<?php
|
||||
foreach($arenas as $arena){
|
||||
if( $arena['id'] == $currentArena){
|
||||
|
@ -128,7 +130,6 @@ if($currentArena == ""){
|
|||
default:
|
||||
//battle history for this arena
|
||||
$hist=get_battles_history($currentArena);
|
||||
|
||||
echo '<aside id="history">
|
||||
<h2>infos:</h2>
|
||||
<p>'.$lang['DEV-YOUR-OWN-BOT'].'<br/> <a href="/'.$currentArena.'/doc">'.$lang['DOC_SPECS_LINKS'].'</a></p>
|
||||
|
|
|
@ -63,3 +63,12 @@ aside{
|
|||
width: 28%;
|
||||
}
|
||||
|
||||
form textarea, form input, form select {width:40%;}
|
||||
form input[type=checkbox], fieldset input[type=radio] { width:15px; }
|
||||
form label {
|
||||
float:left;
|
||||
width:40%;
|
||||
margin-right:0.5em;
|
||||
padding-top:0.2em;
|
||||
text-align:right;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
$lang=array(
|
||||
'lang' => 'en',
|
||||
'SITE_NAME' => 'bots\'arena',
|
||||
'SITE_DESCRIPTION' => '<p>BWelcome on the bots\'arena.<br/><b>this website is still in dev. it doesn\'t work yet</b><br/>This vhost is a mirror of dev branch <a href="https://github.com/gnieark/botsArena/tree/dev">this github repo</a></p>
|
||||
'SITE_DESCRIPTION' => '<p>Welcome on the bots\'arena.<br/><b>this website is still in dev. it doesn\'t work yet</b><br/>This vhost is a mirror of dev branch <a href="https://github.com/gnieark/botsArena/tree/dev">this github repo</a></p>
|
||||
<p>Many games will be proposed here. You wont play to, but you will developp the bot who will play for you.
|
||||
This website will be the arena for bots confrontation.</p>',
|
||||
'HOME' => 'Home page',
|
||||
|
|
|
@ -4,7 +4,7 @@ require_once(__DIR__."/functions.php");
|
|||
switch ($_POST['act']){
|
||||
|
||||
case "fight":
|
||||
$bots=get_Bots_Array();
|
||||
$bots=get_Bots_Array('tictactoe');
|
||||
//clean $_POST vars
|
||||
$postParams=get_Post_Params(count($bots));
|
||||
if(!$postParams){
|
||||
|
|
|
@ -16,6 +16,7 @@ function get_Post_Params($botsCount){
|
|||
return array('bot1' => $_POST['bot1'],'bot2' => $_POST['bot2']);
|
||||
}
|
||||
|
||||
/*
|
||||
function get_Bots_Array(){
|
||||
//Recupérer la liste des Bots
|
||||
$bots=array();
|
||||
|
@ -29,6 +30,7 @@ function get_Bots_Array(){
|
|||
}
|
||||
return $bots;
|
||||
}
|
||||
*/
|
||||
function get_IA_Response($youChar,$iaBaseUrl,$grille){
|
||||
/*transforme la grille en parametres http GET
|
||||
* et fait la requete vers $iaBaseUrl
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
stupidAI http://morpionmaster.tinad.fr/stupidIa.php
|
||||
moul http://tictactoe.m.42.am/
|
||||
Gnieark http://morpionmaster.tinad.fr/gnieark.php
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
require_once(__DIR__."/functions.php");
|
||||
|
||||
$bots=get_Bots_Array();
|
||||
$bots=get_Bots_Array('tictactoe');
|
||||
$postParams=get_Post_Params(count($bots));
|
||||
if(!$postParams){
|
||||
$bot1="";
|
||||
|
|
|
@ -3,6 +3,29 @@ function get_arenas_list(){
|
|||
include (__DIR__."/arenas_lists.php");
|
||||
return $arenas;
|
||||
}
|
||||
function get_Bots_Array($arena,$activeOnly=true){
|
||||
global $lnMysql;
|
||||
//$bots[]=array("name" => $name, "url" =>$url);
|
||||
|
||||
if($activeOnly){
|
||||
$addClause=" AND active='1'";
|
||||
}else{
|
||||
$addClause="";
|
||||
}
|
||||
|
||||
$rs=mysqli_query($lnMysql,
|
||||
"SELECT id,name,url,description FROM bots WHERE game='".mysqli_real_escape_string($lnMysql,$arena)."'".$addClause);
|
||||
$bots=array();
|
||||
while($r=mysqli_fetch_row($rs)){
|
||||
$bots[]=array(
|
||||
'id' => $r[0],
|
||||
'name'=> $r[1],
|
||||
'url' => $r[2],
|
||||
'description' => $r[3]
|
||||
);
|
||||
}
|
||||
return $bots;
|
||||
}
|
||||
function rand_str($length = 32, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'){
|
||||
|
||||
$chars_length = (strlen($chars) - 1);
|
||||
|
@ -14,6 +37,7 @@ function rand_str($length = 32, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkl
|
|||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
function xd_check_input($id=1){
|
||||
/*
|
||||
*On génére un hash aléatoire qui sera
|
||||
|
@ -112,8 +136,9 @@ function conn_bdd(){
|
|||
|
||||
}
|
||||
function get_battles_history($game){
|
||||
global $lnMysql;
|
||||
$game=substr($game,0,8); //limit 8 char for limitting mysql index size
|
||||
$lnMysql=conn_bdd();
|
||||
|
||||
$rs=mysqli_query($lnMysql,
|
||||
" SELECT
|
||||
player1.name,
|
||||
|
@ -142,15 +167,16 @@ function get_battles_history($game){
|
|||
);
|
||||
|
||||
}
|
||||
mysqli_close($lnMysql);
|
||||
return $results;
|
||||
}
|
||||
function save_battle($game,$bot1,$bot2,$resultat){
|
||||
//resultat: 0 match nul, 1 bot1 gagne 2 bot 2 gagne
|
||||
|
||||
global $lnMysql;
|
||||
|
||||
$game=substr($game,0,8); //limit 8 char for limitting mysql index size
|
||||
|
||||
$lnMysql=conn_bdd();
|
||||
|
||||
//chercher les id de bot 1 et bot2
|
||||
$rs=mysqli_query($lnMysql,"SELECT name,id FROM bots
|
||||
WHERE name='".mysqli_real_escape_string($lnMysql,$bot1)."'
|
||||
|
@ -186,6 +212,4 @@ function save_battle($game,$bot1,$bot2,$resultat){
|
|||
'".$bots[$bot2]."',
|
||||
'1')
|
||||
ON DUPLICATE KEY UPDATE ".$field." = ".$field." + 1;");
|
||||
|
||||
mysqli_close($lnMysql);
|
||||
}
|
||||
|
|
23
src/home.php
23
src/home.php
|
@ -1,2 +1,23 @@
|
|||
<article>
|
||||
<?php
|
||||
echo $lang['SITE_DESCRIPTION'];
|
||||
echo $lang['SITE_DESCRIPTION'];?>
|
||||
</article>
|
||||
<article id="addBot">
|
||||
<h2>Ajouter votre bot</h2>
|
||||
<form method="POST" action="/">
|
||||
<?php echo xd_check_input(0); ?><input type="hidden" name="act" value="addBot"/>
|
||||
<p><label for="botName">Nom de votre Bot: </label><input id="botName" type="text" name="botName" placeholder="votre pseudo par exemple"/></p>
|
||||
<p><label for="botGame">Jeu du bot: </label>
|
||||
<select id="botGame" name="botGame">
|
||||
<?php
|
||||
foreach($arenas as $arena){
|
||||
echo '<option value="'.$arena['id'].'">'.$arena['id'].'</option>';
|
||||
}
|
||||
?>
|
||||
</select></p>
|
||||
<p><label for="botURL">URL du bot:</label><input type="text" name="botURL" id="botURL" placeholder="http://"/></p>
|
||||
<p><label>Description:</label><textarea></textarea></p>
|
||||
<p><label for="email">Votre e-mail (sera utilisé pour valider l'inscription du bot)</label><input type="text" name="email" id="email"/></p>
|
||||
<p><input type="submit" value="Enregistrer mon bot"/></p>
|
||||
</form>
|
||||
</article>
|
Loading…
Reference in New Issue
Block a user