Finish updating the last links in fight to HTMX

This commit is contained in:
Sky Johnson 2024-12-19 10:09:06 -06:00
parent 35b0e07e4e
commit b8c3c96f8d

View File

@ -164,7 +164,7 @@ function fight()
if ($playerisdead != 1) {
$page["command"] = <<<HTML
Command?<br><br>
<form action="/fight" method="post">
<form action="/fight" method="post" hx-post="/fight" hx-target="#middle">
<input type="submit" name="fight" value="Fight"><br><br>
{$page['magiclist']}
<input type="submit" name="run" value="Run"><br><br>
@ -173,7 +173,11 @@ function fight()
user()->currentfight += 1;
} else {
$page["command"] = "<b>You have died.</b><br><br>As a consequence, you've lost half of your gold. However, you have been given back a portion of your hit points to continue your journey.<br><br>You may now continue back to <a href=\"/\">town</a>, and we hope you fair better next time.";
$page["command"] = <<<HTML
<b>You have died.</b><br><br>
As a consequence, you've lost half of your gold. However, you have been given back a portion of your hit points to continue your journey.<br><br>
You may now continue back to <a href="/" hx-get="/" hx-target="#middle">town</a>, and we hope you fair better next time.
HTML;
}
user()->save();
@ -226,7 +230,7 @@ function victory()
$spelltext = "You have learned a new spell.<br>";
} else { $spelltext = ""; $newspell=""; }
$page = "Congratulations. You have defeated the ".$monsterrow["name"].".<br>You gain $exp experience. $warnexp <br>You gain $gold gold. $warngold <br><br><b>You have gained a level!</b><br><br>You gain ".$levelrow[user()->charclass."_hp"]." hit points.<br>You gain ".$levelrow[user()->charclass."_mp"]." magic points.<br>You gain ".$levelrow[user()->charclass."_tp"]." travel points.<br>You gain ".$levelrow[user()->charclass."_strength"]." strength.<br>You gain ".$levelrow[user()->charclass."_dexterity"]." dexterity.<br>$spelltext<br>You can now continue <a href=\"/\">exploring</a>.";
$page = "Congratulations. You have defeated the ".$monsterrow["name"].".<br>You gain $exp experience. $warnexp <br>You gain $gold gold. $warngold <br><br><b>You have gained a level!</b><br><br>You gain ".$levelrow[user()->charclass."_hp"]." hit points.<br>You gain ".$levelrow[user()->charclass."_mp"]." magic points.<br>You gain ".$levelrow[user()->charclass."_tp"]." travel points.<br>You gain ".$levelrow[user()->charclass."_strength"]." strength.<br>You gain ".$levelrow[user()->charclass."_dexterity"]." dexterity.<br>$spelltext<br>You can now continue <a href=\"/\" hx-get=\"/\" hx-target=\"#middle\">exploring</a>.";
$title = "Courage and Wit have served thee well!";
$dropcode = "";
} else {
@ -235,10 +239,10 @@ function victory()
if (rand(1, 30) === 1) {
$droprow = db()->query('SELECT * FROM drops WHERE mlevel <= ? ORDER BY RANDOM() LIMIT 1;', [$monsterrow['level']])->fetchArray(SQLITE3_ASSOC);
$dropcode = "dropcode='".$droprow["id"]."',";
$page .= "This monster has dropped an item. <a href=\"/drop\">Click here</a> to reveal and equip the item, or you may also move on and continue <a href=\"/\">exploring</a>.";
$page .= "This monster has dropped an item. <a href=\"/drop\" hx-get=\"/drop\" hx-target=\"#middle\">Click here</a> to reveal and equip the item, or you may also move on and continue <a href=\"/\" hx-get=\"/\" hx-target=\"#middle\">exploring</a>.";
} else {
$dropcode = "";
$page .= "You can now continue <a href=\"/\">exploring</a>.";
$page .= 'You can now continue <a href="/" hx-get="/" hx-target="#middle">exploring</a>.';
}
$title = "Victory!";
@ -353,7 +357,7 @@ function drop()
$page .= "<br>Select an inventory slot from the list below to equip this item. If the inventory slot is already full, the old item will be discarded.";
$page .= "<form action=\"/drop\" method=\"post\"><select name=\"slot\"><option value=\"0\">Choose One</option><option value=\"1\">Slot 1: ".user()->slot1name."</option><option value=\"2\">Slot 2: ".user()->slot2name."</option><option value=\"3\">Slot 3: ".user()->slot3name."</option></select> <input type=\"submit\" name=\"submit\" value=\"Submit\" /></form>";
$page .= "You may also choose to just continue <a href=\"/\">exploring</a> and give up this item.";
$page .= "You may also choose to just continue <a href=\"/\" hx-get=\"/\" hx-target=\"#middle\">exploring</a> and give up this item.";
return is_htmx() ? $page : display($page, "Item Drop");
}
@ -365,7 +369,7 @@ function dead()
<b>You have died.</b><br><br>
As a consequence, you've lost half of your gold. However, you have been given back a portion of your hit points
to continue your journey.<br><br>
You may now continue back to <a href="/">town</a>, and we hope you fair better next time.
You may now continue back to <a href="/" hx-get="/" hx-target="#middle">town</a>, and we hope you fair better next time.
HTML;
return is_htmx() ? $page : display($page, 'You Died');
}