comparison materials/info.php @ 326:03963c456ed8 misc

Sprinkle in some comments.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 31 Dec 2015 03:00:50 +0200
parents b65e0d6efe9d
children fd471bd4e013
comparison
equal deleted inserted replaced
325:b65e0d6efe9d 326:03963c456ed8
9 9
10 $pageTitle = "Pupunen BatMUD Alloy Browser"; 10 $pageTitle = "Pupunen BatMUD Alloy Browser";
11 $pageIndex = "info.php"; 11 $pageIndex = "info.php";
12 12
13 13
14 // Static list of alloy data contributors
14 $contributors = 15 $contributors =
15 [ 16 [
16 "Hair", "Malacoda", "Kiomet", "Aegenor", "Gileon", "Corto", 17 "Hair", "Malacoda", "Kiomet", "Aegenor", "Gileon", "Corto",
17 ]; 18 ];
18 19
19 20
21 // Material type table for the type selector.
22 // Because some types are combinations, we need to have
23 // mappings for those (the last two columns)
20 $matTypeTable = 24 $matTypeTable =
21 [ 25 [
22 0 => ["Organic + cloth (sewing)" , 0, 1], 26 0 => ["Organic + cloth (sewing)" , 0, 1],
23 1 => ["Wood + bone (carpentry)" , 5, 3], 27 1 => ["Wood + bone (carpentry)" , 5, 3],
24 2 => ["Metal + alloy (blacksmithing)" , 4, 7], 28 2 => ["Metal + alloy (blacksmithing)" , 4, 7],
35 11 => ["Bone" , -1, 3], 39 11 => ["Bone" , -1, 3],
36 12 => ["Alloy" , -1, 7], 40 12 => ["Alloy" , -1, 7],
37 ]; 41 ];
38 42
39 43
44 // Define ranges for alloy tests' "reliability" based
45 // on how many tests have been performed. Define the
46 // lower and upper bound (inclusive), informative text
47 // and CSS style for those items.
40 $matReliability = 48 $matReliability =
41 [ 49 [
42 [ 1, 2, "1-2 tests", "background: #a00; color: white;" ], 50 [ 1, 2, "1-2 tests", "background: #a00; color: white;" ],
43 [ 3, 5, "3-5 tests", "background: #750; color: white;" ], 51 [ 3, 5, "3-5 tests", "background: #750; color: white;" ],
44 [ 6, 9, "6-9 tests", "background: #c90; color: black;", "color: black;" ], 52 [ 6, 9, "6-9 tests", "background: #c90; color: black;", "color: black;" ],
76 $setShowMatName = strtoupper(substr($setShowMat,0,1)).substr($setShowMat, 1); 84 $setShowMatName = strtoupper(substr($setShowMat,0,1)).substr($setShowMat, 1);
77 } 85 }
78 86
79 $setSwapRows = (isset($_GET["swap"]) && is_array($_GET["swap"])) ? $_GET["swap"] : array(); 87 $setSwapRows = (isset($_GET["swap"]) && is_array($_GET["swap"])) ? $_GET["swap"] : array();
80 88
89
90 // Generate CSS and information snippets into temporary arrays
81 $extraCSS = []; 91 $extraCSS = [];
82 $extraInfo = []; 92 $extraInfo = [];
83 foreach ($matReliability as $chk) 93 foreach ($matReliability as $chk)
84 { 94 {
85 $tmps = "hits".$chk[0]."to".$chk[1]; 95 $tmps = "hits".$chk[0]."to".$chk[1];
88 $extraCSS[] = " td.".$tmps." a { ".$chk[4]." }"; 98 $extraCSS[] = " td.".$tmps." a { ".$chk[4]." }";
89 99
90 $extraInfo[] = "<span class=\"hits".$chk[0]."to".$chk[1]."\"><b>".$chk[2]."</b></span>"; 100 $extraInfo[] = "<span class=\"hits".$chk[0]."to".$chk[1]."\"><b>".$chk[2]."</b></span>";
91 } 101 }
92 102
103
104 //
105 // Let's start pooping out the page
106 //
93 cmPrintPageHeader($pageTitle, " 107 cmPrintPageHeader($pageTitle, "
94 <meta name=\"robots\" content=\"nofollow\" /> 108 <meta name=\"robots\" content=\"nofollow\" />
95 <style type=\"text/css\"> 109 <style type=\"text/css\">
96 span.alternate { color: red; font-weight: bold; } 110 span.alternate { color: red; font-weight: bold; }
97 ".implode("\n", $extraCSS)." 111 ".implode("\n", $extraCSS)."
130 " </tr>\n". 144 " </tr>\n".
131 " <tr>\n". 145 " <tr>\n".
132 " <td class=\"icenter\">\n". 146 " <td class=\"icenter\">\n".
133 " <select name=\"o\">\n"; 147 " <select name=\"o\">\n";
134 148
149 // Output the type selectors
135 foreach ($matTypeTable as $key => $value) 150 foreach ($matTypeTable as $key => $value)
136 { 151 {
137 $n = 0; 152 $n = 0;
138 foreach ($matDataTable as $name => $data) 153 foreach ($matDataTable as $name => $data)
139 { 154 {
158 " <td class=\"icenter\"><input type=\"submit\" value=\" Filter \" class=\"isubmit\" /></td>\n". 173 " <td class=\"icenter\"><input type=\"submit\" value=\" Filter \" class=\"isubmit\" /></td>\n".
159 " </tr>\n". 174 " </tr>\n".
160 "</table>\n". 175 "</table>\n".
161 "</form>\n"; 176 "</form>\n";
162 177
178 //
179 // Now, act accordingly ..
180 //
163 if (isset($setShowMat)) 181 if (isset($setShowMat))
164 { 182 {
183 //
184 // We are showing information about one specific material
185 //
165 if (!isset($matDataTable[$setShowMat])) 186 if (!isset($matDataTable[$setShowMat]))
166 { 187 {
167 echo 188 echo
168 "<h2>Error! No such material '".$setShowMatName."'</h2>\n". 189 "<h2>Error! No such material '".$setShowMatName."'</h2>\n".
169 "<p>Material is not known. Check spelling.</p>\n"; 190 "<p>Material is not known. Check spelling.</p>\n";
192 echo "</td>"; 213 echo "</td>";
193 if ($n++ >= 2) { echo "</tr>\n<tr>"; $n = 0; } 214 if ($n++ >= 2) { echo "</tr>\n<tr>"; $n = 0; }
194 } 215 }
195 echo "</tr>\n</table>\n"; 216 echo "</tr>\n</table>\n";
196 217
218 //
219 // Show alloy combinations table for this material
220 //
197 echo "<h3>Alloy combinations</h3>\n"; 221 echo "<h3>Alloy combinations</h3>\n";
198 if (isset($alloyRevTable[$setShowMat])) 222 if (isset($alloyRevTable[$setShowMat]))
199 { 223 {
200 echo "<ul>\n"; 224 echo "<ul>\n";
201 foreach ($alloyRevTable[$setShowMat] as $mat => $value) 225 foreach ($alloyRevTable[$setShowMat] as $mat => $value)
216 "<b>A + B | C = D</b> means A alloyed with B <b>or</b> C produces D.\n". 240 "<b>A + B | C = D</b> means A alloyed with B <b>or</b> C produces D.\n".
217 "</pre>\n"; 241 "</pre>\n";
218 } 242 }
219 else 243 else
220 { 244 {
245 //
246 // No alloy combos known, show "generic" formula
247 //
221 echo "<p>No known alloy combinations.</p>\n"; 248 echo "<p>No known alloy combinations.</p>\n";
222 } 249 }
223 250
224 /* 251 /*
225 $typeMats = []; 252 $typeMats = [];
270 } 297 }
271 } 298 }
272 } 299 }
273 else 300 else
274 { 301 {
275 /* 302 //
276 * Print alloy table for given material type 303 // Print alloy table for given material type
277 */ 304 //
278 // Filter table from maintable matching desired material type(s) 305 // Filter table from maintable matching desired material type(s)
279 $currTable = []; 306 $currTable = [];
280 foreach ($matDataTable as $name => $data) 307 foreach ($matDataTable as $name => $data)
281 { 308 {
282 if ($data[14] == $matTypeTable[$setShowOnly][1] || 309 if ($data[14] == $matTypeTable[$setShowOnly][1] ||
302 if (count($str) > 0) 329 if (count($str) > 0)
303 { 330 {
304 echo "<p>Swapped rows: ".implode(", ", $str)."</p>\n"; 331 echo "<p>Swapped rows: ".implode(", ", $str)."</p>\n";
305 } 332 }
306 } 333 }
307
308 334
309 // Print out the table 335 // Print out the table
310 echo 336 echo
311 "<table class=\"alloyTable\">". 337 "<table class=\"alloyTable\">".
312 " <tr>\n". 338 " <tr>\n".