pull/98/head
Gnieark 8 years ago
parent 464df559dc
commit aa48d68c2a

@ -1,77 +0,0 @@
<?php
class InvalidArenaException extends UnexpectedValueException{
}
class ARENA{
public $name;
public $bots;
private $path;
private $id;
private $url;
private $title;
private $metaDescription;
private $jsFile;
private $cssFile;
private $ludusUrl;
/*
'id' => "tictactoe",
'url' => "/tictactoe",
'title' => "Tic Tac Toe",
'metaDescription' => 'Affrontements de bots au TicTacToe, morpion',
'jsFile'=> "js.js",
'cssFile'=> "style.css",
'ludusUrl' => "/testBotScripts/tictactoe.html"
*/
public function get_id(){
return $this->id;
}
public function get_css_code(){
return file_get_contents($this->path.$this->cssFile);
}
public function get_js_code(){
return file_get_contents($this->path.$this->jsFile);
}
public function get_title(){
return $this->title;
}
public function get_meta_description(){
return $this->metaDescription;
}
public function get_ludus_url(){
return $this->ludusUrl;
}
public function get_doc($lang){
if(file_exists($this->path."doc-".$lang.".html")) return file_get_contents($this->path."doc-".$lang.".html");
if(file_exists($this->path."doc-fr.html")) return file_get_contents($this->path."doc-fr.html");
return "";
}
public function __construct($name){
$this->name = $name;
$this->path = __DIR__."/arenas/".$name."/";
if(!is_dir($this->path)){
throw new InvalidArenaException("No path containing arena ".$name." found ".__DIR__."/".$name."/");
}
$this->bots = new SplStack();
}
public function hydrate($arr){
foreach ($arr as $key => $value){
if (property_exists($this,$key)){
$this->$key = $value;
}else{
throw new InvalidArenaException("incorrect array key");
}
}
}
public function addBot(BOT $bot){
$this->bots->push($bot);
}
}

@ -1,46 +0,0 @@
<?php
class InvalidBotsException extends UnexpectedValueException{
}
class BOT{
/*
+---------------------+-------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------------+-------------+------+-----+-------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | text | NO | | NULL | |
| game | varchar(10) | NO | | NULL | |
| url | text | NO | | NULL | |
| description | text | NO | | NULL | |
| unclean_description | text | NO | | NULL | |
| active | int(1) | NO | | NULL | |
| date_inscription | timestamp | NO | | CURRENT_TIMESTAMP | |
| validate_secret | varchar(8) | NO | | NULL | |
| author_email | text | NO | | NULL | |
| ELO | int(11) | NO | | 1500 | |
+---------------------+-------------+------+-----+-------------------+----------------+
*/
private $id;
public $name;
//don't link to game in this class
public $url;
public $description;
public $ELO;
public function __construct($name){
$this->name = $name;
}
public function hydrate ($arr){
foreach ($arr as $key => $value){
if (property_exists($this,$key)){
$this->$key = $value;
}elseif(is_numeric($key)){
//rien, on accepte mais prends pas en compte
}else{
throw new InvalidArenaException("incorrect array key".$key);
}
}
}
}
Loading…
Cancel
Save