Skip to content

Instantly share code, notes, and snippets.

@VictorFursa
Created September 1, 2016 11:34
Show Gist options
  • Save VictorFursa/9f0640ffab5f980f37c593a666e73d5e to your computer and use it in GitHub Desktop.
Save VictorFursa/9f0640ffab5f980f37c593a666e73d5e to your computer and use it in GitHub Desktop.
<?php
class Character
{
public $lvl= 1;
public $character;
const WARRIOR = 'warrior';
const MAGE = 'mage';
public $stats = array(
self::WARRIOR => array('power' => 2 , 'intellect' => 1),
self::MAGE => array('power' => 1, 'intellect' => 2)
);
public function __construct($characterName)
{
$this->character = $characterName;
}
public function levelUp($lvl)
{
return $this->lvl = $lvl;
}
public function getStat($lvl,$character)
{
echo '<b>' . $character . '<hr></b>';
foreach ($this->stats[$character] as $key => $value)
{
print_r( "$key = ".$getstat[] = $value + $this->levelUp($lvl) . '<br>');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment