Created
September 1, 2016 11:34
-
-
Save VictorFursa/9f0640ffab5f980f37c593a666e73d5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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