function get_status_list($target = null) { $states = array(); $result = ''; $target = isset($target) ? $target : get_username(); // Default to showing own status. $statuses = getStatus($target); $health = getHealth($target); if ($health < 1) { $states[] = "Dead"; } else { // *** Other statuses only display if not dead. if ($health < 80) { $states[] = "Injured"; } else { $states[] = "Healthy"; } if ($statuses['Stealth']) { $states[] = "Stealthed"; } if ($statuses['Poison']) { $states[] = "Poisoned"; } if ($statuses['Frozen']) { $states[] = "Frozen"; } } return $states; }
function changeHealth($who, $amount) { if (abs($amount) > 0) { global $sql; $sql->Update("UPDATE players SET health = health + " . "CASE WHEN health+{$amount} < 0 THEN health*(-1) ELSE {$amount} END " . "WHERE uname = '{$who}'"); $new_health = getHealth($who); return $new_health; } else { return getHealth($who); } }
function changeHealth($who, $amount) { $amount = (int) $amount; if (abs($amount) > 0) { $dbconn = DatabaseConnection::getInstance(); $statement = DatabaseConnection::$pdo->prepare("UPDATE players SET health = health + " . "CASE WHEN health + :amount < 0 THEN health*(-1) ELSE :amount2 END " . "WHERE player_id = :user"); $statement->bindValue(':user', $who); $statement->bindValue(':amount', $amount); $statement->bindValue(':amount2', $amount); $statement->execute(); } return getHealth($who); }
public function onCommand(CommandSender $sender, Command $command, $label, array $args) { if ($sender instanceof Player) { $name = $sender->getName(); if (strtolower($command->getName()) == "afk") { if (count($args) < 1) { $Phealth = getHealth(); $sender->sendMessage(Color::GREEN . "[AFK plugin] You are now AFK!"); $sender->setHealth(20); $sender->getEffect(10); $this->god = true; return; } else { $sender->sendMessage(Color::GREEN . "[AFK plugin] This command has no arguments!"); return; } } } else { $sender->sendMessage(Color::RED . "That command can only be run in console!"); return; } }
addGold($attackee, $loot); subtractGold($username, $loot); } $attackee_msg = "<div class='ninja-notice'>\n\t\t\t\tYou have killed {$username} in combat and taken {$loot} gold on {$today}.\n\t\t\t\t</div>"; $attacker_msg = "DEATH: You have been killed by {$attackee} in combat and lost {$loot} gold on {$today}!"; sendMessage($username, $attackee, $attackee_msg); sendMessage($attackee, $username, $attacker_msg); echo "<div class='ninja-error'>{$attackee} has killed you!</div>\n"; echo "<div class='ninja-notice'>\n\t\t\t\tYou have been slain! Go to the <a href=\"shrine.php\">Shrine</a> to return to the living.<br>\n\t\t\t\t</div>\n"; if (!$simultaneousKill) { echo "{$attackee} has taken {$loot} gold from you.<br>\n"; } } // *** END MAIN ATTACK AND DUELING SECTION *** } if (!$duel && getHealth($username) > 0 && getHealth($attackee) > 0) { // *** After any partial attack. *** echo "<a href=\"attack_mod.php?attacked=1&attackee={$attackee}\">Attack Again?</a><br>\n"; } } // *** Take away at least one turn even on attacks that fail. *** if ($turns_to_take < 1) { $turns_to_take = 1; } $ending_turns = subtractTurns($username, $turns_to_take); assert($ending_turns < $starting_turns || $starting_turns == 0); // *** START ACTION OVER AGAIN SECTION *** echo "<hr>\n"; if (isset($attackee)) { echo "Return to <a href=\"player.php?player=" . urlencode($attackee) . "\">Player Detail</a><br>Or \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); } } echo "<br>\n"; echo "Beware the Ninja Thieves, they have entered this world to steal from all!<br>\n"; } } } } } } } } } if (getHealth($username) <= 0) { sendMessage("SysMsg", $username, "DEATH: You have been killed by a non-player character at {$today}"); echo "<p>Go to the <a href=\"shrine.php\">shrine</a> to resurrect.</p>"; } subtractTurns($username, $turn_cost); if ($victim && !$random_encounter) { echo "<a href=\"attack_npc.php?attacked=1&victim={$victim}\">Attack {$victim} again</a>\n"; echo "<br>\n"; } echo "<a href=\"attack_player.php\">Return to Combat</a>\n"; } } else { echo "You have no turns left today. Buy a speed scroll or wait for your turns to replenish.\n"; } include SERVER_ROOT . "interface/footer.php";
// Check whether the user actually has the needed skill. $has_skill = $skillListObj->hasSkill($command); $starting_turn_cost = $turn_cost; assert($turn_cost >= 0); $turns_to_take = null; // *** Even on failure take at least one turn. if ($target != "") { $link_back = "<a href=\"player.php?player={$target}\">Player Detail</a>"; } else { $target = $username; $link_back = "<a href=\"skills.php\">Skills</a>"; } $user_ip = $_SESSION['ip']; $username_status = getStatus($username); $class = getClass($username); $target_hp = getHealth($target); $target_ip = $sql->QueryItem("SELECT ip FROM players WHERE uname = '{$target}'"); $target_turns = $sql->QueryItem("SELECT turns FROM players WHERE uname = '{$target}'"); $level = getLevel($username); $covert = false; $victim_alive = true; $attacker_id = $username; $starting_turns = getTurns($username); $ending_turns = null; $level_check = $level - getLevel($target); if ($username_status && $status_array['Stealth']) { $attacker_id = "A Stealthed Ninja"; } // TODO: Make attackLegal use self_use param. // TODO: Make attackLegal also check that the skill can be used on an outside target. // *** Checks the skill use legality, as long as the target isn't self.
addHealth($username, $has_chi ? round($heal_points * 1.5) : $heal_points); $finalHealth = getHealth($username); echo "<p>A monk tends to your wounds and you are " . ($max_health <= $finalHealth ? "fully healed" : "healed to {$finalHealth} hitpoints") . ".</p>\n"; } else { echo "You do not have enough gold for this amount of healing.<br>\n"; } } else { echo "You cannot heal with zero gold.<br>\n"; } } else { echo "You must resurrect before you can heal.<br>\n"; } } else { if ($poisoned == 1) { // *** POISON SECTION *** if (getHealth($username) > 0) { $cost = 50; // the cost of curing poison is set here. if ($startingGold >= $cost) { if (getStatus($username) && $status_array['Poison']) { subtractGold($username, $cost); subtractStatus($username, POISON); echo "You have been cured!<br>\n"; } else { echo "You are not ill.<br><br>\n"; } } else { echo "You need more gold to remove poison.<br>\n"; } } else { echo "You must resurrect before you can heal.<br>\n";
if (isset($_GET['db'])) { $mysql_database = $_GET['db']; //echo "db exists: $mysql_database<Br/>"; } /* else { echo "ERROR: DB does not exist<Br/>"; }*/ if (isset($_GET['sitenames'])) { $a = getSiteNames($mysql_host, $mysql_database, $mysql_user, $mysql_password); echo $a; } if (isset($_GET['health'])) { //echo "health exists<Br/>"; $site = $_GET['site']; $a = getHealth($site, $mysql_host, $mysql_database, $mysql_user, $mysql_password); if (isset($a)) { echo 'No value returned.'; } else { echo $a; } } if (isset($_GET['sitehealth'])) { //echo "site health exists<Br/>"; $site = $_GET['site']; $date = $_GET['q']; if (isset($_GET['site']) && isset($_GET['q'])) { //echo "site info & date data is incomplete<Br/>"; $a = getSiteHealth($date, $site, $mysql_host, $mysql_database, $mysql_user, $mysql_password); echo $a; } else {
} if ($loot) { add_gold(get_char_id($victor), $loot); subtract_gold(get_char_id($loser), $loot); } if ($rounds > 4) { // Even matched battle! Reward some ki to the attacker, even if they die. change_ki($attacker_id, 1); // Award Ki. $rewarded_ki = 1; } } // *** Take away at least one turn even on attacks that fail. *** if ($turns_to_take < 1) { $turns_to_take = 1; } $ending_turns = subtractTurns($attacker_id, $turns_to_take); // *** START ACTION OVER AGAIN SECTION *** $attack_again = false; if (isset($target)) { $attacker_health_snapshot = getHealth($attacker_id); $defender_health_snapshot = getHealth($target_id); if ($AttackLegal && $attacker_health_snapshot > 0 && $defender_health_snapshot > 0) { // *** After any partial attack. *** $attack_again = true; } } $target_ending_health = $target_player->health(); $target_ending_health_percent = $target_player->health_percent(); $target_name = $target_player->name(); display_page('attack_mod.tpl', 'Battle Status', get_defined_vars());