<?php
abstract class ocharacter {
protected $aCar = array (
'attaque' => 0,
'defense' => 0,
'pv' => 0,
'init' => 0
);
protected $aSpecialAbilities = array (
'poison' => false
);
public $sImage = '';
const sImgDir = 'char/';
protected function __construct ($sImage, array $aCar) {
if (file_exists (self::sImgDir.$sImage)) {
$this -> sImage = $sImage;
}
foreach ($aCar as $clef => $val) {
if (array_key_exists ($clef, $this -> aCar) && is_int ($val)) {
$this -> aCar[$clef] = $val;
}
}
}
public function getCar ($sCar) {
if (isset ($this -> aCar[$sCar])) {
return $this -> aCar[$sCar];
}
}
public function getCost ($sAbility) {
if (array_key_exists ($sAbility, $this -> aOnFightCan)) {
return $this -> aOnFightCan[$sAbility];
} else {
return false;
}
}
public function getOnFightCan ($sAbility = null) {
if (is_array ($this -> aOnFightCan) && !empty ($this -> aOnFightCan)) {
if (is_null ($sAbility)) {
return array_keys ($this -> aOnFightCan);
} else {
if (array_key_exists ($sAbility, $this -> aOnFightCan)) {
return true;
} else {
return false;
}
}
} else {
return false;
}
}
public function getSpecialAbility ($sAbility = null) {
if (is_array ($this -> aSpecialAbilities) && !empty ($this -> aSpecialAbilities)) {
if (is_null ($sAbility)) {
return $this -> aSpecialAbilities;
} else {
if (array_key_exists ($sAbility, $this -> aSpecialAbilities)) {
return $this -> aSpecialAbilities[$sAbility];
} else {
return false;
}
}
} else {
return false;
}
}
}
?>