Less data on each query
0
.gitignore
vendored
Normal file → Executable file
0
.gitmodules
vendored
Normal file → Executable file
2
countBattles.txt
Normal file → Executable file
|
@ -1 +1 @@
|
|||
1617
|
||||
1622
|
0
html/.htaccess
Normal file → Executable file
0
html/imgs/Arenes-Nimes.jpg
Normal file → Executable file
Before Width: | Height: | Size: 550 KiB After Width: | Height: | Size: 550 KiB |
0
html/imgs/Bronze_Medal.svg
Normal file → Executable file
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
0
html/imgs/Emoji_u1f4a9.svg
Normal file → Executable file
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
0
html/imgs/Gold_Medal.svg
Normal file → Executable file
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
0
html/imgs/Silver_Medal.svg
Normal file → Executable file
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
0
html/index.php
Normal file → Executable file
0
html/log.txt
Normal file → Executable file
0
html/principe.gif
Normal file → Executable file
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
0
html/style.css
Normal file → Executable file
0
html/testBotScripts/connectfour.html
Normal file → Executable file
0
html/testBotScripts/index.html
Normal file → Executable file
0
html/testBotScripts/tictactoe.html
Normal file → Executable file
0
install.sql
Normal file → Executable file
0
lang/en.php
Normal file → Executable file
0
lang/fr.php
Normal file → Executable file
0
src/about.html
Normal file → Executable file
0
src/aboutBot.php
Normal file → Executable file
0
src/act.php
Normal file → Executable file
0
src/addBot.php
Normal file → Executable file
0
src/arenas/Battleship/act.php
Normal file → Executable file
0
src/arenas/Battleship/doc-en.html
Normal file → Executable file
0
src/arenas/Battleship/doc-fr.html
Normal file → Executable file
0
src/arenas/Battleship/functions.php
Normal file → Executable file
0
src/arenas/Battleship/js.js
Normal file → Executable file
0
src/arenas/Battleship/public.php
Normal file → Executable file
0
src/arenas/Battleship/style.css
Normal file → Executable file
0
src/arenas/Battleship/testBot.html
Normal file → Executable file
0
src/arenas/connectFour/act.php
Normal file → Executable file
0
src/arenas/connectFour/doc-en.html
Normal file → Executable file
0
src/arenas/connectFour/doc-fr.html
Normal file → Executable file
0
src/arenas/connectFour/functions.php
Normal file → Executable file
0
src/arenas/connectFour/js.js
Normal file → Executable file
0
src/arenas/connectFour/public.php
Normal file → Executable file
0
src/arenas/connectFour/style.css
Normal file → Executable file
0
src/arenas/tictactoe/act.php
Normal file → Executable file
0
src/arenas/tictactoe/doc-en.html
Normal file → Executable file
0
src/arenas/tictactoe/doc-fr.html
Normal file → Executable file
0
src/arenas/tictactoe/doc.html
Normal file → Executable file
0
src/arenas/tictactoe/functions.php
Normal file → Executable file
0
src/arenas/tictactoe/js.js
Normal file → Executable file
0
src/arenas/tictactoe/public.php
Normal file → Executable file
0
src/arenas/tictactoe/style.css
Normal file → Executable file
0
src/arenas/tictactoe/testBot.html
Normal file → Executable file
0
src/arenas/tron/Coords.php
Normal file → Executable file
0
src/arenas/tron/Direction.php
Normal file → Executable file
1
src/arenas/tron/Trail.php
Normal file → Executable file
|
@ -36,6 +36,7 @@ class Trail {
|
|||
public function __toString(){
|
||||
return json_encode($this->getTrailAsArray());
|
||||
}
|
||||
|
||||
public function getTrailAsArray(){
|
||||
$arr = array();
|
||||
foreach($this->trail as $coord) {
|
||||
|
|
10
src/arenas/tron/TronGame.php
Normal file → Executable file
|
@ -77,6 +77,14 @@ class TronGame
|
|||
}
|
||||
return $trailsArr;
|
||||
}
|
||||
public function get_lasts_trails(){
|
||||
//return only the lasts coords for each tail
|
||||
$trailsArr = array();
|
||||
foreach($this->bots as $bot){
|
||||
$trailsArr[] = $bot->trail->last();
|
||||
}
|
||||
return $trailsArr;
|
||||
}
|
||||
public function new_lap(){
|
||||
// for all alive bots
|
||||
$logs = "";
|
||||
|
@ -133,7 +141,7 @@ class TronGame
|
|||
}
|
||||
}
|
||||
|
||||
return $this->get_trails();
|
||||
return $this->get_lasts_trails();
|
||||
|
||||
|
||||
}
|
||||
|
|
0
src/arenas/tron/TronPlayer.php
Normal file → Executable file
2
src/arenas/tron/act.php
Normal file → Executable file
|
@ -44,7 +44,7 @@ switch ($_POST['act']){
|
|||
'status' => $game->get_continue(),
|
||||
'logs' => $logs,
|
||||
'gameId' => $game->gameId,
|
||||
'botsPosition' => $game->get_trails()
|
||||
'botsPosition' => $game->get_lasts_trails()
|
||||
));
|
||||
|
||||
$_SESSION['game'] = serialize($game);
|
||||
|
|
0
src/arenas/tron/doc-en.html
Normal file → Executable file
0
src/arenas/tron/doc-fr.html
Normal file → Executable file
0
src/arenas/tron/functions.php
Normal file → Executable file
13
src/arenas/tron/js.js
Normal file → Executable file
|
@ -12,6 +12,7 @@ function addLog(message){
|
|||
divLogs.scrollTop = divLogs.scrollHeight;
|
||||
|
||||
}
|
||||
/*
|
||||
function growTails(newPointsByPlayer){
|
||||
|
||||
var botsColor = ['cyan','darkmagenta','darkred','darkslategrey','deeppink','dodgerblue','goldenrod','grey','indigo','lightgreen','mediumslateblue','midnightblue'];
|
||||
|
@ -28,6 +29,7 @@ function growTails(newPointsByPlayer){
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
function createElemNS(type,attributes){
|
||||
//same as createElem but with ns for svg file
|
||||
var elem=document.createElementNS("http://www.w3.org/2000/svg",type);
|
||||
|
@ -85,7 +87,7 @@ function applyInitMessage(req,xd_check){
|
|||
}
|
||||
addLog(ret['logs']);
|
||||
if(ret['status'] == true){
|
||||
growTails(ret['botsPosition']);
|
||||
drawMap(ret['botsPosition']);
|
||||
play(ret['gameId'],xd_check);
|
||||
}
|
||||
|
||||
|
@ -103,12 +105,18 @@ function drawMap(map){
|
|||
var botsColor = ['cyan','darkmagenta','darkred','darkslategrey','deeppink','dodgerblue','goldenrod','grey','indigo','lightgreen','mediumslateblue','midnightblue'];
|
||||
|
||||
for (var botId in map){
|
||||
//draw the point
|
||||
var rect=createElemNS('rect',{'x':map[botId]['x'],'y':map[botId]['y'],'width':'2','height':'2','style':'fill:' + botsColor[botId] + ';'});
|
||||
document.getElementById('map').appendChild(rect);
|
||||
/*
|
||||
for(var coordsI in map[botId]){
|
||||
coords = map[botId][coordsI];
|
||||
//draw the point
|
||||
var rect=createElemNS('rect',{'x':coords[0],'y':coords[1],'width':'2','height':'2','style':'fill:' + botsColor[botId] + ';'});
|
||||
|
||||
document.getElementById('map').appendChild(rect);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,9 +134,12 @@ function play(gameId,xd_check){
|
|||
drawMap(reponse['lap']);
|
||||
if(reponse['continue'] == '1'){
|
||||
play(gameId,xd_check);
|
||||
}else{
|
||||
alert ('game ended');
|
||||
}
|
||||
|
||||
}else{
|
||||
alert('erreur' + req.status);
|
||||
|
||||
}
|
||||
}
|
||||
|
|