Mercurial > hg > batmud > misc
comparison materials/info.php @ 316:fedf17494a35 misc
Various cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 30 Dec 2015 06:58:48 +0200 |
parents | 7615bf7f980f |
children | 1f3fd2d0831b |
comparison
equal
deleted
inserted
replaced
315:72bf6267e34f | 316:fedf17494a35 |
---|---|
1 <? | 1 <? |
2 $pageTitle = "Pupunen BatMUD Alloy Browser"; | |
3 $pageIndex = "info.php"; | |
4 $people = ["Hair", "Malacoda", "Kiomet", "Aegenor", "Gileon", "Corto"]; | |
5 | |
6 $matTypeTable = [ | |
7 0 => ["Organic + cloth (sewing)", 0, 1], | |
8 1 => ["Wood + bone (carpentry)", 5, 3], | |
9 2 => ["Metal + alloy (blacksmithing)", 4, 7], | |
10 3 => ["Stone (masonry)", 6, -1], | |
11 4 => ["Gem (gemcutting)", 10, -1], | |
12 5 => ["Inorganic (sculpture)", 8, -1], | |
13 6 => ["Glass (glassblowing)", 9, -1], | |
14 | |
15 7 => ["Organic", 0, -1], | |
16 8 => ["Wood", 5, -1], | |
17 9 => ["Metal", 4, -1], | |
18 | |
19 10 => ["Cloth", -1, 1], | |
20 11 => ["Bone", -1, 3], | |
21 12 => ["Alloy", -1, 7], | |
22 ]; | |
23 | |
24 | |
25 require "mgeneric.inc.php"; | 2 require "mgeneric.inc.php"; |
26 require "materials.inc.php"; | 3 require "materials.inc.php"; |
27 require "alloys.inc.php"; | 4 require "alloys.inc.php"; |
28 | 5 |
6 $pageTitle = "Pupunen BatMUD Alloy Browser"; | |
7 $pageIndex = "info.php"; | |
8 | |
9 | |
10 $contributors = | |
11 [ | |
12 "Hair", "Malacoda", "Kiomet", "Aegenor", "Gileon", "Corto", | |
13 ]; | |
14 | |
15 | |
16 $matTypeTable = | |
17 [ | |
18 0 => ["Organic + cloth (sewing)" , 0, 1], | |
19 1 => ["Wood + bone (carpentry)" , 5, 3], | |
20 2 => ["Metal + alloy (blacksmithing)" , 4, 7], | |
21 3 => ["Stone (masonry)" , 6, -1], | |
22 4 => ["Gem (gemcutting)" , 10, -1], | |
23 5 => ["Inorganic (sculpture)" , 8, -1], | |
24 6 => ["Glass (glassblowing)" , 9, -1], | |
25 | |
26 7 => ["Organic" , 0, -1], | |
27 8 => ["Wood" , 5, -1], | |
28 9 => ["Metal" , 4, -1], | |
29 | |
30 10 => ["Cloth" , -1, 1], | |
31 11 => ["Bone" , -1, 3], | |
32 12 => ["Alloy" , -1, 7], | |
33 ]; | |
34 | |
35 | |
36 $matReliability = | |
37 [ | |
38 [ 1, 1, "1 test", "background: #a00; color: white;" ], | |
39 [ 2, 3, "2-3 tests", "background: #750; color: white;" ], | |
40 [ 4, 6, "4-6 tests", "background: #c90; color: black;", "color: black;" ], | |
41 [ 7, 9, "7-10 tests", "background: #080; color: white;" ], | |
42 [ 10, 9999, "10 or more", "background: #0c0; color: black;", "color: black;" ], | |
43 ]; | |
44 | |
29 | 45 |
30 function stGetMatLink($mat, $title = "", $extra = "") | 46 function stGetMatLink($mat, $title = "", $extra = "") |
31 { | 47 { |
32 $tmp = ($title != "") ? " title=\"".chentities($title)."\"" : ""; | 48 $tmp = ($title != "") ? " title=\"".chentities($title)."\"" : ""; |
33 return "<a href=\"/mat/".urlencode($mat)."\"".$tmp.">".chentities($mat)."</a>".$extra; | 49 return "<a href=\"/mat/".urlencode($mat)."\"".$tmp.">".chentities($mat)."</a>".$extra; |
34 } | 50 } |
35 | 51 |
36 | 52 |
37 $reliability = [ | 53 function stGetReliabilityStyle($n) |
38 [ 1, 1, "1 test", "background: #a00; color: white;" ], | 54 { |
39 [ 2, 4, "2-4 tests", "background: #750; color: white;" ], | 55 global $matReliability; |
40 [ 5, 9, "5-9 tests", "background: #c90; color: black;", "color: black;" ], | 56 foreach ($matReliability as $chk) |
41 [ 10, 19, "10-19 tests", "background: #080; color: white;" ], | |
42 [ 20, 1000, "20 or more", "background: #0c0; color: black;", "color: black;" ], | |
43 ]; | |
44 | |
45 | |
46 function stGetValueStyle($n) | |
47 { | |
48 global $reliability; | |
49 foreach ($reliability as $chk) | |
50 { | 57 { |
51 if ($n >= $chk[0] && $n <= $chk[1]) | 58 if ($n >= $chk[0] && $n <= $chk[1]) |
52 return " class=\"hits".$chk[0]."to".$chk[1]."\""; | 59 return " class=\"hits".$chk[0]."to".$chk[1]."\""; |
53 } | 60 } |
54 return ""; | 61 return ""; |
68 | 75 |
69 $setSwapRows = (isset($_GET["swap"]) && is_array($_GET["swap"])) ? $_GET["swap"] : array(); | 76 $setSwapRows = (isset($_GET["swap"]) && is_array($_GET["swap"])) ? $_GET["swap"] : array(); |
70 | 77 |
71 $extraCSS = []; | 78 $extraCSS = []; |
72 $extraInfo = []; | 79 $extraInfo = []; |
73 foreach ($reliability as $chk) | 80 foreach ($matReliability as $chk) |
74 { | 81 { |
75 $tmps = "hits".$chk[0]."to".$chk[1]; | 82 $tmps = "hits".$chk[0]."to".$chk[1]; |
76 $extraCSS[] = " td.".$tmps.", .".$tmps." { ".$chk[3]." }"; | 83 $extraCSS[] = " td.".$tmps.", .".$tmps." { ".$chk[3]." }"; |
77 if (isset($chk[4])) | 84 if (isset($chk[4])) |
78 $extraCSS[] = " td.".$tmps." a { ".$chk[4]." }"; | 85 $extraCSS[] = " td.".$tmps." a { ".$chk[4]." }"; |
104 " <li><b><a href=\"instructions.php\">Read this</a> for instructions on how you can collect and submit your own alloy research data.</b></li>\n". | 111 " <li><b><a href=\"instructions.php\">Read this</a> for instructions on how you can collect and submit your own alloy research data.</b></li>\n". |
105 " <li>Only 2-material alloys are supported by this browser.</li>\n". | 112 " <li>Only 2-material alloys are supported by this browser.</li>\n". |
106 " <li>There may be errors, and lots of combinations are not researched yet.</li>\n". | 113 " <li>There may be errors, and lots of combinations are not researched yet.</li>\n". |
107 " <li>The cell colour reflects how \"reliable\" the information is: ".implode(", ", $extraInfo).".</li>\n"; | 114 " <li>The cell colour reflects how \"reliable\" the information is: ".implode(", ", $extraInfo).".</li>\n"; |
108 | 115 |
109 if (isset($people) && count($people) > 0) | 116 if (isset($contributors) && count($contributors) > 0) |
110 { | 117 { |
111 $tmp = []; | 118 $tmp = []; |
112 foreach ($people as $key) | 119 foreach ($contributors as $key) |
113 $tmp[] = "<b>".$key."</b>"; | 120 $tmp[] = "<b>".$key."</b>"; |
114 echo " <li>Thanks to the following people for providing alloying data: ".join(", ", $tmp).".</li>\n"; | 121 echo " <li>Thanks to the following people for providing alloying data: ".join(", ", $tmp).".</li>\n"; |
115 } | 122 } |
116 | 123 |
117 echo | 124 echo |
247 | 254 |
248 foreach ($alloyTable[$setShowMat] as $key => $value) | 255 foreach ($alloyTable[$setShowMat] as $key => $value) |
249 { | 256 { |
250 if (list($a, $b) = each($value)) | 257 if (list($a, $b) = each($value)) |
251 { | 258 { |
252 echo "<td ".stGetValueStyle($b).">".stGetMatLink($a)."</td>"; | 259 echo "<td ".stGetReliabilityStyle($b).">".stGetMatLink($a)."</td>"; |
253 } | 260 } |
254 } | 261 } |
255 echo "</tr></table>\n"; | 262 echo "</tr></table>\n"; |
256 } | 263 } |
257 else | 264 else |
347 (count($tmp) > 1 ? " [UNSTABLE]" : "") | 354 (count($tmp) > 1 ? " [UNSTABLE]" : "") |
348 ); | 355 ); |
349 // , " <sup>".$b."</sup>"); | 356 // , " <sup>".$b."</sup>"); |
350 } | 357 } |
351 echo | 358 echo |
352 "<td".stGetValueStyle($value, count($tmp) > 1 ? " mitalic" : "").">". | 359 "<td".stGetReliabilityStyle($value, count($tmp) > 1 ? " mitalic" : "").">". |
353 join(" <span class=\"alternate\">/</span> ", $slist)."</td>"; | 360 join(" <span class=\"alternate\">/</span> ", $slist)."</td>"; |
354 } | 361 } |
355 else | 362 else |
356 echo "<td class=\"nohits\" title=\"Not researched\">?</td>"; | 363 echo "<td class=\"nohits\" title=\"Not researched\">?</td>"; |
357 | 364 |