cube render 95% done. todo: group descfunc, cleanups

This commit is contained in:
color.diff=auto
2021-05-12 02:53:05 -06:00
parent babfe5b0dd
commit ca04aa615f
2460 changed files with 26729 additions and 223 deletions

View File

@@ -1,4 +1,5 @@
<?php
error_reporting(E_ERROR | E_PARSE);
set_time_limit(-1);
ini_set('max_input_time', '-1');
@@ -48,6 +49,12 @@ ob_start();
*/
require_once './config.php';
require_once './_pdo.php';
require_once './src/D2ItemData.php';
require_once './src/D2ItemDesc.php';
$idata = new D2ItemData();
$idesc = new D2ItemDesc();
define('DB_FILE', $_SESSION['modname'] . ".db");
PDO_Connect("sqlite:" . DB_FILE);
@@ -68,8 +75,30 @@ if ($cmd == 'genDocUniqueItems') {
$type = "Unique Items";
$align = 'center';
}
$sql = "SELECT p.`code` as prop,
p.stat1,
i.descstrpos,
i.descstr2,
i.descfunc,
i.descval,
s1.String as string1,
s2.String as string2
FROM properties as p
LEFT JOIN itemstatcost as i
ON p.stat1 = i.Stat
LEFT JOIN strings as s1
ON i.descstrpos = s1.Key
LEFT JOIN strings as s2
ON i.descstr2 = s2.Key";
$res = PDO_FetchAll($sql);
$isc = null;
foreach ($res as $r) {
$isc[$r['prop']] = $r;
$isc[$r['prop']]['prop'] = $r['prop'];
}
$htmltop = <<<EOT
<!doctype html>
<html lang="en">
@@ -134,7 +163,7 @@ $htmltop = <<<EOT
$(document).ready(function() {
$('.cubetable').dataTable();
// $('.cubetable').dataTable();
} );
@@ -145,7 +174,7 @@ $(document).ready(function() {
</head>
<body>
<div class="container container-top">
<div class="">
<h1>{$_SESSION['modname']} $type</h1>
<p>Auto generated with D2Modder by Hash Casper</p>
@@ -171,7 +200,9 @@ EOT;
*
*
*/
$dir = getcwd() . "/docs/{$_SESSION['modname']}";
mkdir($dir, 0777, true);
if ($cmd == "genDocUniqueItems") {
// grab unique item index only (to save on memory)
@@ -187,10 +218,6 @@ if ($cmd == "genDocUniqueItems") {
echo $htmltop;
ob_flush();
$dir = getcwd() . "/docs/{$_SESSION['modname']}";
mkdir($dir, 0777, true);
/*
START MAIN LOOP HERE
*
@@ -332,21 +359,24 @@ function getItemName($code) {
}
if ($cmd == "genDocCube") {
$htmlFinal = '';
$htmlFinal .= $htmltop;
echo $htmltop;
echo <<<EOT
ob_flush();
$css = <<<EOT
<style>
body{
background: white;
color: black;
font-family: ExocetLight;
text-transform: uppercase;
}
table, table th, table td, table tr {
background: #000;
background: #111;
color: #ccc;
}
@@ -378,20 +408,26 @@ if ($cmd == "genDocCube") {
}
table {
font-family: Lato;
}
.desc {
width: 25%;
font-family: ExocetHeavy;
font-size: 1.25em;
}
td {
width: 200px;
width: auto;
text-align: center;
vertical-align: top;
vertical-align: middle;
padding: 10px;
}
</style>
EOT;
echo <<<EOT
echo $css;
$htmlFinal .= $css;
ob_flush();
$table = <<<EOT
<table border=1 class="cubetable">
<thead>
<tr>
@@ -409,29 +445,30 @@ EOT;
</tr>
</thead>
<tbody>
EOT;
$item_quality_params = [
"any" => "Any item (*Not Advised)",
"low" => "low quality",
"hiq" => "superior",
echo $table;
$htmlFinal .= $table;
ob_flush();
$i_params = [
"any" => "Any Item",
"low" => "Low Quality",
"hiq" => "Superior",
"nor" => "Normal",
"mag" => "Magic",
"rar" => "Rare",
"set" => "Set",
"uni" => "Unique",
"crf" => "Crafted",
"tmp" => "Tempered",
"eth" => "Ethereal",
"noe" => "Not Ethereal",
"mag" => "<span class='blue'>Magic<span>",
"rar" => "<span class='yellow'>Rare<span>",
"set" => "<span class='green'>Set<span>",
"uni" => "<span class='gold'>Unique<span>",
"crf" => "<span class='orange'>Crafted<span>",
"tmp" => "<span class='orange'>Tempered<span>",
"eth" => "<span style='color: #ccc;'>Ethereal<span>",
"noe" => "<span style='color: #ccc;'>Not Ethereal<span>",
"nos" => "No Socket (for input)",
"sock" => "# sockets (eg: sock=>4)",
"sock" => "Sockets",
"pre" => "Prefix (ID from magicprefix.txt) - ID => (Row Number - 2)",
"suf" => "Suffix (ID from magicsuffix.txt) - ID => (Row Number - 2)",
"rep" => "Repair durability",
"rch" => "Recharge Quantity",
"qty" => 'amount of same item(eg: "hpot, qty => 3" means 3 hp potions)',
"qty" => 'Quantity',
"upg" => "For inputs only, Item is upgraded.",
"bas" => "Base item",
"exc" => "Exceptional",
@@ -445,7 +482,7 @@ EOT;
];
// get all cube rows
$sql = "SELECT * FROM cubemain WHERE enabled=1 LIMIT 1500";
$sql = "SELECT * FROM cubemain WHERE enabled=1";
$res = PDO_FetchAll($sql);
/*
@@ -455,7 +492,6 @@ EOT;
*
*/
foreach ($res as $r) {
$desc = $r['description'];
//var_dump($r);
@@ -562,7 +598,14 @@ EOT;
$output_codes[$outputNum] = explode(",", $value); // hpot,qty=3
$oarray = explode(",", $value); // hpot,qty=3
$sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
// clean str
$str = PDO_FetchOne($sql);
if(str_contains($str, "ÿc")){
$p = "/ÿc[\d:;\/.]/i";
$str = preg_replace($p, "", $str);
}
// if empty str == 4-letter code, so just display
if (empty($str)) {
@@ -578,8 +621,18 @@ EOT;
$output_codes[$outputNum] = explode(",", $value); // hpot,qty=3
$oarray = explode(",", $value); // hpot,qty=3
$sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
// clean color codes
$str = PDO_FetchOne($sql);
if(str_contains($str, "ÿc")){
$p = "/ÿc[\d:;\/.]/i";
$str = preg_replace($p, "", $str);
}
// if empty str == 4-letter code, so just display
if (empty($str)) {
$output_codes[$outputNum][0] = ($oarray[0]);
@@ -652,6 +705,9 @@ EOT;
*
*/
$m = null;
for ($counter = 1; $counter <= 5; $counter++) {
@@ -677,6 +733,39 @@ EOT;
}
$output['mods'] = array_filter($m);
$result = [];
//var_dump($output['mods']);
foreach ($output['mods'] as $k => $v) {
$prop = ($v["mod " . $k + 1]);
$par = ($v["mod " . $k + 1 . " param"]) ?? "";
$min = ($v["mod " . $k + 1 . " min"]) ?? $max;
$max = ($v["mod " . $k + 1 . " max"]) ?? $min;
//var_dump($min);
$output['mods'][$k]["isc"] = $isc[$prop];
$params = [
'string1' => $output['mods'][$k]["isc"]['string1'],
'string2' => $output['mods'][$k]["isc"]['string2'],
'descfunc' => $output['mods'][$k]["isc"]['descfunc'],
'descval' => $output['mods'][$k]["isc"]['descval'],
"prop" => $prop,
"par" => $par,
"min" => $min,
"max" => $max,
// "val1" => $funcval['val1'],
// "func1" => $funcval['func1']
// 'item' => $return
];
$output['mods'][$k]["str"] = $idesc->getDesc($params);
//var_dump($output['mods'][$k]["isc"]);
}
//ddump($idata->getIscStrings("energy"));
/*
* Echo out each row as HTML with all the data it may have
*
@@ -698,171 +787,211 @@ EOT;
// }
// }
// echo "</tr>";
?>
<tr>
<td class="desc">
<?php echo $output['desc'] ?>
</td>
<td class="input1">
<?php
if (!empty($output["input 1"]["img"])) {
echo "<img src='/img/items/{$output["input 1"]["img"]}'><br>";
$htmlRow = "<tr>";
$htmlRow .= "<td class='desc'>" . $output['desc'] . "</td>";
for ($i = 1; $i <= 7; $i++) {
$htmlRow .= "<td class='input$i'>";
if (!empty($output["input $i"]["img"])) {
$htmlRow .= "<img src='img/items/{$output["input $i"]["img"]}'><br>";
if(str_contains($output["input $i"][0], "ÿc")){
$p = "/ÿc[\d:;\/.]/i";
$output["input $i"][0] = preg_replace($p, "", $output["input $i"][0]);
}
$ostr = implode("<br>", (array_reverse(explode('\n', $output["input $i"][0]))));
$htmlRow .= $ostr."<br>";
if (str_contains($output["input $i"][1], "=")) {
$htmlRow .= $output["input $i"][1]."<br>";
} else {
$htmlRow .= $i_params[$output["input $i"][1]]."<br>";
}
}
$htmlRow .= "</td>";
}
$htmlRow .= "<td class='output1'>";
if (!empty($output["output"]["img"])) {
$htmlRow .= "<img src='img/items/{$output["output"]["img"]}'><br>";
if(str_contains($output["output"][0], "ÿc")){
$p = "/ÿc[\d:;\/.]/i";
$output["output"][0] = preg_replace($p, "", $output["output"][0]);
}
if(str_contains($output["output"][1], "ÿc")){
$p = "/ÿc[\d:;\/.]/i";
$output["output"][1] = preg_replace($p, "", $output["output"][1]);
}
if ($i_params[$output["output"][0]]) {
$htmlRow .= '<span style="color: #AF833B;">'.$output["output"][0]."</span><br>";
} else {
$htmlRow .= $output["output"][0]."<br>";
}
if ($i_params[$output["output"][1]]) {
$htmlRow .= $i_params[$output["output"][1]]."<br>";
} else {
$htmlRow .= $output["output"][1]."<br>";
}
for ($i = 1; $i <= 5; $i++) {
if ($output["mods"][0]["mod $i"]) {
if(str_contains($output["mods"][0]["str"], "ÿc")){
$p = "/ÿc[\d:;\/.]/i";
$output["mods"][0]["str"] = preg_replace($p, "", $output["mods"][0]["str"]);
}
$htmlRow .= str_replace("\n", "<br>", "<span class='blue'>{$output["mods"][0]["str"]}</span><br><br>");
}
?>
<?php echo $output["input 1"][0] ?><br>
<?php echo $output["input 1"][1] ?><br>
</td>
<td class="input2">
<?php
if (!empty($output["input 2"]["img"])) {
echo "<img src='/img/items/{$output["input 2"]["img"]}'><br>";
if ($output["mods"][0]["mod $i chance"]) {
$htmlRow .= "<span style='color: #FFA500'>Chance:{$output["mods"][0]["mod $i chance"]}</span><br>";
}
?>
<?php echo $output["input 2"][0] ?><br>
<?php echo $output["input 2"][1] ?><br>
</td>
<td class="input3">
<?php
if (!empty($output["input 3"]["img"])) {
echo "<img src='/img/items/{$output["input 3"]["img"]}'><br>";
// if ($output["mods"][0]["mod $i min"]) {
// $htmlRow .= "Min:{$output["mods"][0]["mod $i min"]}<br>";
// }
// if ($output["mods"][0]["mod $i max"]) {
// $htmlRow .= "Max:{$output["mods"][0]["mod $i max"]}";
// }
}
}
$htmlRow .= "</td>";
$htmlRow .= "<td class='output2'>";
if (!empty($output["output 2"]["img"])) {
$htmlRow .= "<img src='img/items/{$output["output 2"]["img"]}'><br>";
if(str_contains($output["output b"][0], "ÿc")){
$p = "/ÿc[\d:;\/.]/i";
$output["output b"][0] = preg_replace($p, "", $output["output b"][0]);
}
if(str_contains($output["output b"][1], "ÿc")){
$p = "/ÿc[\d:;\/.]/i";
$output["output b"][1] = preg_replace($p, "", $output["output b"][1]);
}
$htmlRow .= $output["output b"][0]."<br>";
$htmlRow .= $output["output b"][1]."<br>";
for ($i = 1; $i <= 5; $i++) {
if ($output["mods"][1]["mod $i"]) {
$htmlRow .= "{$output["mods"][1]["mod $i"]}<br>";
}
?>
<?php echo $output["input 3"][0] ?><br>
<?php echo $output["input 3"][1] ?><br>
</td>
<td class="input4">
<?php
if (!empty($output["input 4"]["img"])) {
echo "<img src='/img/items/{$output["input 4"]["img"]}'><br>";
if ($output["mods"][1]["mod $i chance"]) {
$htmlRow .= "Chance:{$output["mods"][1]["mod $i chance"]}<br>";
}
?>
<?php echo $output["input 4"][0] ?><br>
<?php echo $output["input 4"][1] ?><br>
</td>
<td class="input5">
<?php
if (!empty($output["input 5"]["img"])) {
echo "<img src='/img/items/{$output["input 5"]["img"]}'><br>";
if ($output["mods"][1]["mod $i min"]) {
$htmlRow .= "Min:{$output["mods"][1]["mod $i min"]}<br>";
}
?>
<?php echo $output["input 5"][0] ?><br>
<?php echo $output["input 5"][1] ?><br>
</td>
<td class="input6">
<?php
if (!empty($output["input 6"]["img"])) {
echo "<img src='/img/items/{$output["input 6"]["img"]}'><br>";
if ($output["mods"][1]["mod $i max"]) {
$htmlRow .= "Max:{$output["mods"][1]["mod $i max"]}";
}
?>
<?php echo $output["input 6"][0] ?><br>
<?php echo $output["input 6"][1] ?><br>
</td>
<td class="input7">
<?php
if (!empty($output["input 7"]["img"])) {
echo "<img src='/img/items/{$output["input 7"]["img"]}'><br>";
}
}
$htmlRow .= "</td>";
$htmlRow .= "<td class='output3'>";
if (!empty($output["output 3"]["img"])) {
$htmlRow .= "<img src='img/items/{$output["output 3"]["img"]}'><br>";
if(str_contains($output["output c"][0], "ÿc")){
$p = "/ÿc[\d:;\/.]/i";
$output["output c"][0] = preg_replace($p, "", $output["output c"][0]);
}
if(str_contains($output["output c"][1], "ÿc")){
$p = "/ÿc[\d:;\/.]/i";
$output["output c"][1] = preg_replace($p, "", $output["output c"][1]);
}
$htmlRow .= $output["output c"][0]."<br>";
$htmlRow .= $output["output c"][1]."<br>";
for ($i = 1; $i <= 5; $i++) {
if ($output["mods"][2]["mod $i"]) {
$htmlRow .= "{$output["mods"][2]["mod $i"]}<br>";
}
?>
<?php echo $output["input 7"][0] ?><br>
<?php echo $output["input 7"][1] ?><br>
</td>
<td class="output1">
<?php
if (!empty($output["output"]["img"])) {
echo "<img src='/img/items/{$output["output"]["img"]}'>";
if ($output["mods"][2]["mod $i chance"]) {
$htmlRow .= "Chance:{$output["mods"][2]["mod $i chance"]}<br>";
}
?>
<?php echo $output["output"][0] ?>
<?php echo $output["output"][1] ?><br>
<?php
for ($i = 1; $i <= 5; $i++) {
if ($output["mods"][0]["mod $i"]) {
echo "{$output["mods"][0]["mod $i"]}<br>";
}
if ($output["mods"][0]["mod $i chance"]) {
echo "Chance:{$output["mods"][0]["mod $i chance"]}<br>";
}
if ($output["mods"][0]["mod $i min"]) {
echo "Min:{$output["mods"][0]["mod $i min"]}<br>";
}
if ($output["mods"][0]["mod $i max"]) {
echo "Max:{$output["mods"][0]["mod $i max"]}";
}
if ($output["mods"][2]["mod $i min"]) {
$htmlRow .= "Min:{$output["mods"][2]["mod $i min"]}<br>";
}
?>
</td>
<td class="output2">
<?php
if (!empty($output["output 2"]["img"])) {
echo "<p><img src='/img/items/{$output["output 2"]["img"]}'></p>";
if ($output["mods"][2]["mod $i max"]) {
$htmlRow .= "Max:{$output["mods"][2]["mod $i max"]}";
}
?>
<p><?php echo $output["output b"][0] ?></p>
<p><?php echo $output["output b"][1] ?></p>
<?php
for ($i = 1; $i <= 5; $i++) {
}
}
$htmlRow .= "</td>";
$htmlRow .= "</tr>";
if ($output["mods"][1]["b mod $i"]) {
echo "{$output["mods"][1]["b mod $i"]}<br>";
}
echo $htmlRow;
ob_flush();
if ($output["mods"][1]["b mod $i chance"]) {
echo "Chance:{$output["mods"][1]["b mod $i chance"]}<br>";
}
$htmlFinal .= $htmlRow;
if ($output["mods"][1]["b mod $i min"]) {
echo "Min:{$output["mods"][1]["b mod $i min"]}<br>";
}
if ($output["mods"][1]["b mod $i max"]) {
echo "Max:{$output["mods"][1]["b mod $i max"]}";
}
}
?>
</td>
<td class="output3">
<?php
if (!empty($output["output 3"]["img"])) {
echo "<p><img src='/img/items/{$output["output 3"]["img"]}'></p>";
}
?>
<p><?php echo $output["output c"][2] ?></p>
<p><?php echo $output["output c"][1] ?></p>
<?php
for ($i = 1; $i <= 5; $i++) {
if ($output["mods"][2]["c mod $i"]) {
echo "{$output["mods"][2]["c mod $i"]}<br>";
}
if ($output["mods"][2]["c mod $i chance"]) {
echo "Chance:{$output["mods"][2]["c mod $i chance"]}<br>";
}
if ($output["mods"][2]["c mod $i min"]) {
echo ">Min:{$output["mods"][2]["c mod $i min"]}<br>";
}
if ($output["mods"][2]["c mod $i max"]) {
echo "Max:{$output["mods"][2]["c mod $i max"]}";
}
}
?>
</td>
</tr>
<?php
//var_dump($output);
unset($output);
}// end each row loop
echo <<<EOT
//ddump($i_params['levelreq']);
//var_dump($output);
ob_flush();
unset($output);
}// end each row loop
$tableBottom = <<<EOT
</tbody>
<table>
EOT;
echo $htmlbottom;
}
echo $tableBottom;
echo $htmlbottom;
ob_flush();
$htmlFinal .= $tableBottom . $htmlbottom;
file_put_contents("$dir/cubemain.html", $htmlFinal);
header("Location: /docs/{$_SESSION['modname']}/cubemain.html");
}
if ($cmd == "getIscStrings") {
// $sql = "SELECT p.`code` as prop,
// p.stat1,
// i.descstrpos,
// i.descstr2,
// i.descfunc,
// i.descval,
// s1.String as string1,
// s2.String as string2
// FROM properties as p
// LEFT JOIN itemstatcost as i
// ON p.stat1 = i.Stat
// LEFT JOIN strings as s1
// ON i.descstrpos = s1.Key
// LEFT JOIN strings as s2
// ON i.descstr2 = s2.Key";
// $res = PDO_FetchAll($sql);
//
// $isc = null;
// foreach ($res as $r) {
// $isc[$r['prop']] = $r;
// $isc[$r['prop']]['prop'] = $r['prop'];
// }
var_dump($isc);
}