Dragon-Knight/heal.php
Jamin Blount 27eb6c15a7 v1.1.0
### 1.1.0 (2.27.2004) ###
### Thanks to Miker, Yop, Mantagnana & Maebius for bug reports & feature
ideas. :)
- Added option to verify registration emails.
- Added options to turn off display of news/online/babblebox in towns.
- Added gameurl and adminemail fields to control table.
- Added ability to ban a user without deleting the account.
- Added rules for passwords (alphanumeric, maxlength=10).
- Added page where users can change their passwords.
- Added a page for lost passwords.
- Fixed bugs in users.php to use doquery() instead of mysql_query().
- Fixed bug in installer program when creating the admin user account.
- Changed the way towns and spells are handled in the user account.
- Removed some deprecated code from the onlinechar() function.
2017-02-05 10:58:20 -06:00

33 lines
2.0 KiB
PHP

<?php // heal.php :: Handles stuff from the Quick Spells menu. (Healing spells only... other spells are handled in fight.php.)
function healspells($id) {
global $userrow;
$userspells = explode(",",$userrow["spells"]);
$spellquery = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "spells");
$spellrow = mysql_fetch_array($spellquery);
// All the various ways to error out.
$spell = false;
foreach ($userspells as $a => $b) {
if ($b == $id) { $spell = true; }
}
if ($spell != true) { display("You have not yet learned this spell. Please go back and try again.", "Error"); die(); }
if ($spellrow["type"] != 1) { display("This is not a healing spell. Please go back and try again.", "Error"); die(); }
if ($userrow["currentmp"] < $spellrow["mp"]) { display("You do not have enough Magic Points to cast this spell. Please go back and try again.", "Error"); die(); }
if ($userrow["currentaction"] == "Fighting") { display("You cannot use the Quick Spells list during a fight. Please go back and select the Healing Spell you wish to use from the Spells box on the main fighting screen to continue.", "Error"); die(); }
if ($userrow["currenthp"] == $userrow["maxhp"]) { display("Your Hit Points are already full. You don't need to use a Healing spell now.", "Error"); die(); }
$newhp = $userrow["currenthp"] + $spellrow["attribute"];
if ($userrow["maxhp"] < $newhp) { $spellrow["attribute"] = $userrow["maxhp"] - $userrow["currenthp"]; $newhp = $userrow["currenthp"] + $spellrow["attribute"]; }
$newmp = $userrow["currentmp"] - $spellrow["mp"];
$updatequery = doquery("UPDATE {{table}} SET currenthp='$newhp', currentmp='$newmp' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
display("You have cast the ".$spellrow["name"]." spell, and gained ".$spellrow["attribute"]." Hit Points. You can now continue <a href=\"index.php\">exploring</a>.", "Healing Spell");
die();
}
?>