예제 #1
0
<?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) {
예제 #2
0
}
$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;
    $firstAttackerSA = $superman->useHeatRay($secondAttacker);
    $secondAttackerSA = $batman->useBelt($firstAttacker);
}
while ($batman->getHP() && $superman->getHP() > 0) {
    echo "<pre>";
    print_r($batman);
    print_r($superman);
    if ($numOfAttack % 2 == 0) {
        $firstAttacker->attack($secondAttacker);
        $secondAttacker->attack($firstAttacker);
    } else {