changeset 316:fedf17494a35 misc

Various cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 30 Dec 2015 06:58:48 +0200
parents 72bf6267e34f
children a4dff42fc40e
files materials/info.php
diffstat 1 files changed, 44 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/materials/info.php	Wed Dec 30 06:58:07 2015 +0200
+++ b/materials/info.php	Wed Dec 30 06:58:48 2015 +0200
@@ -1,30 +1,46 @@
 <?
+require "mgeneric.inc.php";
+require "materials.inc.php";
+require "alloys.inc.php";
+
 $pageTitle = "Pupunen BatMUD Alloy Browser";
 $pageIndex = "info.php";
-$people = ["Hair", "Malacoda", "Kiomet", "Aegenor", "Gileon", "Corto"];
+
 
-$matTypeTable = [
-  0  => ["Organic + cloth (sewing)",      0, 1],
-  1  => ["Wood + bone (carpentry)",       5, 3],
-  2  => ["Metal + alloy (blacksmithing)", 4, 7],
-  3  => ["Stone (masonry)",               6, -1],
-  4  => ["Gem (gemcutting)",              10, -1],
-  5  => ["Inorganic (sculpture)",         8, -1],
-  6  => ["Glass (glassblowing)",          9, -1],
-
-  7  => ["Organic",                       0, -1],
-  8  => ["Wood",                          5, -1],
-  9  => ["Metal",                         4, -1],
-
-  10 => ["Cloth",                         -1, 1],
-  11 => ["Bone",                          -1, 3],
-  12 => ["Alloy",                         -1, 7],
+$contributors =
+[
+  "Hair", "Malacoda", "Kiomet", "Aegenor", "Gileon", "Corto",
 ];
 
 
-require "mgeneric.inc.php";
-require "materials.inc.php";
-require "alloys.inc.php";
+$matTypeTable =
+[
+  0  => ["Organic + cloth (sewing)"        ,  0,  1],
+  1  => ["Wood + bone (carpentry)"         ,  5,  3],
+  2  => ["Metal + alloy (blacksmithing)"   ,  4,  7],
+  3  => ["Stone (masonry)"                 ,  6, -1],
+  4  => ["Gem (gemcutting)"                , 10, -1],
+  5  => ["Inorganic (sculpture)"           ,  8, -1],
+  6  => ["Glass (glassblowing)"            ,  9, -1],
+
+  7  => ["Organic"                         ,  0, -1],
+  8  => ["Wood"                            ,  5, -1],
+  9  => ["Metal"                           ,  4, -1],
+
+  10 => ["Cloth"                           , -1,  1],
+  11 => ["Bone"                            , -1,  3],
+  12 => ["Alloy"                           , -1,  7],
+];
+
+
+$matReliability =
+[
+  [  1,    1, "1 test", "background: #a00; color: white;" ],
+  [  2,    3, "2-3 tests", "background: #750; color: white;" ],
+  [  4,    6, "4-6 tests", "background: #c90; color: black;", "color: black;" ],
+  [  7,    9, "7-10 tests", "background: #080; color: white;" ],
+  [ 10, 9999, "10 or more", "background: #0c0; color: black;", "color: black;" ],
+];
 
 
 function stGetMatLink($mat, $title = "", $extra = "")
@@ -34,19 +50,10 @@
 }
 
 
-$reliability = [
-  [  1,    1, "1 test", "background: #a00; color: white;" ],
-  [  2,    4, "2-4 tests", "background: #750; color: white;" ],
-  [  5,    9, "5-9 tests", "background: #c90; color: black;", "color: black;" ],
-  [ 10,   19, "10-19 tests", "background: #080; color: white;" ],
-  [ 20, 1000, "20 or more", "background: #0c0; color: black;", "color: black;" ],
-];
-
-
-function stGetValueStyle($n)
+function stGetReliabilityStyle($n)
 {
-  global $reliability;
-  foreach ($reliability as $chk)
+  global $matReliability;
+  foreach ($matReliability as $chk)
   {
     if ($n >= $chk[0] && $n <= $chk[1])
       return " class=\"hits".$chk[0]."to".$chk[1]."\"";
@@ -70,7 +77,7 @@
 
 $extraCSS = [];
 $extraInfo = [];
-foreach ($reliability as $chk)
+foreach ($matReliability as $chk)
 {
   $tmps = "hits".$chk[0]."to".$chk[1];
   $extraCSS[] = "   td.".$tmps.", .".$tmps." { ".$chk[3]." }";
@@ -106,10 +113,10 @@
   "    <li>There may be errors, and lots of combinations are not researched yet.</li>\n".
   "    <li>The cell colour reflects how \"reliable\" the information is: ".implode(", ", $extraInfo).".</li>\n";
 
-if (isset($people) && count($people) > 0)
+if (isset($contributors) && count($contributors) > 0)
 {
   $tmp = [];
-  foreach ($people as $key)
+  foreach ($contributors as $key)
     $tmp[] = "<b>".$key."</b>";
   echo "    <li>Thanks to the following people for providing alloying data: ".join(", ", $tmp).".</li>\n";
 }
@@ -249,7 +256,7 @@
       {
         if (list($a, $b) = each($value))
         {
-          echo "<td ".stGetValueStyle($b).">".stGetMatLink($a)."</td>";
+          echo "<td ".stGetReliabilityStyle($b).">".stGetMatLink($a)."</td>";
         }
       }
       echo "</tr></table>\n";
@@ -349,7 +356,7 @@
 //              , " <sup>".$b."</sup>");
           }
           echo
-            "<td".stGetValueStyle($value, count($tmp) > 1 ? " mitalic" : "").">".
+            "<td".stGetReliabilityStyle($value, count($tmp) > 1 ? " mitalic" : "").">".
             join(" <span class=\"alternate\">/</span> ", $slist)."</td>";
         }
         else