annotate materials/info.php @ 325:b65e0d6efe9d misc

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