changeset 23:652a6864d3ce misc

Added alloy.php, updated index.php.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 16 Apr 2009 22:31:21 +0000
parents 580e702a0e1a
children 4a28161cedc2
files materials/alloy.php materials/index.php
diffstat 2 files changed, 162 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/materials/alloy.php	Thu Apr 16 22:31:21 2009 +0000
@@ -0,0 +1,156 @@
+<?
+$pageTitle = "BatMUD Alloy Browser (ALPHA version)";
+$pageIndex = "alloy.php";
+require "materials.inc.php";
+require "alloys.inc.php";
+
+if (isset($_GET["o"]))
+  $showOnly = intval($_GET["o"]);
+else
+  $showOnly = 0;
+
+if (isset($_GET["m"])) {
+  $showMat = strtolower($_GET["m"]);
+  $showMatName = strtoupper(substr($showMat,0,1)).substr($showMat, 1);
+}
+
+require "../header.inc.php";
+?>
+<h1><? echo $pageTitle; ?></h1>
+<form action="<? echo $pageIndex; ?>" method="get">
+<table class="optionsTable" width="100%">
+ <tr>
+  <th width="25%">Show type</th>
+  <td rowspan="3" style="background: black; border: 1px solid white; color: red; padding: 8px;">
+   Only 2-material alloys are supported by this browser. It is known, that there are
+   at least SOME 3-material alloys, and naturally the "all but one" of given
+   material class combination.
+   There may be bugs and lots of combinations are not researched yet.
+   If you notice any inaccuracies, contact <b>Ggr</b>@Bat.
+  </td>
+ </tr>
+ <tr>
+  <td class="icenter">
+   <select name="o">
+<?
+$typeTable = $transTable[14];
+ksort($typeTable);
+reset($typeTable);
+$showOnlySet = FALSE;
+while (list($key, $value) = each($typeTable)) {
+  echo "    <option value=\"$key\"";
+  if ($showOnly == $key) {
+    echo " selected=\"selected\"";
+    $showOnlySet = TRUE;
+  }
+  echo ">".htmlentities($value)."</option>\n";
+}
+
+
+?>
+   </select>
+  </td>
+ </tr>
+ <tr>
+  <td class="icenter"><input type="submit" value=" Filter " class="isubmit" /></td>
+  <td></td>
+ </tr>
+</table>
+</form>
+<?
+function matLink($mat) {
+  return "<a href=\"?m=".urlencode($mat)."\">".htmlentities($mat)."</a>";
+}
+
+if (isset($showMat)) {
+  if (!isset($matTable[$showMat])) {
+    echo "<h2>Error! No such material '".$showMatName."'</h2>\n".
+    "<p>Material is not known. Check spelling.</p>\n";
+  } else {
+    echo "<h2>".$showMatName."</h2>\n".
+    "<table width=\"95%\">\n".
+    "<tr>";
+    $n = 0;
+    foreach ($matTable[$showMat] as $key => $val) {
+      echo "<th>".$transNameTable[$key+1]."</th><td>".$transTable[$key][$val]."</td>";
+      if ($n++ >= 2) { echo "</tr>\n<tr>"; $n = 0; }
+    }
+    
+    echo "</tr>\n</table>\n";
+    
+    echo "<h3>Alloy combinations</h3>\n";
+    if (isset($alloyRevTable[$showMat])) {
+      echo "<ul>\n";
+      foreach ($alloyRevTable[$showMat] as $mat1 => $value) {
+        echo " <li>".matLink($mat1)." <b>+</b> ";
+        reset($value);
+        if (list($a, $b) = each($value)) {
+          echo matLink($b);
+        }
+        
+        while (list($a, $b) = each($value)) {
+          echo " <b>|</b> ".matLink($b);
+        }
+        
+        echo "<b> = ".htmlentities($showMat)."</b></li>\n";
+      }
+      echo "</ul>\n";
+    } else {
+      echo "<p>No alloy combinations.</p>\n";
+    }
+
+    echo "<h3>Mixtable</h3>\n";
+    
+    if (count($alloyTable[$showMat]) > 0) {
+      echo
+      "<table class=\"matTable\">".
+      " <tr>\n".
+      "  <th>+</th>\n";
+      foreach ($alloyTable[$showMat] as $key => $value) {
+        echo "<th>".matLink($key)."</th>\n";
+      }
+      echo " </tr>\n".
+      " <tr><th>".htmlentities($showMat)."</th>";
+      foreach ($alloyTable[$showMat] as $key => $value) {
+        echo "<td>".matLink($value)."</td>";
+      }
+      echo "</tr></table>\n";
+    } else {
+    }
+  }
+} else {
+  $currTable = array();
+  foreach ($matTable as $key => $value) {
+    if ($value[14] == $showOnly)
+      $currTable[$key] = $value;
+  }
+
+  echo "<table class=\"matTable\">".
+  " <tr>\n".
+  "  <th>-</th>\n";
+  
+  foreach ($currTable as $key => $value) {
+    echo "<th>".matLink($key)."</th>\n";
+  }
+  echo " </tr>\n";
+
+  foreach ($currTable as $mat1 => $value) {
+    echo " <tr><th>".matLink($mat1)."</th>\n";
+    foreach ($currTable as $mat2 => $v) {
+      echo "<td>";
+      if (isset($alloyTable[$mat1][$mat2])) {
+        echo matLink($alloyTable[$mat1][$mat2]);
+      } else if (isset($alloyTable[$mat2][$mat1])) {
+        echo matLink($alloyTable[$mat2][$mat1]);
+      } else {
+        echo "-";
+      }
+      echo "</td>";
+    }  
+    echo "</tr>\n";
+  }
+  echo "</table>\n";
+}
+
+require "../footer.inc.php";
+?>
--- a/materials/index.php	Thu Apr 16 22:22:57 2009 +0000
+++ b/materials/index.php	Thu Apr 16 22:31:21 2009 +0000
@@ -1,6 +1,7 @@
 <?
-require "config.inc.php";
-require "material.inc.php";
+$pageTitle = "BatMUD Material Browser";
+$pageIndex = "index.php";
+require "materials.inc.php";
 
 $sortDirs = array("asc", "desc");
 
@@ -72,14 +73,13 @@
 require "../header.inc.php";
 ?>
 <h1><? echo $pageTitle; ?></h1>
-<form action="index.php" method="get">
+<form action="<? echo $pageIndex; ?>" method="get">
 <table class="optionsTable">
  <tr>
   <th>Hide columns</th>
   <th>Show only type</th>
   <td rowspan="3" style="background: black; border: 1px solid white; color: red;">
-   Please note, that this is BETA version. There may be bugs.
-   If you notice any persistent bugs, contact <b>Ggr</b>.
+   There may be bugs. If you notice any inaccuracies, contact <b>Ggr</b>@Bat.
    <ul>
     <li>You can sort by any column by clicking on the column name. Clicking again will change
     sorting direction (ascending/descending).</li>
@@ -177,7 +177,7 @@
     $col = 0;
     echo " <tr>";
     printTC("td", $col++);
-    echo htmlentities($key)."</td>";
+    echo "<a href=\"alloy.php?m=".urlencode($key)."\">".htmlentities($key)."</a></td>";
     
     while (list($kkey, $kvalue) = each($value)) {
       if (!isset($filterTable[$kkey+1])) {