diff --git a/TCEX.php b/TCEX.php new file mode 100644 index 0000000..2febcc8 --- /dev/null +++ b/TCEX.php @@ -0,0 +1,214 @@ +getMessage(); +} + +$query = "SELECT * FROM treasureclassex WHERE `Treasure Class` != ''"; +$res = array_filter(PDO_FetchAll($query)); + +$dropChances = []; + +foreach ($res as $r) { + $total = (int) $r['NoDrop']; + + for ($i = 1; $i <= 10; $i++) { + if (!empty($r["Item$i"])) { + $total += (int) $r["Prob$i"]; + $ic = $r["Item$i"]; + $prob = (int) $r["Prob$i"]; + $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); + } + } +} +header("Content-Type: text/html"); +?> + + + + Drop Chances Table + + + + + +

Drop Chances Calculator by HCB (Hash Borgir)

+
+ + + + + $row) { + $nodrop = $row['nodrop']; + echo ""; + echo ""; + echo ""; + foreach ($row['items'] as $item => $values) { + echo ""; + } + echo ""; + } + ?> + +
$treasureClass$nodrop% + + + + + + + + + + + + + +
codeprobchance
{$values["code"]}{$values["chance"]}%
+
+
+ + diff --git a/TCEX_Process.php b/TCEX_Process.php new file mode 100644 index 0000000..186eec7 --- /dev/null +++ b/TCEX_Process.php @@ -0,0 +1,77 @@ +escapeString($_POST['treasureClass']); +$noDrop = $db->escapeString($_POST['noDrop']); +$prob = []; +for ($i = 1; $i <= 10; $i++) { + $prob[$i] = isset($_POST["prob$i"]) ? $db->escapeString($_POST["prob$i"]) : 0; +} + +// Prepare the SQL UPDATE statement +$query = " + UPDATE treasureclassex + SET NoDrop = $noDrop, + Prob1 = {$prob[1]}, Prob2 = {$prob[2]}, Prob3 = {$prob[3]}, Prob4 = {$prob[4]}, + Prob5 = {$prob[5]}, Prob6 = {$prob[6]}, Prob7 = {$prob[7]}, Prob8 = {$prob[8]}, + Prob9 = {$prob[9]}, Prob10 = {$prob[10]} + WHERE `Treasure Class` = '$treasureClass' +"; + +// Execute the update statement +$result = $db->exec($query); + +if ($result) { + echo "Successfully updated!"; +} else { + echo "Failed to update! Error: " . $db->lastErrorMsg(); +} + + + +// Define the path to the TSV file +$tsvFilePath = $_SESSION['path'] . "/treasureclassex.txt"; + +// Open the file for writing +$fileHandle = fopen($tsvFilePath, 'w'); + +// Query to select all rows from the treasureclassex table +$query = "SELECT * FROM treasureclassex"; + +// Execute the query +$result = $db->query($query); + +// Write the column headers to the file +$columnNames = $result->numColumns(); +$headers = []; +for ($i = 0; $i < $columnNames; $i++) { + $headers[] = $result->columnName($i); +} +fputcsv($fileHandle, $headers, "\t"); + +// Write the rows to the file +while ($row = $result->fetchArray(SQLITE3_ASSOC)) { + fputcsv($fileHandle, $row, "\t"); +} + +// Close the file +fclose($fileHandle); + +echo "Successfully updated and written to TSV file!"; + +// Close the database connection +$db->close(); \ No newline at end of file diff --git a/TblEditorGUI.php b/TblEditorGUI.php index 8ce4862..e382bb3 100644 --- a/TblEditorGUI.php +++ b/TblEditorGUI.php @@ -155,19 +155,19 @@ foreach (glob($tbl . "*.tbl") as $filename) { // Initialize DataTables on the table $('.table').DataTable(); - // Resize textareas on page load - $('textarea').each(resizeTextarea); - - // Resize textareas on input - $('textarea').on('input', resizeTextarea); - - // Resize textareas on custom select change - $('.custom-select').change(function () { - $('textarea').each(resizeTextarea); - }); - $('.page-link').click(function () { - $('textarea').each(resizeTextarea); - }); +// // Resize textareas on page load +// $('textarea').each(resizeTextarea); +// +// // Resize textareas on input +// $('textarea').on('input', resizeTextarea); +// +// // Resize textareas on custom select change +// $('.custom-select').change(function () { +// $('textarea').each(resizeTextarea); +// }); +// $('.page-link').click(function () { +// $('textarea').each(resizeTextarea); +// }); }); }); } diff --git a/TblEditorGUI_TAB.php b/TblEditorGUI_TAB.php index 582cad7..3d0c96e 100644 --- a/TblEditorGUI_TAB.php +++ b/TblEditorGUI_TAB.php @@ -278,9 +278,9 @@ foreach (glob($tbl . "*.tbl") as $filename) { this.style.height = 'auto'; this.style.height = (this.scrollHeight) + 'px'; }); - setInterval(function () { - $('textarea').each(resizeTextarea); - }, 4000); +// setInterval(function () { +// $('textarea').each(resizeTextarea); +// }, 4000); }); @@ -297,10 +297,11 @@ foreach (glob($tbl . "*.tbl") as $filename) { width: 75px !important; } textarea { - overflow: hidden; - resize: none; - scrollbar-width: none; /* For Firefox */ - -ms-overflow-style: none; /* For Internet Explorer and Edge */ + min-height: 240px; + overflow: ; + resize: vertical; +/* scrollbar-width: none; For Firefox + -ms-overflow-style: none; For Internet Explorer and Edge */ } #loading-spinner { } diff --git a/config.php b/config.php index 29185e6..1d6e22a 100755 --- a/config.php +++ b/config.php @@ -45,7 +45,7 @@ ini_set('max_execution_time', '0'); */ $title = 'D2 Modder'; $author = " HashCasper"; -$version = 'v6.1 Alpha '; +$version = 'v7.0 Alpha '; define('APP_DB', "D2Modder.db"); diff --git a/img/chest.jpg b/img/chest.jpg new file mode 100644 index 0000000..e4703d8 Binary files /dev/null and b/img/chest.jpg differ diff --git a/img/chest.png b/img/chest.png new file mode 100644 index 0000000..6b20a33 Binary files /dev/null and b/img/chest.png differ diff --git a/src/D2Files.php b/src/D2Files.php index 9d54f8f..d5d4276 100755 --- a/src/D2Files.php +++ b/src/D2Files.php @@ -67,7 +67,7 @@ class D2Files { "cubemain.txt", // cubemain is processed manually in sqlite cli tool "misc.txt", // grew too large, process manually in processmanually function "treasureclass.txt", - "treasureclassex.txt" + //"treasureclassex.txt" ]; $glob = glob($_SESSION['path'] . '*.txt'); // Get a list of all ".txt" files in the specified path. diff --git a/src/head.php b/src/head.php index 1c553b1..f034bd7 100755 --- a/src/head.php +++ b/src/head.php @@ -71,7 +71,7 @@ - + D2Modder \ No newline at end of file diff --git a/src/tabs/Doc.php b/src/tabs/Doc.php index f6e4e26..1717bc6 100644 --- a/src/tabs/Doc.php +++ b/src/tabs/Doc.php @@ -31,6 +31,7 @@
+
diff --git a/src/tabs/TC.php b/src/tabs/TC.php new file mode 100644 index 0000000..da5da64 --- /dev/null +++ b/src/tabs/TC.php @@ -0,0 +1,59 @@ + +
+
+
+ +
+ +

TreasureClassEx.txt Drop Rates

+ +
+
\ No newline at end of file diff --git a/test.php b/test.php new file mode 100644 index 0000000..6934e33 --- /dev/null +++ b/test.php @@ -0,0 +1,150 @@ +getMessage(); +} + +$query = "SELECT * FROM treasureclassex WHERE `Treasure Class` != ''"; +$res = array_filter(PDO_FetchAll($query)); + +$dropChances = []; + +foreach ($res as $r) { + $total = (int) $r['NoDrop']; + + for ($i = 1; $i <= 10; $i++) { + if (!empty($r["Item$i"])) { + $total += (int) $r["Prob$i"]; // total will be denominator + + $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); + } + } +} + +?> + + + + + + Drop Chances 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"]}%
+
+ +