Beispiel #1
0
 /**
  * User command for betting on the coin toss game in the casino
  *
  * @param bet int The amount of money to bet on the coin toss game
  * @return Array
  *
  * @note
  * If the player bets within ~1% of the maximum bet, they will receive a reward item
  */
 public function bet()
 {
     $player = new Player(self_char_id());
     $bet = intval(in('bet'));
     $negative = $bet < 0;
     set_setting('bet', max(0, $bet));
     $pageParts = ['reminder-max-bet'];
     if ($negative) {
         $pageParts = ['result-cheat'];
         $player->vo->health = subtractHealth($player->id(), 99);
     } else {
         if ($bet > $player->vo->gold) {
             $pageParts = ['result-no-gold'];
         } else {
             if ($bet > 0 && $bet <= self::MAX_BET) {
                 if (rand(0, 1) === 1) {
                     $pageParts = ['result-win'];
                     $player->vo->gold = add_gold($player->id(), $bet);
                     if ($bet >= round(self::MAX_BET * 0.99)) {
                         // within about 1% of the max bet & you win, you get a reward item.
                         add_item($player->id(), self::REWARD, 1);
                     }
                 } else {
                     $player->vo->gold = subtract_gold($player->id(), $bet);
                     $pageParts = ['result-lose'];
                 }
             }
         }
     }
     // End of not cheating check.
     return $this->render(['pageParts' => $pageParts, 'player' => $player, 'bet' => get_setting('bet')]);
 }
