Mercurial > hg > batmud > maputils
view www/quests.php @ 2775:2b85092046b8
Simplify quests page code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 13 Mar 2024 14:08:27 +0200 |
parents | e39dc8ee9e4a |
children |
line wrap: on
line source
<?php require "config.inc.php"; require "world.inc.php"; require "common.inc.php"; if (($hcbat = isset($_GET["hcbat"]))) { $locTable = array(); mpParseLocFile("hcbat", $locTable, FALSE, FALSE, 0); } else { $locTable = mpParseLocFiles(FALSE); } function printQuestData($name, &$area) { global $batQuestURL, $continentList, $hcbat; echo "<td><a href=\"".$batQuestURL.urlencode($name)."\">".chentities($name)."</a></td>". "<td class=\"".$area["continent"]."\">". mpGetMapLink($area, !isset($continentList[$area["continent"]]) || $continentList[$area["continent"]][CTI_HAS_MAP], TRUE, FALSE). "</td>". ($hcbat ? "" : "<td><a href=\"loc.php?n=".$area["continent"]."\">".$continentList[$area["continent"]][CTI_NAME]."</a></td>"); } // Create quest data tables $lqTable = array(); $aqTable = array(); foreach ($locTable as $loc) if (isset($loc["freeform"])) { if (preg_match_all("/LQ([0-9]+) *\"([^\"]+)\"/", $loc["freeform"], $matches, PREG_SET_ORDER)) { foreach ($matches as $key => $val) $lqTable[intval($val[1])][$val[2]] = $loc; } if (preg_match_all("/AQ *\"([^\"]+)\"/", $loc["freeform"], $matches, PREG_SET_ORDER)) { foreach ($matches as $key => $val) $aqTable[$val[1]] = $loc; } } ksort($lqTable, SORT_NUMERIC); ksort($aqTable, SORT_STRING); //======================================================================== mpPrintPageHeader($pageTitle." - Quests"); echo "<h1>BatMUD Quests</h1>\n". "\n". "<div class=\"attnbox\">\n". "<b>NOTICE!</b> The information herein may be considered as a mild \"spoiler\", ". "but I've made it available for the reason that some quest descriptions are rather ". "vague, confusing and in (rare) cases deprecated. <b>You should be aware that this list ". "does not include all quests and never will, for reasons both technical and ethical</b>. ". "Please refer to <a href=\"http://www.bat.org/help/quests\">the official BatMUD quest list</a> ". "for full details.\n". "</div>\n". "<div class=\"quests\">\n". " <h2>Level Quests (".count($lqTable).")</h2>\n". " <table class=\"locTable quests\">\n". " <tr>\n". " <th>Level</th>\n". " <th>Quest name</th>\n". " <th>Location</th>\n". ($hcbat ? "" : " <th>Continent</th>\n"). " </tr>\n"; foreach ($lqTable as $level => $quests) { foreach ($quests as $name => $area) { echo " <tr><td>".$level."</td>"; printQuestData($name, $area); echo "</tr>\n"; } } echo " </table>\n". " <p><b>".count($lqTable)."</b> level quests.</p>\n". "</div>\n". "<div class=\"quests\">\n". " <h2>Area Quests (".count($aqTable).")</h2>\n". " <table class=\"locTable quests\">\n". " <tr>\n". " <th>Quest name</th>\n". " <th>Location</th>\n". ($hcbat ? "" : " <th>Continent</th>\n"). " </tr>\n"; foreach ($aqTable as $name => $area) { echo " <tr>"; printQuestData($name, $area); echo "</tr>\n"; } echo " </table>\n". " <p><b>".count($aqTable)."</b> area quests.</p>\n". "</div>\n"; mpPrintPageFooter(); ?>