# HG changeset patch # User Matti Hamalainen # Date 1394663503 -7200 # Node ID 9aaabd02a0ed6154633f9bf6bf2fb7efe69c7e7f # Parent 4123ddac74e6f253af3b4074ec9dbe135d7ebb3d Fixes and cleanups. diff -r 4123ddac74e6 -r 9aaabd02a0ed index.php --- 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 "".$results[$resultTypes[$n][0]]." ".$resultTypes[$n][1]; + echo ($n < count($resultTypes) - 1) ? ", " : ".\n"; +} -echo "".$results["!"]." found potions, ". - "".$results["?"]." active partial matches, ". - "".$results["-"]." combinations eliminated, ". - "".$results["."]." combinations untested.\n". - "\n"; - - -echo "
Change index key to "; +echo + "
\n". + "
Change index key to "; foreach ($dbModes as $id => $data) echo "[".$data[2]."] "; echo "
\n"; @@ -445,16 +462,20 @@ if ($mode == "list") { $index = 0; - echo "

".$dbModes[$mode][0]." view (".$dbNames[$dbModes[$mode][1]][$active].")

- - - - - - - - - "; + echo + "

".$dbModes[$mode][0]." view (".$dbNames[$dbModes[$mode][1]][$active].")

\n". + "
#MineralOrganHerbPotion
\n". + " \n". + " \n"; + + foreach ($dbModes as $qmode => $qdata) + { + echo " \n"; + } + + echo + " \n"; + if ($active == 0) { for ($x = 0; $x < $dbDims[0]; $x++) @@ -501,15 +522,15 @@ ?>
#".$qdata[0]."
- - - - - - - - - + + + + + + + + +
Legend
 Not researched yet
-No match
-Marked to no potion by another no match.
-2 materials match, marked as no potion by another no match.
?2 materials match
!Accepted potion
 Known to be possible potion by other attempts
Legend
 Not researched yet
-No match
-Marked to no potion by another no match.
-2 materials match, marked as no potion by another no match.
?2 materials match
!Accepted potion
 Known to be possible potion by other attempts