Beispiel #2
0
     $what = "duel";
 }
 if ($blaze) {
     echo "You spent two extra turns to blaze with power.<br>\n";
     // *** Reminds of Blaze turn cost. ***
 }
 if ($deflect) {
     echo "You spent two extra turns in order to deflect your enemy's blows.<br>\n";
     // *** Deflect turn cost. ***
 }
 //  *** Let the victim know who hit them ***
 $attack_type = $duel ? 'dueled' : 'attacked';
 $email_msg = "You have been {$attack_type} by {$username} at {$today} for {$total_attacker_damage}!";
 sendMessage($username, $attackee, $email_msg);
 $defenderHealthRemaining = subtractHealth($attackee, $total_attacker_damage);
 $attackerHealthRemaining = subtractHealth($username, $total_attackee_damage);
 if ($defenderHealthRemaining < 1) {
     //***  ATTACKER KILLS DEFENDER! ***
     $simultaneousKill = $attackerHealthRemaining < 1;
     // *** If both died at the same time. ***
     $killpoints = 1;
     // *** Changes killpoints from zero to one. ***
     if ($duel) {
         killpointsFromDueling();
         // *** Changes killpoints amount by dueling equation. ***
         $duel_log_msg = "{$username} has dueled {$attackee} and won {$killpoints} killpoints at {$today}.";
         sendMessage("SysMsg", "SysMsg", $duel_log_msg);
         sendLogOfDuel($username, $attackee, 1, $killpoints);
         // *** Makes a WIN record in the dueling log. ***
     }
     addKills($username, $killpoints);
Beispiel #3
0
 if (is_string($item) || $target == "") {
     echo "You didn't choose an item/victim.\n";
 } else {
     $row = $sql->data;
     if ($item_count < 1) {
         echo "You do not have" . ($item ? " {$article} " . $item->getName() : ' that item') . ".\n";
     } else {
         /**** MAIN SUCCESSFUL USE ****/
         echo "Preparing to use item - <br>\n";
         if ($give == "on" || $give == "Give") {
             echo render_give_item($username, $target, $item->getName());
         } else {
             // *** HP Altering ***
             if ($item->getTargetDamage() > 0) {
                 $result = "lose " . $item->getTargetDamage() . " HP";
                 $victim_alive = subtractHealth($target, $item->getTargetDamage());
             } else {
                 if ($item === $stealthScroll) {
                     addStatus($target, STEALTH);
                     echo "<br>{$target} is now Stealthed.<br>\n";
                     $result = false;
                     $victim_alive = true;
                 } else {
                     if ($item === $dimMak) {
                         setHealth($target, 0);
                         $victim_alive = false;
                         $result = "be drained of your life-force and die!";
                         $gold_mod = 0.25;
                         //The Dim Mak takes away 25% of a targets' gold.
                     } else {
                         if ($item->getTurnChange() <= 0) {
Beispiel #4
0
             // Powerful attack gives an additional disadvantage
             echo "<p>You overpowered the swine, but the blow to the head they gave you before they ran made you lose some of your memories!</p>";
             subtractKills($username, 1);
         }
         echo "<p>The group of theives does {$group_attack} damage to you, but you rout them in the end!</p>";
         echo "<p>You have gained {$group_gold} gold.</p> <p>You have found a firescroll on the body of one of the thieves!</p>";
         addGold($username, $group_gold);
         addItem($username, 'Fire Scroll', $quantity = 1);
     }
 } else {
     // Normal attack on a single thief.
     echo "Thief sees you and prepares to defend!<br><br>\n";
     echo "<img src=\"images/characters/thief.png\" alt=\"Thief\">\n";
     $thief_attack = rand(0, 35);
     // *** Thief Damage  ***
     if (!subtractHealth($username, $thief_attack)) {
         echo "Thief has slain you!<br>\n";
         echo "Go to the <a href=\"shrine.php\">shrine</a> to resurrect.<br>\n";
     } else {
         $thief_gold = rand(0, 40);
         // *** Thief Gold ***
         if ($thief_attack > 30) {
             echo "Thief escaped and stole {$thief_gold} pieces of your gold!\n";
             subtractGold($username, $thief_gold);
         } else {
             if ($thief_attack < 30) {
                 echo "The Thief is injured!<br>\n";
                 echo "Thief does {$thief_attack} points of damage!<br>\n";
                 echo "You have gained {$thief_gold} gold.<br> You have found a Shuriken on the thief!\n";
                 addGold($username, $thief_gold);
                 addItem($username, 'Shuriken', $quantity = 1);
Beispiel #5
0
             // Powerful attack gives an additional disadvantage
             subtractKills($char_id, 1);
         }
         add_gold($char_id, $group_gold);
         add_item($char_id, 'phosphor', $quantity = 1);
     } else {
         // If the den of theives killed the attacker.
         $group_gold = 0;
     }
     $npc_template = 'npc.thief-group.tpl';
     $combat_data = array('attack' => $group_attack, 'gold' => $group_gold, 'victory' => $victory);
 } else {
     // Normal attack on a single thief.
     $thief_attack = rand(0, 35);
     // *** Thief Damage  ***
     if ($player->vo->health = $victory = subtractHealth($char_id, $thief_attack)) {
         $thief_gold = rand(0, 40);
         // *** Thief Gold ***
         if ($thief_attack > 30) {
             subtract_gold($char_id, $thief_gold);
         } else {
             if ($thief_attack < 30) {
                 add_gold($char_id, $thief_gold);
                 add_item($char_id, 'shuriken', $quantity = 1);
             }
         }
     } else {
         $thief_gold = 0;
     }
     $npc_template = 'npc.thief.tpl';
     $combat_data = array('attack' => $thief_attack, 'gold' => $thief_gold, 'victory' => $victory);
Beispiel #6
0
         addStatus($target, POISON);
         $target_damage = rand($poisonMinimum, $poisonMaximum);
         $victim_alive = subtractHealth($target, $target_damage);
         echo "{$target} has beeen poisoned!<br>\n";
         echo "{$target}'s HP reduced by {$target_damage}!<br>\n";
         $msg = "You have been poisoned by {$attacker_id} at {$today}";
         sendMessage($attacker_id, $target, $msg);
     } else {
         $turn_cost = 0;
         echo "You do not have enough turns to cast {$command}.\n";
     }
 } elseif ($command == "Fire Bolt") {
     if ($starting_turns >= $turn_cost) {
         $target_damage = 5 * ceil($level / 3) + rand(1, getStrength($username));
         echo "{$target}'s HP reduced by {$target_damage}!<br>\n";
         if ($victim_alive = subtractHealth($target, $target_damage)) {
             $attacker_id = $username;
         }
         $msg = "You have had fire bolt cast on you by {$attacker_id} at {$today}";
         sendMessage($attacker_id, $target, $msg);
     } else {
         $turn_cost = 0;
         echo "You do not have enough turns to cast {$command}.\n";
     }
 } else {
     if ($command == "Ice Bolt") {
         if ($starting_turns >= $turn_cost) {
             $turns_decrease = rand(1, 5);
             subtractTurns($target, $turns_decrease);
             // Changed ice bolt to kill stealth.
             $username_status = subtractStatus($target, STEALTH);
Beispiel #7
0
 } else {
     if ($command == 'Poison Touch') {
         $covert = true;
         $target->addStatus(POISON);
         $target->addStatus(WEAKENED);
         // Weakness kills strength.
         $target_damage = rand($poisonMinimum, $poisonMaximum);
         $victim_alive = $target->subtractHealth($target_damage);
         $generic_state_change = "__TARGET__ has been poisoned!";
         $generic_skill_result_message = "__TARGET__ has taken {$target_damage} damage!";
         $msg = "You have been poisoned by {$attacker_id}";
         send_event($attacker_char_id, $target->id(), $msg);
     } elseif ($command == 'Fire Bolt') {
         $target_damage = 5 * ceil($player->vo->level / 3) + rand(1, $player->getStrength());
         $generic_skill_result_message = "__TARGET__ has taken {$target_damage} damage!";
         if ($victim_alive = subtractHealth($target->vo->player_id, $target_damage)) {
             $attacker_id = $username;
         }
         $msg = "You have had fire bolt cast on you by {$attacker_id}";
         send_event($attacker_char_id, $target->id(), $msg);
     } else {
         if ($command == 'Heal' || $command == 'Harmonize') {
             // This is the starting template for self-use commands, eventually it'll be all refactored.
             $harmonize = false;
             if ($command == 'Harmonize') {
                 $harmonize = true;
             }
             $hurt = $target->hurt_by();
             // Check how much the TARGET is hurt (not the originator, necessarily).
             // Check that the target is not already status healing.
             if ($target->hasStatus(HEALING) && !$player->isAdmin()) {
Beispiel #8
0
     }
 }
 // *** END OF MAIN BATTLE ALGORITHM ***
 $combat_final_results = true;
 $finalizedHealth = $attacker_health - $total_target_damage;
 // *** RESULTING PLAYER MODIFICATION ***
 $gold_mod = 0.2;
 $turns_to_take = $required_turns;
 if ($duel) {
     $gold_mod = 0.25;
     $what = "duel";
 }
 //  *** Let the victim know who hit them ***
 $attack_label = $duel ? 'dueled' : 'attacked';
 $defenderHealthRemaining = subtractHealth($target_id, $total_attacker_damage);
 $attackerHealthRemaining = subtractHealth($attacker_id, $total_target_damage);
 if ($defenderHealthRemaining && $attackerHealthRemaining) {
     $combat_msg = "You have been {$attack_label} by {$attacker} for {$total_attacker_damage}, but they got away before you could kill them!";
 } else {
     $combat_msg = "You have been {$attack_label} by {$attacker} for {$total_attacker_damage}!";
 }
 sendMessage($attacker, $target, $combat_msg);
 if ($defenderHealthRemaining < 1 || $attackerHealthRemaining < 1) {
     // A kill occurred.
     if ($defenderHealthRemaining < 1) {
         //***  ATTACKER KILLS DEFENDER! ***
         if ($simultaneousKill = $attackerHealthRemaining < 1) {
             // *** If both died at the same time. ***
         } else {
             $victor = $attacker;
             $loser = $target;