From 7b3869530f571dfcbd331b26912626a483abb735 Mon Sep 17 00:00:00 2001 From: Hash Borgir Date: Sun, 10 Sep 2023 02:04:02 -0600 Subject: [PATCH] levels parser started --- test.php | 199 +++++++++++++++++++++++++++---------------------------- 1 file changed, 96 insertions(+), 103 deletions(-) diff --git a/test.php b/test.php index 6934e33..b14356c 100644 --- a/test.php +++ b/test.php @@ -22,129 +22,122 @@ try { echo "Connection error: " . $e->getMessage(); } -$query = "SELECT * FROM treasureclassex WHERE `Treasure Class` != ''"; -$res = array_filter(PDO_FetchAll($query)); +$query = "SELECT Id,LevelName FROM levels"; +$levels = PDO_FetchAssoc($query); -$dropChances = []; +$query = "SELECT * FROM levels"; +$levelsAll = PDO_FetchAll($query); -foreach ($res as $r) { - $total = (int) $r['NoDrop']; +$query = "SELECT monstats.Id, strings.String AS Name +FROM monstats +LEFT JOIN strings ON monstats.NameStr = strings.Key;"; +$monstats = PDO_FetchAssoc($query); - for ($i = 1; $i <= 10; $i++) { - if (!empty($r["Item$i"])) { - $total += (int) $r["Prob$i"]; // total will be denominator +//ddump($monstats); - $ic = $r["Item$i"]; // get item code - $prob = (int) $r["Prob$i"]; - // now every item divided by denominator = dropchance - $dropChances[$r['Treasure Class']]["nd"] =$r['NoDrop']; - $dropChances[$r['Treasure Class']]["nodrop"] = round(((int) $r['NoDrop'] / $total) * 100, 2); - $dropChances[$r['Treasure Class']]["items"]["Item$i"]["code"] = $ic; - $dropChances[$r['Treasure Class']]["items"]["Item$i"]["prob"] = $prob; - $dropChances[$r['Treasure Class']]["items"]["Item$i"]["chance"] = round(($prob / $total) * 100, 2); +$query = "SELECT LevelName,Vis0,Vis1,Vis2,Vis3,Vis4,Vis5,Vis6,Vis7 FROM levels"; +$res = PDO_FetchAll($query); + +$output = []; + +foreach ($res as $key => $item) { + $newItem = []; + $newItem['LevelName'] = $item['LevelName']; // Copy the LevelName to new item + foreach ($levelsAll[$key] as $levelsKey => $levelsValue) { + //$newItem[$levelsKey] = isset($monstats[$levelsValue]) ? $monstats[$levelsValue] : $levelsValue; + } + + + $foundLevels = []; // Store found level names to avoid duplicates + + foreach ($item as $subKey => $subItem) { + // Check if the key starts with 'Vis', has a corresponding level, is non-empty, and is not a duplicate + if (strpos($subKey, 'Vis') === 0 && isset($levels[$subItem]) && $levels[$subItem] !== '' && !in_array($levels[$subItem], $foundLevels)) { + $newItem[$subKey] = "(" . $subItem . ") " . $levels[$subItem]; + $foundLevels[] = $levels[$subItem]; // Add to found levels } } + $output[] = array_filter($newItem); // Add the modified item to the output array } +unset($output[0]); + +ddump($output); ?> - - + - Drop Chances Table + + + Levels Table + + + -

Drop Chances Table

- - - - - - - - - - - - - - - - - - - $row) { - $nodrop = $row['nodrop']; // no drop chance - echo ""; - echo ""; - echo ""; - foreach ($row['items'] as $item => $values) { +"; - echo ""; - } - echo ""; - } - ?> - -
Treasure ClassNoDrop %Item1Item2Item3Item4Item5Item6Item7Item8Item9Item10
$treasureClassNoDrop : {$row["nd"]}
Chance: $nodrop
- - - - - - - - - - - - - -
codeprobchance
{$values["code"]}{$values["prob"]}{$values["chance"]}%
-
+// Display table headers with Bootstrap styling +$headers = ['Id', 'Name', 'LevelName', "", "", "", ""]; +for ($i = 0; $i < 8; $i++) { + $headers[] = "Vis" . $i; +} +for ($i = 1; $i <= 25; $i++) { + $headers[] = "mon" . $i; +} +$headers[] = 'MonDen'; + +echo ""; // Add thead and use Bootstrap dark theme +echo ""; +foreach ($headers as $header) { + echo "" . $header . ""; +} +echo ''; +echo ""; + +// Display table data with Bootstrap styling +echo ""; +foreach ($output as $level) { + echo ""; + foreach ($headers as $header) { + if (isset($level[$header])) { + echo "" . $level[$header] . ""; + } else { + echo ""; + } + } + echo ""; +} +echo ""; + +// End the HTML table +echo ""; +?> + + + + + + +