Instead of fixing the [questionable] provided code, we should answer the desperate call of object-oriented refactoring:
// define the class
class Pokemon
{
protected $path;
protected $health;
protected $attack;
public function __construct($path, $attack = 10, $health = 100)
{
$this -> setPath($path);
$this -> setAttack($attack);
$this -> setHealth($health);
}
public function setPath($path){ $this -> path = $path; }
public function getPath(){ return $this -> path; }
public function setAttack($attack){ $this -> attack = $attack; }
public function getAttack(){ return $this -> attack; }
public function setHealth($health){ $this -> health = $health; }
public function getHealth(){ return $this -> health; }
public function attack(Pokemon $other)
{
$otherHealth = $other -> getHealth();
$other -> setHealth($otherHealth - $this -> getAttack());
// make further controls / bonuses / death...
}
}
// use it sonewhere
include "path/to/your/class/file/Pokemon.php"
$pomemon1 = new Pokemon('dunno', 100);
$pomemon2 = new Pokemon('reallyDunno', 100);
$pokemon1 -> attack($pokemon2);
Of course you should read more about the matter, but this is up to you.