Fix explore, refactor heal
This commit is contained in:
parent
b2ef29ca9c
commit
9df90861e2
|
@ -772,7 +772,7 @@ END;
|
|||
$class2name = $controlrow["class2name"];
|
||||
$class3name = $controlrow["class3name"];
|
||||
|
||||
$page = <<<END
|
||||
$page = <<<HTML
|
||||
<b><u>Edit Users</u></b><br /><br />
|
||||
<form action="admin.php?do=edituser:$id" method="post">
|
||||
<table width="90%">
|
||||
|
@ -846,7 +846,7 @@ $page = <<<END
|
|||
</table>
|
||||
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
|
||||
</form>
|
||||
END;
|
||||
HTML;
|
||||
|
||||
if ($row["authlevel"] == 0) { $row["auth0select"] = "selected=\"selected\" "; } else { $row["auth0select"] = ""; }
|
||||
if ($row["authlevel"] == 1) { $row["auth1select"] = "selected=\"selected\" "; } else { $row["auth1select"] = ""; }
|
||||
|
|
|
@ -15,12 +15,11 @@ function move()
|
|||
if (isset($_POST["east"])) { $longitude++; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } }
|
||||
if (isset($_POST["west"])) { $longitude--; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } }
|
||||
|
||||
$townquery = db()->query('SELECT id FROM towns WHERE latitude = ? AND longitude = ? LIMIT 1;', [$latitude, $longitude]);
|
||||
if ($townquery !== false) {
|
||||
$townrow = $townquery->fetchArray(SQLITE3_ASSOC);
|
||||
$town = get_town_by_xy($longitude, $latitude);
|
||||
if ($town !== false) {
|
||||
require_once __DIR__ . '/towns.php';
|
||||
travelto($townrow["id"], false);
|
||||
exit;
|
||||
travelto($town['id'], false);
|
||||
return;
|
||||
}
|
||||
|
||||
$chancetofight = rand(1, 5);
|
||||
|
|
29
src/heal.php
29
src/heal.php
|
@ -1,33 +1,28 @@
|
|||
<?php // heal.php :: Handles stuff from the Quick Spells menu. (Healing spells only... other spells are handled in fight.php.)
|
||||
<?php
|
||||
|
||||
function healspells($id) {
|
||||
// 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);
|
||||
$spellrow = get_spell($id);
|
||||
|
||||
// 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(); }
|
||||
foreach ($userspells as $b) if ($b == $id) $spell = true;
|
||||
if ($spell !== true) display("You have not yet learned this spell. Please go back and try again.", "Error");
|
||||
if ($spellrow["type"] != 1) display("This is not a healing spell. Please go back and try again.", "Error");
|
||||
if ($userrow["currentmp"] < $spellrow["mp"]) display("You do not have enough Magic Points to cast this spell. Please go back and try again.", "Error");
|
||||
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");
|
||||
if ($userrow["currenthp"] == $userrow["maxhp"]) display("Your Hit Points are already full. You don't need to use a Healing spell now.", "Error");
|
||||
|
||||
$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");
|
||||
db()->query('UPDATE users SET currenthp=?, currentmp=? WHERE id=?;', [$newhp, $newmp, $userrow['id']]);
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
?>
|
10
src/lib.php
10
src/lib.php
|
@ -293,3 +293,13 @@ function get_item(int $id): array|false
|
|||
if ($query === false) return false;
|
||||
return $query->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a spell by it's ID.
|
||||
*/
|
||||
function get_spell(int $id): array|false
|
||||
{
|
||||
$query = db()->query('SELECT * FROM spells WHERE id=? LIMIT 1;', [$id]);
|
||||
if ($query === false) return false;
|
||||
return $query->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user