Mercurial > hg > batmud > alchtool
changeset 71:9aaabd02a0ed
Fixes and cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 13 Mar 2014 00:31:43 +0200 |
parents | 4123ddac74e6 |
children | 201d2b850c52 |
files | index.php |
diffstat | 1 files changed, 53 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/index.php Thu Mar 13 00:10:05 2014 +0200 +++ b/index.php Thu Mar 13 00:31:43 2014 +0200 @@ -7,11 +7,20 @@ // Execution time measurement $tick = array_sum(explode(" ", microtime())); -if (!extension_loaded('gd')) { +if (!extension_loaded('gd')) +{ echo "Could not load extension GD!"; exit; } +$resultTypes = array( + array("!", "found potions"), + array("?", "active partial matches"), + array("-", "combinations eliminated"), + array(".", "combinations untested"), +); + + $dbModes = array( "min" => array("Mineral", 0, "minerals"), "org" => array("Organ", 1, "organs"), @@ -141,10 +150,15 @@ case "?": $class = ($r[1] == "*") ? "pairclose" : "close"; break; - case "-": if ($r[1] == "-") $class = "nomatch"; - else if ($r[1] == "*") $class = "pairno"; - else if ($r[1] !== "") $class = "noclose"; - else $class = "nomark"; + case "-": $class = "nomark"; + if (strlen($r) > 1) + { + if ($r[1] == "-") $class = "nomatch"; + else + if ($r[1] == "*") $class = "pairno"; + else + if ($r[1] !== "") $class = "noclose"; + } break; case ".": if ($r[1] == "*") $class = "pair"; @@ -424,20 +438,23 @@ // Calculate statistics $results = array(); +foreach ($resultTypes as $fdata) + $results[$fdata[0]] = 0; + for ($x = 0; $x < $dbDims[0]; $x++) for ($y = 0; $y < $dbDims[1]; $y++) for ($z = 0; $z < $dbDims[2]; $z++) $results[$db[$x][$y][$z][0]]++; +for ($n = 0; $n < count($resultTypes); $n++) +{ + echo "<b>".$results[$resultTypes[$n][0]]."</b> ".$resultTypes[$n][1]; + echo ($n < count($resultTypes) - 1) ? ", " : ".\n"; +} -echo "<b>".$results["!"]."</b> found potions, ". - "<b>".$results["?"]."</b> active partial matches, ". - "<b>".$results["-"]."</b> combinations eliminated, ". - "<b>".$results["."]."</b> combinations untested.\n". - "</div>\n"; - - -echo "<div id=\"controls\">Change index key to "; +echo + "</div>\n". + "<div id=\"controls\">Change index key to "; foreach ($dbModes as $id => $data) echo "[<a href=\"?".$id."=0\">".$data[2]."</a>] "; echo "</div>\n"; @@ -445,16 +462,20 @@ if ($mode == "list") { $index = 0; - echo "<h1>".$dbModes[$mode][0]." view (".$dbNames[$dbModes[$mode][1]][$active].")</h1> - <table class=\"potlist\"> - <tr> - <th>#</th> - <th><a href=\"?list=0\">Mineral</a></th> - <th><a href=\"?list=1\">Organ</a></th> - <th><a href=\"?list=2\">Herb</a></th> - <th><a href=\"?list=3\">Potion</a></th> - </tr> - "; + echo + "<h1>".$dbModes[$mode][0]." view (".$dbNames[$dbModes[$mode][1]][$active].")</h1>\n". + "<table class=\"potlist\">\n". + " <tr>\n". + " <th>#</th>\n"; + + foreach ($dbModes as $qmode => $qdata) + { + echo " <th><a href=\"?list=".$qdata[1]."\">".$qdata[0]."</a></th>\n"; + } + + echo + " </tr>\n"; + if ($active == 0) { for ($x = 0; $x < $dbDims[0]; $x++) @@ -501,15 +522,15 @@ ?> <table id="legend" border="1" cellspacing="1" onmouseover="vis();"> - <tr><th colspan="2" class="noframe">Legend</th></tr> - <tr><td width="10%" class="notres"> </td><th class="noframe">Not researched yet</th></tr> - <tr><td class="nomatch">-</td><th class="noframe">No match</th></tr> - <tr><td class="nomark">-</td><th class="noframe">Marked to no potion by another no match.</th></tr> - <tr><td class="noclose">-</td><th class="noframe">2 materials match, marked as no potion by another no match.</th></tr> - <tr><td class="close">?</td><th class="noframe">2 materials match</th></tr> - <tr><td class="accepted">!</td><th class="noframe">Accepted potion</th></tr> - <tr><td class="pair"> </td><th class="noframe">Known to be possible potion by other attempts</th></tr> - <tr><td colspan="2"><?php echo $progName." ".$progCopyright; ?></td></tr> + <tr><th colspan="2" class="noframe">Legend</th></tr> + <tr><td width="10%" class="notres"> </td><th class="noframe">Not researched yet</th></tr> + <tr><td class="nomatch">-</td><th class="noframe">No match</th></tr> + <tr><td class="nomark">-</td><th class="noframe">Marked to no potion by another no match.</th></tr> + <tr><td class="noclose">-</td><th class="noframe">2 materials match, marked as no potion by another no match.</th></tr> + <tr><td class="close">?</td><th class="noframe">2 materials match</th></tr> + <tr><td class="accepted">!</td><th class="noframe">Accepted potion</th></tr> + <tr><td class="pair"> </td><th class="noframe">Known to be possible potion by other attempts</th></tr> + <tr><td colspan="2"><?php echo $progName." ".$progCopyright; ?></td></tr> </table> <?php }