Mercurial > hg > batmud > misc
annotate materials/info.php @ 327:fd471bd4e013 misc
Improve page HTML output cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 31 Dec 2015 03:02:17 +0200 |
parents | 03963c456ed8 |
children | 98c798a843ed |
rev | line source |
---|---|
250 | 1 <? |
325 | 2 // |
3 // BatMUD material alloy combo and material info viewer | |
4 // (C) Copyright 2009 - 2015 Matti 'ccr' Hämäläinen <ccr@tnsp.org> | |
5 // | |
316 | 6 require "mgeneric.inc.php"; |
7 require "materials.inc.php"; | |
8 require "alloys.inc.php"; | |
9 | |
250 | 10 $pageTitle = "Pupunen BatMUD Alloy Browser"; |
11 $pageIndex = "info.php"; | |
316 | 12 |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
13 |
326 | 14 // Static list of alloy data contributors |
316 | 15 $contributors = |
16 [ | |
17 "Hair", "Malacoda", "Kiomet", "Aegenor", "Gileon", "Corto", | |
313 | 18 ]; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
19 |
250 | 20 |
326 | 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) | |
316 | 24 $matTypeTable = |
25 [ | |
26 0 => ["Organic + cloth (sewing)" , 0, 1], | |
27 1 => ["Wood + bone (carpentry)" , 5, 3], | |
28 2 => ["Metal + alloy (blacksmithing)" , 4, 7], | |
29 3 => ["Stone (masonry)" , 6, -1], | |
30 4 => ["Gem (gemcutting)" , 10, -1], | |
31 5 => ["Inorganic (sculpture)" , 8, -1], | |
32 6 => ["Glass (glassblowing)" , 9, -1], | |
33 | |
34 7 => ["Organic" , 0, -1], | |
35 8 => ["Wood" , 5, -1], | |
36 9 => ["Metal" , 4, -1], | |
37 | |
38 10 => ["Cloth" , -1, 1], | |
39 11 => ["Bone" , -1, 3], | |
40 12 => ["Alloy" , -1, 7], | |
41 ]; | |
42 | |
43 | |
326 | 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. | |
316 | 48 $matReliability = |
49 [ | |
322
1f3fd2d0831b
Adjust threshold values for alloy tests.
Matti Hamalainen <ccr@tnsp.org>
parents:
316
diff
changeset
|
50 [ 1, 2, "1-2 tests", "background: #a00; color: white;" ], |
1f3fd2d0831b
Adjust threshold values for alloy tests.
Matti Hamalainen <ccr@tnsp.org>
parents:
316
diff
changeset
|
51 [ 3, 5, "3-5 tests", "background: #750; color: white;" ], |
1f3fd2d0831b
Adjust threshold values for alloy tests.
Matti Hamalainen <ccr@tnsp.org>
parents:
316
diff
changeset
|
52 [ 6, 9, "6-9 tests", "background: #c90; color: black;", "color: black;" ], |
1f3fd2d0831b
Adjust threshold values for alloy tests.
Matti Hamalainen <ccr@tnsp.org>
parents:
316
diff
changeset
|
53 [ 10, 9999, "10 or more", "background: #080; color: white;" ], |
316 | 54 ]; |
250 | 55 |
56 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
57 function stGetMatLink($mat, $title = "", $extra = "") |
250 | 58 { |
59 $tmp = ($title != "") ? " title=\"".chentities($title)."\"" : ""; | |
253
1eca10751695
Improve alloy browser output.
Matti Hamalainen <ccr@tnsp.org>
parents:
250
diff
changeset
|
60 return "<a href=\"/mat/".urlencode($mat)."\"".$tmp.">".chentities($mat)."</a>".$extra; |
250 | 61 } |
62 | |
63 | |
316 | 64 function stGetReliabilityStyle($n) |
250 | 65 { |
316 | 66 global $matReliability; |
67 foreach ($matReliability as $chk) | |
313 | 68 { |
69 if ($n >= $chk[0] && $n <= $chk[1]) | |
70 return " class=\"hits".$chk[0]."to".$chk[1]."\""; | |
71 } | |
72 return ""; | |
250 | 73 } |
74 | |
75 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
76 // |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
77 // Actual main code begins |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
78 // |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
79 $setShowOnly = intval(stGetRequestItem("o", 0, TRUE)); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
80 |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
81 if (isset($_GET["m"])) |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
82 { |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
83 $setShowMat = strtolower($_GET["m"]); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
84 $setShowMatName = strtoupper(substr($setShowMat,0,1)).substr($setShowMat, 1); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
85 } |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
86 |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
87 $setSwapRows = (isset($_GET["swap"]) && is_array($_GET["swap"])) ? $_GET["swap"] : array(); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
88 |
326 | 89 |
90 // Generate CSS and information snippets into temporary arrays | |
313 | 91 $extraCSS = []; |
92 $extraInfo = []; | |
316 | 93 foreach ($matReliability as $chk) |
313 | 94 { |
95 $tmps = "hits".$chk[0]."to".$chk[1]; | |
327
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
96 $extraCSS[] = " td.".$tmps.", .".$tmps." { ".$chk[3]." }"; |
313 | 97 if (isset($chk[4])) |
327
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
98 $extraCSS[] = " td.".$tmps." a { ".$chk[4]." }"; |
313 | 99 |
100 $extraInfo[] = "<span class=\"hits".$chk[0]."to".$chk[1]."\"><b>".$chk[2]."</b></span>"; | |
101 } | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
102 |
326 | 103 |
104 // | |
105 // Let's start pooping out the page | |
106 // | |
250 | 107 cmPrintPageHeader($pageTitle, " |
327
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
108 <meta name=\"robots\" content=\"nofollow\" /> |
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
109 <style type=\"text/css\"> |
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
110 span.alternate { color: red; font-weight: bold; } |
313 | 111 ".implode("\n", $extraCSS)." |
327
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
112 td.nohits, .nohits { background: black; } |
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
113 td.impossible { background: black; color: #f00; text-align: center; } |
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
114 </style> |
250 | 115 "); |
310 | 116 |
313 | 117 echo |
118 "<h1>".$pageTitle."</h1>\n". | |
119 "<form action=\"".$pageIndex."\" method=\"get\">\n". | |
120 "<table class=\"optionsTable\" width=\"100%\">\n". | |
121 " <tr>\n". | |
122 " <th width=\"25%\">Show type</th>\n". | |
123 " <td rowspan=\"3\" class=\"infobox\">\n". | |
124 " [<a href=\"".$pageIndex."\">Reset/Clear</a>] [<a href=\"index.php\">Material browser</a>]\n". | |
125 " <br />\n". | |
126 " <ul>\n". | |
127 " <li><b>Also available in <a href=\"alloys.txt\">ASCII plaintext format</a>.</b></li>\n". | |
128 " <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". | |
129 " <li>Only 2-material alloys are supported by this browser.</li>\n". | |
130 " <li>There may be errors, and lots of combinations are not researched yet.</li>\n". | |
314 | 131 " <li>The cell colour reflects how \"reliable\" the information is: ".implode(", ", $extraInfo).".</li>\n"; |
313 | 132 |
316 | 133 if (isset($contributors) && count($contributors) > 0) |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
134 { |
313 | 135 $tmp = []; |
316 | 136 foreach ($contributors as $key) |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
137 $tmp[] = "<b>".$key."</b>"; |
313 | 138 echo " <li>Thanks to the following people for providing alloying data: ".join(", ", $tmp).".</li>\n"; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
139 } |
310 | 140 |
141 echo | |
314 | 142 " </ul>\n". |
310 | 143 " </td>\n". |
144 " </tr>\n". | |
145 " <tr>\n". | |
146 " <td class=\"icenter\">\n". | |
147 " <select name=\"o\">\n"; | |
148 | |
326 | 149 // Output the type selectors |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
150 foreach ($matTypeTable as $key => $value) |
250 | 151 { |
255 | 152 $n = 0; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
153 foreach ($matDataTable as $name => $data) |
255 | 154 { |
155 if ($data[14] == $value[1] || $data[14] == $value[2]) | |
156 $n++; | |
157 } | |
158 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
159 $matTypeTable[$key][] = $n; |
255 | 160 |
161 printf( | |
162 " <option value=\"%s\"%s>%-30s [%d]</option>\n", | |
163 $key, | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
164 ($setShowOnly == $key ? " selected=\"selected\"" : ""), |
255 | 165 chentities($value[0]), $n); |
250 | 166 } |
167 | |
310 | 168 echo |
169 " </select>\n". | |
170 " </td>\n". | |
171 " </tr>\n". | |
172 " <tr>\n". | |
173 " <td class=\"icenter\"><input type=\"submit\" value=\" Filter \" class=\"isubmit\" /></td>\n". | |
174 " </tr>\n". | |
175 "</table>\n". | |
176 "</form>\n"; | |
177 | |
326 | 178 // |
179 // Now, act accordingly .. | |
180 // | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
181 if (isset($setShowMat)) |
250 | 182 { |
326 | 183 // |
184 // We are showing information about one specific material | |
185 // | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
186 if (!isset($matDataTable[$setShowMat])) |
250 | 187 { |
188 echo | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
189 "<h2>Error! No such material '".$setShowMatName."'</h2>\n". |
250 | 190 "<p>Material is not known. Check spelling.</p>\n"; |
191 } | |
192 else | |
193 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
194 echo "<h2>".$setShowMatName."</h2>\n". |
250 | 195 "<table width=\"95%\">\n". |
196 "<tr>"; | |
197 | |
198 $n = 0; | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
199 foreach ($matDataTable[$setShowMat] as $key => $val) |
250 | 200 { |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
201 echo "<th>".chentities($matTransNames[$key + 1])."</th><td>"; |
250 | 202 if (is_array($val)) |
203 { | |
313 | 204 $tmp = []; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
205 foreach ($val as $lode) |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
206 $tmp[] = chentities($matTransTable[$key][$lode]); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
207 echo join(", ", $tmp); |
250 | 208 } |
209 else | |
210 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
211 echo chentities($matTransTable[$key][$val]); |
250 | 212 } |
213 echo "</td>"; | |
214 if ($n++ >= 2) { echo "</tr>\n<tr>"; $n = 0; } | |
215 } | |
216 echo "</tr>\n</table>\n"; | |
217 | |
326 | 218 // |
219 // Show alloy combinations table for this material | |
220 // | |
250 | 221 echo "<h3>Alloy combinations</h3>\n"; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
222 if (isset($alloyRevTable[$setShowMat])) |
250 | 223 { |
224 echo "<ul>\n"; | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
225 foreach ($alloyRevTable[$setShowMat] as $mat => $value) |
250 | 226 { |
313 | 227 $tmp = []; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
228 foreach ($value as $qkey => $qval) |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
229 $tmp[] = stGetMatLink($qkey); |
250 | 230 |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
231 echo |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
232 " <li>".stGetMatLink($mat)." <b>+</b> ".join(" <b>|</b> ", $tmp). |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
233 "<b> = ".chentities($setShowMat)."</b></li>\n"; |
250 | 234 } |
291 | 235 echo |
236 "</ul>\n". | |
237 "<pre>\n". | |
238 "Syntax: <b>+</b> is AND, <b>|</b> is OR, e.g.:\n". | |
239 "<b>A + B = C</b> means A alloyed with B produces C.\n". | |
240 "<b>A + B | C = D</b> means A alloyed with B <b>or</b> C produces D.\n". | |
241 "</pre>\n"; | |
250 | 242 } |
243 else | |
244 { | |
326 | 245 // |
246 // No alloy combos known, show "generic" formula | |
247 // | |
250 | 248 echo "<p>No known alloy combinations.</p>\n"; |
249 } | |
250 | |
251 /* | |
313 | 252 $typeMats = []; |
309 | 253 foreach ($matDataTable as $name => $data) |
254 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
255 if ($data[14] == $matDataTable[$setShowMat][14] && $name != $setShowMat) |
250 | 256 $typeMats[] = $name; |
257 } | |
258 | |
309 | 259 echo "<p>Full mix: "; |
250 | 260 if (list($a, $b) = each($typeMats)) |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
261 echo stGetMatLink($b); |
250 | 262 |
263 while (list($a, $b) = each($typeMats)) | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
264 echo " <b>+</b> ".stGetMatLink($b); |
309 | 265 echo "</p>\n"; |
250 | 266 */ |
267 | |
268 echo "<h3>Mixtable</h3>\n"; | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
269 if (count($alloyTable[$setShowMat]) > 0) |
250 | 270 { |
271 echo | |
309 | 272 "<table class=\"matTable\">". |
273 " <tr>\n". | |
274 " <th>+</th>\n"; | |
275 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
276 foreach ($alloyTable[$setShowMat] as $key => $value) |
250 | 277 { |
327
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
278 echo " <th>".stGetMatLink($key)."</th>\n"; |
250 | 279 } |
309 | 280 |
281 echo | |
282 " </tr>\n". | |
327
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
283 " <tr>\n". |
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
284 " <th>".chentities($setShowMat)."</th>\n"; |
309 | 285 |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
286 foreach ($alloyTable[$setShowMat] as $key => $value) |
250 | 287 { |
309 | 288 if (list($a, $b) = each($value)) |
289 { | |
327
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
290 echo " <td".stGetReliabilityStyle($b).">".stGetMatLink($a)."</td>\n"; |
309 | 291 } |
250 | 292 } |
327
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
293 echo |
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
294 " </tr>\n". |
fd471bd4e013
Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
326
diff
changeset
|
295 "</table>\n"; |
250 | 296 } |
297 else | |
298 { | |
299 echo "<p>No mixtable entries.</p>\n"; | |
300 } | |
301 } | |
302 } | |
303 else | |
304 { | |
326 | 305 // |
306 // Print alloy table for given material type | |
307 // | |
250 | 308 // Filter table from maintable matching desired material type(s) |
313 | 309 $currTable = []; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
310 foreach ($matDataTable as $name => $data) |
250 | 311 { |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
312 if ($data[14] == $matTypeTable[$setShowOnly][1] || |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
313 $data[14] == $matTypeTable[$setShowOnly][2]) |
250 | 314 $currTable[] = $name; |
315 } | |
316 | |
317 // Swap desired rows | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
318 if (count($setSwapRows) > 0) |
250 | 319 { |
313 | 320 $str = []; |
250 | 321 $nkeys = count($currTable); |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
322 foreach ($setSwapRows as $from => $to) |
250 | 323 if ($from >= 0 && $from < $nkeys && $to >= 0 && $to < $nkeys && $to != $from) |
324 { | |
325 $str[] = $from." <=> ".$to; | |
326 | |
327 $tmp = $currTable[$from]; | |
328 $currTable[$from] = $currTable[$to]; | |
329 $currTable[$to] = $tmp; | |
330 } | |
309 | 331 |
250 | 332 if (count($str) > 0) |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
333 { |
250 | 334 echo "<p>Swapped rows: ".implode(", ", $str)."</p>\n"; |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
335 } |
250 | 336 } |
337 | |
338 // Print out the table | |
339 echo | |
340 "<table class=\"alloyTable\">". | |
341 " <tr>\n". | |
342 " <th>-</th>\n"; | |
343 | |
344 foreach ($currTable as $name) | |
345 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
346 echo " <th>".stGetMatLink($name)."</th>\n"; |
250 | 347 } |
348 echo " </tr>\n"; | |
349 | |
255 | 350 $researched = 0; |
351 $researchValue = 0; | |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
352 $total = 0; |
255 | 353 |
250 | 354 foreach ($currTable as $mat1) |
355 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
356 echo " <tr><th>".stGetMatLink($mat1)."</th>"; |
250 | 357 foreach ($currTable as $mat2) |
358 { | |
359 // Is the combo possible? | |
360 if ($mat1 != $mat2) | |
361 { | |
362 // Check for combination result | |
363 if (isset($alloyTable[$mat1][$mat2])) | |
364 $tmp = $alloyTable[$mat1][$mat2]; | |
365 else | |
366 if (isset($alloyTable[$mat2][$mat1])) | |
367 $tmp = $alloyTable[$mat2][$mat1]; | |
368 else | |
369 unset($tmp); | |
370 | |
371 if (isset($tmp)) | |
372 { | |
373 arsort($tmp); | |
374 $value = 0; | |
375 foreach ($tmp as $a => $b) | |
376 $value += $b; | |
377 | |
255 | 378 $researched++; |
379 $researchValue += $value; | |
380 | |
313 | 381 $slist = []; |
250 | 382 foreach ($tmp as $a => $b) |
383 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
384 $slist[] = stGetMatLink($a, |
250 | 385 $b." successful alloys (".$mat1." + ".$mat2." = ".$a.")". |
255 | 386 (count($tmp) > 1 ? " [UNSTABLE]" : "") |
387 ); | |
388 // , " <sup>".$b."</sup>"); | |
250 | 389 } |
390 echo | |
316 | 391 "<td".stGetReliabilityStyle($value, count($tmp) > 1 ? " mitalic" : "").">". |
250 | 392 join(" <span class=\"alternate\">/</span> ", $slist)."</td>"; |
393 } | |
394 else | |
395 echo "<td class=\"nohits\" title=\"Not researched\">?</td>"; | |
309 | 396 |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
397 $total++; |
250 | 398 } |
399 else | |
400 { | |
401 echo "<td class=\"impossible\" title=\"Impossible combination\">-</td>"; | |
402 } | |
403 } | |
404 echo "</tr>\n"; | |
405 } | |
255 | 406 |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
407 // |
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
408 // Calculate some statistics |
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
409 // |
309 | 410 $researchValue /= $researched * 15.0; |
411 if ($researchValue > 1.0) | |
412 $researchValue = 1.0; | |
413 | |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
414 $total /= 2; |
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
415 $researched /= 2; |
255 | 416 |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
417 printf( |
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
418 "</table>\n". |
255 | 419 "<div><b>%1.2f%%</b> (%d / %d) of combinations researched. ". |
420 "Estimating <b>%1.2f%%</b> overall accuracy.</div>\n", | |
421 ($researched * 100.0) / $total, $researched, $total, | |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
422 $researchValue * 100.0); |
250 | 423 } |
424 | |
425 cmPrintPageFooter(); | |
426 ?> |