private function getHeroData(Hero $heroInformation, $heroLevel) { $data = array(); $information = new Information(); //set everything base on display with respect to hero $information->set('name', $heroInformation->getName() . '(Level ' . DotaResourceData::HERO_LEVEL_START . ')'); $information->set('agi', $heroInformation->getBasicAgility()); $information->set('str', $heroInformation->getBasicStrength()); $information->set('int', $heroInformation->getBasicIntelligence()); $information->set('minDamage', $heroInformation->getMinDamage()); $information->set('maxDamage', $heroInformation->getMaxDamage()); $information->set('hp', $heroInformation->getHp()); $information->set('mana', $heroInformation->getMana()); $data[] = $information; if ($heroLevel > 1) { $data[] = DotaResourceCalculator::getInstance()->getCalculatedHeroStats($heroInformation, $heroLevel); } return $data; }
{ //Attacks every living thing in an array if ($this->isAlive()) { foreach ($monsters as $monster) { while ($monster->isAlive() && $this->isAlive()) { $this->attack($monster); } } } } } $rat = new LivingThing("Rat", 5); $goblin = new LivingThing("Goblin", 30); $ogre = new LivingThing("Ogre", 80); $hero = new Hero("Batman", 100); $monsters = array($rat, $goblin, $ogre); echo "<h3>A hero emerges!</h3>"; echo "<p>The noble {$hero->getName()} has vowed to defeat the monsters and save the realm.</p>"; echo "<p>Will they be victorious?</p>"; $hero->fight($monsters); if ($hero->isAlive()) { echo "<p>The hero {$hero->getName()} prevailed!</p>"; } else { echo "<p>{$hero->getName()} was bested by the monsters. We are doomed.</p>"; } ?> </p> </body> </html>