From bdee84f9ab118ab51775cfbd3857eae6027d2e50 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 2 Dec 2016 19:07:25 +0100 Subject: [PATCH 1/3] colorize bots names --- countBattles.txt | 2 +- html/testBotScripts/tron.html | 2 +- src/DUEL.php | 10 ---------- src/act.php | 6 +----- src/arenas/tron/Coords.php | 5 ----- src/arenas/tron/js.js | 5 ++++- src/arenas/tron/style.css | 4 ++-- 7 files changed, 9 insertions(+), 25 deletions(-) diff --git a/countBattles.txt b/countBattles.txt index d081bc1..0fba8d1 100755 --- a/countBattles.txt +++ b/countBattles.txt @@ -1 +1 @@ -1836 \ No newline at end of file +1845 \ No newline at end of file diff --git a/html/testBotScripts/tron.html b/html/testBotScripts/tron.html index 978ab3b..23308d2 100755 --- a/html/testBotScripts/tron.html +++ b/html/testBotScripts/tron.html @@ -73,7 +73,7 @@ function createPlayerForm(index){ divForm.appendChild(select); //url - var inputUrl = createElem("input", {"id","botUrl" + index, "type": "text", "value":"jljfhglfsghf", "placeholder":"http://Bot.url" }); + var inputUrl = createElem("input", {"id":"botUrl" + index, "type": "text", "value":"", "placeholder":"http://Bot.url" }); divForm.appendChild(inputUrl); diff --git a/src/DUEL.php b/src/DUEL.php index 0b158c5..ca00537 100644 --- a/src/DUEL.php +++ b/src/DUEL.php @@ -31,16 +31,6 @@ class DUEL{ } } - - - - - - - - - - class ELO { public $rank = 1500; //default rank diff --git a/src/act.php b/src/act.php index f9df799..d127730 100755 --- a/src/act.php +++ b/src/act.php @@ -100,7 +100,6 @@ switch($_POST['act']){ } } - break; case "editBot": @@ -193,10 +192,7 @@ switch($_POST['act']){ error(500,"Mailer Error: " . $mail->ErrorInfo); } else { //echo "Message sent!"; - } - - - + } } break; diff --git a/src/arenas/tron/Coords.php b/src/arenas/tron/Coords.php index dbb8c29..24bc986 100755 --- a/src/arenas/tron/Coords.php +++ b/src/arenas/tron/Coords.php @@ -12,18 +12,13 @@ class Coords{ error_log("a bot out of limits"); return false; } - $this->x = $x; $this->y = $y; - - } public function __toString(){ return $this->x.",".$this->y; - } - public function addDirection(Direction $dir){ return new Coords( $this->x + $dir->deltaX, diff --git a/src/arenas/tron/js.js b/src/arenas/tron/js.js index 7ce82c5..d8da32d 100755 --- a/src/arenas/tron/js.js +++ b/src/arenas/tron/js.js @@ -35,9 +35,12 @@ function changeSelect(number,botId){ } } function show_bot_panel(number){ + + var botsColor = ['cyan','darkmagenta','darkred','darkslategrey','deeppink','dodgerblue','goldenrod','grey','indigo','lightgreen','mediumslateblue','midnightblue']; + //configurePlayers var fieldset = createElem('fieldset',{'class':'botFormulaire'}); - var legend = createElem('legend',{}); + var legend = createElem('legend',{"style": "color: " + botsColor[number] +'; font-weight: bold;'}); legend.innerHTML = 'bot ' + number; fieldset.appendChild(legend); var p=createElem('p'); diff --git a/src/arenas/tron/style.css b/src/arenas/tron/style.css index b307116..fa439cb 100755 --- a/src/arenas/tron/style.css +++ b/src/arenas/tron/style.css @@ -6,5 +6,5 @@ #configurePlayers{width: 100%;} #configurePlayers fieldset{display: block; width: 100px; float:left;} #logs{display:block;padding-left:10px; height: 200px; overflow-y: scroll;} -#logs p em {color: grey; font-size: 70%; test-transform:italic;} -code{font-family: monospace;} \ No newline at end of file +#logs p em {color: grey; font-size: 70%; font-style:italic;} +code{font-family: monospace;} From dc2069f3038bb7f3d20650635f089ff57be883fd Mon Sep 17 00:00:00 2001 From: Gnieark Date: Sat, 10 Dec 2016 19:18:49 +0100 Subject: [PATCH 2/3] limit time awnser close #97 --- README.md | 14 ++++++++++++++ html/nging-rewrite.txt | 15 +++++++++++++++ src/arenas/tron/TronGame.php | 3 ++- src/functions.php | 4 +++- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 html/nging-rewrite.txt diff --git a/README.md b/README.md index 7f47aee..ca8d8ae 100755 --- a/README.md +++ b/README.md @@ -19,6 +19,20 @@ I'd better like you to help me to improve [bot's Arena](https://botsarena.tinad. * Apache/tomcat document root starts at ./html * copy src/config.php.empty to src/config.php +Apache RewriteRules are given on the file html/.htaccess + +For nginx in server directive: + + rewrite '^/([a-zA-Z]{1,})/doc-([a-z]{2})$' /index.php?doc=$1&lang=$2 last; + rewrite '^/p/([a-zA-Z]{1,})/(.*)-([a-z]{2})$' /index.php?page=$1¶ms=$2&lang=$3 last; + rewrite '^/p/([a-zA-Z]{1,})/(.*)$' /index.php?page=$1¶ms=$2 last; + rewrite '^/p/(.*)-([a-z]{2})$' /index.php?page=$1&lang=$2 last; + rewrite '^/p/(.*)$' index.php?page=$1 last; + rewrite '^/([a-zA-Z]{1,})/scores$' /index.php?scores=$1 last; + rewrite '^/([a-zA-Z]{1,})-([a-z]{2})$' /index.php?arena=$1&lang=$2 last; + rewrite '^/([a-zA-Z]{1,})/doc$' /index.php?doc=$1 last; + rewrite '^/([a-zA-Z]{1,})$' /index.php?arena=$1 last; + # License Bot's Arena , Website for Artificials intelligences duels. diff --git a/html/nging-rewrite.txt b/html/nging-rewrite.txt new file mode 100644 index 0000000..557713c --- /dev/null +++ b/html/nging-rewrite.txt @@ -0,0 +1,15 @@ +RewriteEngine On +RewriteBase / +RewriteRule ^p/([a-zA-Z]{1,})/(.*)-([a-z]{2})$ index\.php?page=$1¶ms=$2&lang=$3 [L] +RewriteRule ^p/([a-zA-Z]{1,})/(.*)$ index\.php?page=$1¶ms=$2 [L] +RewriteRule ^p/(.*)-([a-z]{2})$ index\.php?page=$1&lang=$2 [L] +RewriteRule ^p/(.*)$ index\.php?page=$1 [L] +RewriteRule ^([a-zA-Z]{1,})/doc-([a-z]{2})$ index\.php?doc=$1&lang=$2 [L] +RewriteRule ^([a-zA-Z]{1,})/doc$ index\.php?doc=$1 [L] +RewriteRule ^([a-zA-Z]{1,})/scores$ index\.php?scores=$1 [L] +RewriteRule ^([a-zA-Z]{1,})-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] +RewriteRule ^([a-zA-Z]{1,})$ index\.php?arena=$1 [L] +RewriteRule ^-([a-z]{2})$ index\.php?lang=$1 [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^index.php$ index.php/ [L] \ No newline at end of file diff --git a/src/arenas/tron/TronGame.php b/src/arenas/tron/TronGame.php index 217298a..88ec16c 100755 --- a/src/arenas/tron/TronGame.php +++ b/src/arenas/tron/TronGame.php @@ -105,7 +105,8 @@ class TronGame curl_setopt($ch[$i], CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch[$i], CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch[$i], CURLOPT_POSTFIELDS, $data_string); - curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch[$i], CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch[$i], CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) diff --git a/src/functions.php b/src/functions.php index da9153e..1e1c782 100755 --- a/src/functions.php +++ b/src/functions.php @@ -271,6 +271,7 @@ function save_battle($game,$bot1,$bot2,$result,$nameOrIds = 'name'){ '1') ON DUPLICATE KEY UPDATE ".$field." = ".$field." + 1; "); + } function get_unique_id(){ //increment the number @@ -344,7 +345,8 @@ function get_IA_Response($iaUrl,$postParams){ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) From 2d003a2c7b4a4913a38e95f2f3b31a3327f15f5b Mon Sep 17 00:00:00 2001 From: Gnieark Date: Sat, 10 Dec 2016 19:19:25 +0100 Subject: [PATCH 3/3] useless --- html/nging-rewrite.txt | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 html/nging-rewrite.txt diff --git a/html/nging-rewrite.txt b/html/nging-rewrite.txt deleted file mode 100644 index 557713c..0000000 --- a/html/nging-rewrite.txt +++ /dev/null @@ -1,15 +0,0 @@ -RewriteEngine On -RewriteBase / -RewriteRule ^p/([a-zA-Z]{1,})/(.*)-([a-z]{2})$ index\.php?page=$1¶ms=$2&lang=$3 [L] -RewriteRule ^p/([a-zA-Z]{1,})/(.*)$ index\.php?page=$1¶ms=$2 [L] -RewriteRule ^p/(.*)-([a-z]{2})$ index\.php?page=$1&lang=$2 [L] -RewriteRule ^p/(.*)$ index\.php?page=$1 [L] -RewriteRule ^([a-zA-Z]{1,})/doc-([a-z]{2})$ index\.php?doc=$1&lang=$2 [L] -RewriteRule ^([a-zA-Z]{1,})/doc$ index\.php?doc=$1 [L] -RewriteRule ^([a-zA-Z]{1,})/scores$ index\.php?scores=$1 [L] -RewriteRule ^([a-zA-Z]{1,})-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] -RewriteRule ^([a-zA-Z]{1,})$ index\.php?arena=$1 [L] -RewriteRule ^-([a-z]{2})$ index\.php?lang=$1 [L] -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^index.php$ index.php/ [L] \ No newline at end of file