public function getHeatRay() { return $this->heatRay; } public function useHeatRay(&$target) { $remaining = $target->getHP() - $this->heatRay; // $superman->setHP(90); $target->setHP($remaining); } } $achilleas = new human(100, 10); $achilleas->setUtilityDamage(1.2); $achilleas->setCritChance(10); $achilleas->setRagePower(2); $superman = new kryptonian(100, 10); $superman->setHeatRay(18); $superman->setCritChance(20); $br = 0; while ($achilleas->getHP() && $superman->getHP() > 0) { $br++; if ($br % 2 == 0) { if (rand(0, 1) < 1) { $achilleas->useRagePower(); $achilleas->attack($superman); if ($superman->getHP() > 0) { $superman->useHeatRay($achilleas); $superman->attack($achilleas); } } else { $superman->useHeatRay($achilleas);
} public function getHeatRay() { return $this->heatRay; } public function useHeatRay(&$target) { $remaining = $target->getHP() - $this->heatRay; // $superman->setHP(90); $target->setHP($remaining); } } $batman = new human(100, 10); $batman->setUtilityDamage(1.2); $batman->setCritChance(10); $superman = new kryptonian(100, 10); $superman->setHeatRay(18); $superman->setCritChance(20); /* $batman->attack($superman); $superman->attack($batman); $batman->useBelt(); $batman->attack($superman); $superman->useHeatRay($batman);*/ $alive = 1; $attack = 0; echo "<pre>"; while ($alive == 1) { if ($attack == 0) {
public function getHeatRay() { return $this->heatRay; } public function useHeatRay(&$target) { $remaining = $target->getHP() - $this->heatRay; // $superman->setHP(90); $target->setHP($remaining); } } $batman = new human(100, 10, 4); $batman->setUtilityDamage(1.2); $batman->setBatarangsDamage(4); $batman->setCritChance(10); $superman = new kryptonian(200, 10, 3); $superman->setHeatRay(18); $superman->setCritChance(20); do { if ($batman->speed > $superman->speed) { $batman->attack($superman); $superman->attack($batman); $batman->useBelt(); $batman->useBatarangs(); $superman->useHeatRay($batman); } elseif ($batman->speed == $superman->speed) { do { $batman = rand(0, 100); $superman = rand(0, 100); } while ($batman == $superman); if ($batman > $superman) {
<?php require_once "kryptonian.class.php"; require_once "human.class.php"; $batman = new human(100, 10); $batman->setUtilityDamage(1.2); $batman->setCritChance(20); $superman = new kryptonian(100, 10); $superman->setHeatRay(8); $superman->setCritChance(15); $winner = 'Noone'; $i = 0; echo "<pre>"; do { if ($i % 2 == 1) { $batman->useBelt(); $superman->useHeatRay($batman); echo 'Superattacks executed.' . "<br>"; if ($superman->getHP() <= 0 && $batman->getHP() > 0) { $winner = 'Batman'; } if ($batman->getHP() <= 0 && $superman->getHP() > 0) { $winner = 'Superman'; } if ($batman->getHP() <= 0 && $superman->getHP() <= 0) { break; } } else { $batman->attack($superman); $superman->attack($batman); if ($superman->getHP() <= 0 && $batman->getHP() > 0) {
<?php require_once 'monster.php'; require_once 'kryptonian.php'; require_once 'arena.php'; $kraken = new monster(); $kraken->setStats(100 + rand(50, 1000), rand(200, 400), 30, 100); $kraken->isPresent(true); $superMincho = new kryptonian(); $superMincho->setStats('100', rand(100, 200), '50', '30'); $superMincho->setHeatray(rand(30, 50)); $superMincho->setSuperhumanstrength('100'); $superMincho->setRegeneration(rand(80, 120)); echo "<pre>"; print_r($kraken); print_r($superMincho); $arena = new Arena($kraken, $superMincho); $rounds = $arena->doBattle(); echo "The battle is over in {$rounds}"; echo "<pre>"; print_r($kraken); print_r($superMincho);
} public function useHeatRay(&$target) { $remaining = $target->getHP() - $this->heatRay; $target->setHP($remaining); } public function useSuperhumanBreath(&$target) { $remaining = $target->getHP() - $this->superhumanBreath; $target->setHP($remaining); } } $batman = new human(100, 10); $batman->setUtilityDamage(1.2); $batman->setCritChance(10); $superman = new kryptonian(100, 10); $superman->setHeatRay(18); $superman->setSuperhumanBreath(25); $superman->setCritChance(20); do { if ($batman->speed < $superman->speed) { $superman->attack($batman); $batman->attack($superman); $superman->useHeatRay($batman); $superman->useSuperhumanBreath($batman); $batman->useBelt(); } elseif ($batman->speed == $superman->speed) { do { $batman = rand(0, 100); $superman = rand(0, 100); } while ($batman == $superman);
$this->healingFactor = $h * rand(5, 10); } public function getHeal() { return $this->healingFactor; } public function enrage($target) { $this->dmg = $this->dmg * $this->rage; } public function heal($target) { $this->hp = $this->hp + $this->healingFactor; } } $wolverine = new mutant(100, 10); $wolverine->setHeal(5); $wolverine->setEnrage(3); $wolverine->setCritChance(5); $batman = new human(100, 10); $batman->setUtilityDamage(1.2); $batman->setCritChance(10); $superman = new kryptonian(100, 10); $superman->setHeatRay(18); $superman->setCritChance(20); fight($superman, $wolverine); echo "<pre>"; print_r($batman); print_r($superman); print_r($wolverine); exit;
} public function getHeatRay() { return $this->heatRay; } public function useHeatRay(&$target) { $remaining = $target->getHP() - $this->heatRay; // $superman->setHP(90); $target->setHP($remaining); } } $batman = new human(100, 10); $batman->setUtilityDamage(1.2); $batman->setCritChance(10); $superman = new kryptonian(100, 10); $superman->setHeatRay(18); $superman->setCritChance(20); $firstAttacker; $secondAttacker; $numOfAttack = 2; // $firstAttackerSA=$superman->useHeatRay(); // $secondAttackerSA=$batman->useBelt(); if (rand(0, 100) >= 50) { $firstAttacker = $batman; $secondAttacker = $superman; $firstAttackerSA = $batman->useBelt($secondAttacker); $secondAttackerSA = $superman->useHeatRay($firstAttacker); } else { $firstAttacker = $superman; $secondAttacker = $batman;