Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * Description of Fight
- *
- * @author Positivo
- */
- class Fight {
- private $fighter_1;
- private $fighter_2;
- function __construct($fighter_1, $fighter_2) {
- $this->fighter_1 = $fighter_1;
- $this->fighter_2 = $fighter_2;
- }
- function calculate() {
- if (rand(0, 100) > $this->fighter_1->getBase_hit_chance()) {
- echo "<big class='redtext'>MISS</big>";
- return 0;
- } else {
- echo "<br><big class='yellowtext'>" . $this->fighter_1->getNickname() . "</big>'s Base Damage is: <big>" . $this->fighter_1->getBase_damage() . "</big>";
- echo "<br><big class='yellowtext'>" . $this->fighter_2->getNickname() . "</big>'s Health Points is: <big>" . $this->fighter_2->getHealth_poits() . "</big>";
- if (rand(0, 100) > $this->fighter_1->getBase_critical_chance()) {
- $damage = $this->fighter_1->getBase_damage() - (rand(0, $this->fighter_2->getBase_defense()));
- } else {
- echo "<br><h2>Critical Hit!!!</h2>";
- $damage = ($this->fighter_1->getBase_damage() * $this->fighter_1->getBase_critical_damage_multiplier()) - (rand(0, $this->fighter_2->getBase_defense()));
- }
- if ($damage < 0) {
- echo "<br><big class='bluetext'>WEAK!!!</big>";
- return 0;
- } elseif ($damage == 0) {
- echo "<br><big class='orangetext'>BLOCK</big>";
- return 0;
- } else {
- if (rand(0, 100) <= $this->fighter_2->getBase_dodge_chance()) {
- echo "<br><big class='bluetext'>DODGE</big>";
- return 0;
- } else {
- echo "<br>Damage dealt to <big>" . $this->fighter_2->getNickname() . "</big>: <big>" . $damage . "</big>";
- return $damage;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement