Misc Browser mostly working

This commit is contained in:
Hash Borgir
2022-03-27 10:43:17 -06:00
parent 5cc49b051f
commit a041997dc4
5 changed files with 167 additions and 10 deletions

View File

@@ -54,6 +54,8 @@ require_once './src/D2ItemData.php';
require_once './src/D2ItemDesc.php';
require_once './src/D2DocGenerator.php';
$pre = "<pre>";
$idata = new D2ItemData();
$idesc = new D2ItemDesc();
// $idoc = new D2DocGenerator();
@@ -478,7 +480,7 @@ EOT;
$output['mods'][$k]["str"] = $idesc->getDesc($params);
}
// var_dump($output);
// At this point, $output contains raw accurte data
// TODO: build output correctly
// input1-input7,output a,b,c item codes can be found in $strings
@@ -486,6 +488,8 @@ EOT;
// Type code sare not in $strings (tbl files)
// Type codes are in ItemTypes in itemtypes.Code
// Type code's string name entry is in itemtypes.ItemType table--
// first find in $strings. if not there, look in itemtypes
//
$htmlRow = "<tr>";
$htmlRow .= "<td class='desc'>" . $output['desc'] . "</td>";
@@ -510,9 +514,7 @@ EOT;
} else {
$ostr = implode("<br>", (array_reverse(explode('\n', $output["input $i"][0]))));
}
echo '<pre>';
$htmlRow .= $ostr . "<br>";
if (str_contains($output["input $i"][1], "=")) {
$htmlRow .= $output["input $i"][1] . "<br>";
@@ -656,8 +658,8 @@ EOT;
$htmlFinal .= $tableBottom . $htmlbottom;
// save file and redirect to it
file_put_contents("$dir/cubemain.html", $htmlFinal);
header("Location: docs/{$_SESSION['modname']}/cubemain.html");
//file_put_contents("$dir/cubemain.html", $htmlFinal);
//header("Location: docs/{$_SESSION['modname']}/cubemain.html");
}
if ($cmd == "getImages") {
@@ -1011,3 +1013,154 @@ if ($cmd == 'genDocRunewords') {
file_put_contents("$dir/runewords.html", $htmlFinal);
header("Location: docs/{$_SESSION['modname']}/runewords.html");
}
if ($cmd == "genDocMisc") {
$sql = "SELECT misc.*,gems.code
FROM misc
LEFT JOIN gems ON misc.code = gems.code
WHERE gems.code IS NULL AND misc.spawnable != 0";
$res = PDO_FetchAll($sql);
$tableTop = <<<EOT
<table border=1 class="mtable">
<thead>
<tr>
<th>Item</th>
<th>Stats</th>
<th>Properties</th>
</tr>
</thead>
<tbody>
EOT;
$htmlFinal = null;
$htmlFinal = $htmltop . $tableTop;
$tr = null;
foreach ($res as $r) {
$data['name'] = $strings[$r['namestr']];
if (str_contains($data['name'], "ÿc")) {
$p = "/ÿc[\d:;\/.]/i";
$data['name'] = preg_replace($p, "", $data['name']);
$data['spelldesc'] = preg_replace($p, "", $data['spelldesc']);
}
// later display these in a li
$img = "/img/items/{$r['invfile']}.png";
if ($r['level']) {
$data['level'] = "Item Level: <span class=''>{$r['level']}</span>";
}
if ($r['levelreq']) {
$data['levelreq'] = "Required Level: <span class=''>{$r['levelreq']}</span>";
}
if ($r['rarity']) {
$data['rarity'] = $armorRack = "Can drop from Armor Racks.";
}
if ($r['speed'] > 0) {
$data['speed'] = "Slow your character down.";
}
if ($r['durability']) {
$data['durability'] = "Base durability: <span class=''>{$r['durability']}</span>";
}
if ($r['hasinv']) {
if ($r['gemapplytype'] == 0) {
$data['gemapplytype'] = "Gem Apply Type: <span class=''>Weapon</span>";
} else if ($r['gemapplytype'] == 1) {
$data['gemapplytype'] = "Gem Apply Type: <span class=''>Armor/Helm</span>";
} else if ($r['gemapplytype'] == 2) {
$data['gemapplytype'] = "Gem Apply Type: <span class=''>Shield</span>";
}
}
if ($r['Transmogrify']) {
$data['Transmogrify'] = "Can right click transmogrify into <p> {$strings[$r['namestr']]}</p>";
$p = "/ÿc[\d:;\/.]/i";
$data['Transmogrify'] = preg_replace($p, "", $data['Transmogrify']);
$data['Transmogrify'] = str_replace('\n', "<br>", $data['Transmogrify']);
}
if ($r['useable']) {
$data['useable'] = "Can be right clicked.";
}
if ($r['throwable']) {
$data['throwable'] = "Can be thrown.";
}
if ($r['unique']) {
$data['unique'] = "Can only spawn as a unique item.";
}
if ($r['stackable']) {
$data['stackable'] = "Can be stacked on top of each other.";
}
if ($r['quest']) {
$data['quest'] = "Quest Itemstats";
}
if ($r['spelldesc']) {
$data['spelldesc'] = $strings[$r['spelldesc']];
}
if ($r['nameable']) {
$data['nameable'] = "<span class=''>Can be personalized by Anya</span>";
}
if ($r['stat1']) {
$stats['stat1'] = "{$r['stat1']}";
}
if ($r['stat2']) {
$stats['stat2'] = "{$r['stat2']}";
}
if ($r['stat3']) {
$stats['stat3'] = "{$r['stat3']}";
}
if ($r['calc1']) {
$stats['calc1'] = "{$r['calc1']}";
}
if ($r['calc2']) {
$stats['calc2'] = "{$r['calc2']}";
}
if ($r['calc3']) {
$stats['calc3'] = "{$r['calc3']}";
}
$data = array_filter($data);
$li = '';
foreach ($data as $d){
$li .= "<li>$d</li>";
}
$tr .= <<<EOT
<tr>
<td><img style="height: 25%;" src="$img"><p>{$data['name']}</p><p>{$data['spelldesc']}</p></td>
<td style="min-width: 420px;font-family: Arial,Tahoma; font-weight: normal;">
<ul>
$li
</ul>
</td>
<td style="font-family: Arial,Tahoma">
<ul>
<li>{$stats['calc1']} {$stats['stat1']}</li>
<li>{$stats['calc2']} {$stats['stat2']}</li>
<li>{$stats['calc3']} {$stats['stat3']}</li>
</ul>
</td>
</tr>
EOT;
}
echo $htmlFinal . $tr . $tableBottom . $htmlbottom;
ob_flush();
}