start battle ship arena dev
This commit is contained in:
parent
99f18fe843
commit
2c033e19cd
26
src/arenas/Battleship/js.js
Normal file
26
src/arenas/Battleship/js.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
function Ajx(){
|
||||
var request = false;
|
||||
try {request = new ActiveXObject('Msxml2.XMLHTTP');}
|
||||
catch (err2) {
|
||||
try {request = new ActiveXObject('Microsoft.XMLHTTP');}
|
||||
catch (err3) {
|
||||
try { request = new XMLHttpRequest();}
|
||||
catch (err1) {
|
||||
request = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return request;
|
||||
}
|
||||
function battleship(bot1,bot2,xd_check){
|
||||
document.getElementById('fightResult').innerHTML = '<p>Please wait...</p>';
|
||||
var xhr = Ajx();
|
||||
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
|
||||
if(xhr.status == 200) {
|
||||
document.getElementById('fightResult').innerHTML = xhr.responseText;
|
||||
}
|
||||
}};
|
||||
xhr.open("POST", '/Battleship', true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send('act=fight&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check);
|
||||
}
|
|
@ -1 +1,45 @@
|
|||
<h2>Battle ship</h2>
|
||||
<?php
|
||||
//require_once(__DIR__."/functions.php");
|
||||
|
||||
$bots=get_Bots_Array('"Battleship');
|
||||
$postParams=get_Post_Params(count($bots));
|
||||
if(!$postParams){
|
||||
$bot1="";
|
||||
$bot2="";
|
||||
}else{
|
||||
$bot1=$postParams['bot1'];
|
||||
$bot2=$postParams['bot2'];
|
||||
}
|
||||
|
||||
?>
|
||||
<article>
|
||||
<h2><?php echo $lang['MAKE_DUEL'];?></h2>
|
||||
<p>
|
||||
<select name="bot1" id="bot1">
|
||||
<?php
|
||||
for($i=0;$i<count($bots);$i++){
|
||||
if($i==$bot1)
|
||||
$selected='selected="selected"';
|
||||
else
|
||||
$selected='';
|
||||
|
||||
echo '<option value="'.$i.'" '.$selected.'>'.$bots[$i]['name'].'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
VS
|
||||
<select name="bot2" id="bot2">
|
||||
<?php
|
||||
for($i=0;$i<count($bots);$i++){
|
||||
if($i==$bot2)
|
||||
$selected='selected="selected"';
|
||||
else
|
||||
$selected='';
|
||||
echo '<option value="'.$i.'" '.$selected.'>'.$bots[$i]['name'].'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<p><input type="button" value="<?php echo $lang['FIGHT']; ?>" onclick="battleship(document.getElementById('bot1').value,document.getElementById('bot2').value,'<?php echo xd_check_input(2); ?>');"></p>
|
||||
<div id="fightResult"></div>
|
||||
</article>
|
|
@ -32,4 +32,4 @@ avec les coordonnées d'une case déjà jouée perd la partie.</p>
|
|||
|
||||
<h2>Publier votre programme pour le tester puis le lâcher dans l'arène</h2>
|
||||
|
||||
<p>Ce n'est pas encore possible. L'interface est en cours de developpement. Mais vous pouvez toujours me contacter, @gnieark sur twitter, je mettrai à la main votre bot dans l'arène.</p>
|
||||
<p>le formulaire est sur la <a href="/">page d'accueil du site</a></p>
|
Loading…
Reference in New Issue
Block a user