Biyernes, Setyembre 28, 2012

duel.php

<?php
    class Duel {
        public $turns;
       
        public function __construct($turns) {
            $this->turns = $turns;
        }
       
        public function Start($ch) {
            $turn = 0;
            $first_turn = 0;
            $ch[0]->isSkillActivated = 0;
            $ch[1]->isSkillActivated = 0;
           
            if ($ch[0]->getSpeed() < $ch[1]->getSpeed()) {
                $first_turn = 1;
            } else {
                $first_turn = 1;
            }

            while($ch[0]->getHealth() > 0 && $ch[1]->getHealth() > 0 && $turn < $this->turns) {
                $name1 = $ch[$first_turn]->getName();
                $name2 = $ch[!$first_turn]->getName();
               
                $attackerSkill = '&nbsp;';
                $defenderSkill = '&nbsp;';
               
                if($ch[$first_turn]->isSkillActivated) {
                    $attackerSkill = $ch[$first_turn]->specialSkill;
                }
               
                if($ch[!$first_turn]->isSkillActivated) {
                    $defenderSkill = $ch[!$first_turn]->specialSkill;
                }
               
                $damageDealt = $ch[$first_turn]->Attack($ch[!$first_turn]);
               
                echo "
                    <tr>
                        <td>" . ($turn + 1) . "</td>
                        <td>{$ch[$first_turn]->getName()}</td>
                        <td>{$ch[!$first_turn]->getName()}</td>
                        <td>" . (int)$this->isEvade . "</td>
                        <td>{$attackerSkill}</td>
                        <td>{$defenderSkill}</td>
                        <td>{$damageDealt}</td>
                    </tr>
                ";

                ++$turn;
                $first_turn = !$first_turn;
            }
        }
    }
?>

Walang komento:

Mag-post ng isang Komento