view www/quests.php @ 2769:e39dc8ee9e4a

Minor code cleanups, remove useless counting.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 13 Mar 2024 13:51:40 +0200
parents 0556b65f137b
children 2b85092046b8
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</h2>\n";

if (count($lqTable) > 0)
{
  echo
    " <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";
}
else
{
  echo " <p><b>No level quests known!</b></p>\n";
}

//========================================================================

echo
  "</div>\n".
  "<div class=\"quests\">\n".
  " <h2>Area Quests</h2>\n";

if (count($aqTable) > 0)
{
  echo
    " <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";
}
else
{
  echo " <p><b>No area quests known!</b></p>\n";
}
echo "</div>\n";

mpPrintPageFooter();
?>