Gendocs cube generator fixes. More needed. Removed Exocet font. Need to fix image paths.

This commit is contained in:
Hash Borgir 2023-05-30 12:38:50 -06:00
parent dd662e26f6
commit 961a061662
2 changed files with 162 additions and 217 deletions

View File

@ -85,23 +85,22 @@ $htmlbottom = "</div></body></html>";
// genDocUniqueItems
if ($cmd == "genDocUniqueItems") {
$tableTop = '
<table border=1 class="utable">
$tableTop = '<table border="1" class="utable">
<thead>
<tr>
<th class="gold uname">Name</th>
<th class="orange ulvl">Lvl</th>
<th class="orange ulvlreq">Lvl Req</th>
<th class="yellow utype">Type</th>
<th class="green ucode">Code</th>
<th class="uitem">Item</th>
</tr>
<tr>
<th class="gold uname">Name</th>
<th class="orange ulvl">Lvl</th>
<th class="orange ulvlreq">Lvl Req</th>
<th class="yellow utype">Type</th>
<th class="green ucode">Code</th>
<th class="uitem">Item</th>
</tr>
</thead>
<tbody>';
$tableBottom = '</tbody> </table>';
<tbody>';
// grab unique item index only (to save on memory)
$tableBottom = '</tbody></table>';
// Grab unique item index only (to save on memory)
$sql = "SELECT `index` FROM `uniqueitems` WHERE `enabled`='1'";
$uIndex = PDO_FetchAll($sql);
@ -112,85 +111,83 @@ if ($cmd == "genDocUniqueItems") {
echo $tableTop;
ob_flush();
// main loop: grab the data for each uIndex (index from uniqueitems.txt)
// Main loop: grab the data for each uIndex (index from uniqueitems.txt)
foreach ($uIndex as $u) {
$item = $idata->uniqueItems($u['index'], true);
$itemBoxTop = "<tr>";
$itemBoxTop .= "<td class='gold uname' style=''>{$item['index']}</td>";
$itemBoxTop .= "<td class='orange ulvl' style=''>{$item['lvl']}</td>";
$itemBoxTop .= "<td class='orange ulvlreq' style=''>{$item["lvl req"]}</td>";
$itemBoxTop .= "<td class='utype' style=''>{$item["*type"]}</td>";
$itemBoxTop .= "<td class='ucode' style=''>{$item['code']}</td>";
$itemBoxTop = '<tr>';
$itemBoxTop .= '<td class="gold uname">' . $item['index'] . '</td>';
$itemBoxTop .= '<td class="orange ulvl">' . $item['lvl'] . '</td>';
$itemBoxTop .= '<td class="orange ulvlreq">' . $item["lvl req"] . '</td>';
$itemBoxTop .= '<td class="utype">' . $item["*type"] . '</td>';
$itemBoxTop .= '<td class="ucode">' . $item['code'] . '</td>';
$itemBoxTop .= <<<HTML
<td class="item">
<div class="center item_desc">
<div class="itemimage" style="height: 116px; background: url(img/items/bg.png) center top no-repeat;">
<img class="item img-fluid" src="img/items/{$item["invfile"]}.png">
</div>
<div class="item_stats">
<div style="width:auto; margin: 0 auto; background:#111; display:inline-block;">
<p>
HTML;
$itemBoxTop .= <<<EOT
<td class='item' style=''>
<div class="center item_desc" style="">
<div class="itemimage" style="height: 116px;background: url(img/items/bg.png) center top no-repeat;">
<img style="" class="item img-fluid" src="img/items/{$item["invfile"]}.png">
</div>
<div class="item_stats" style="">
<div style="width:auto; margin: 0 auto; background:#111; display:inline-block;">
<p>
EOT;
$itemBoxBottom = <<<EOT
</p>
</div>
</div>
</div>
</td>
EOT;
$itemBoxBottom .= "</tr>";
$itemBoxBottom = <<<HTML
</p>
</div>
</div>
</div>
</td>
</tr>
HTML;
echo $itemBoxTop;
ob_flush();
$htmlFinal .= $itemBoxTop;
//index
$props = "<ul><li class='statindex gold'>{$item['index']}</li>";
// Index
$props = '<ul><li class="statindex gold">' . $item['index'] . '</li>';
//type
$props .= "<li class='stattype gold'>({$item["*type"]})</li>";
// Type
$props .= '<li class="stattype gold">(' . $item["*type"] . ')</li>';
//level
$props .= "<li style='color: white;' class=''>Level: {$item["lvl"]}</li>";
// Level
$props .= '<li style="color: white;">Level: ' . $item["lvl"] . '</li>';
//lvlreq
$props .= "<li style='color: white;' class=''>Level Required: {$item["lvl req"]}</li>";
// Level Required
$props .= '<li style="color: white;">Level Required: ' . $item["lvl req"] . '</li>';
//code
$props .= "<li style='color: #aaa;' class=''>Item Code: {$item["code"]}</li>";
// Item Code
$props .= '<li style="color: #aaa;">Item Code: ' . $item["code"] . '</li>';
//reqstr
// Required Strength
if ($item["reqstr"]) {
$props .= "<li style='color: white;' class=''>{$item["reqstr"]}</li>";
$props .= '<li style="color: white;">' . $item["reqstr"] . '</li>';
}
//reqdex
// Required Dexterity
if ($item["reqdex"]) {
$props .= "<li style='color: white;' class=''>{$item["reqdex"]}</li>";
$props .= '<li style="color: white;">' . $item["reqdex"] . '</li>';
}
//sock
$props .= "<li style='color: white;' class=''>{$item["gemsockets"]}</li>";
// Sockets
$props .= '<li style="color: white;">' . $item["gemsockets"] . '</li>';
foreach ($item['props'] as $prop) {
if ($prop['string'][0]) {
$props .= "<li class='blue'>{$prop['string'][0]}</li>";
$props .= '<li class="blue">' . $prop['string'][0] . '</li>';
}
}
$props .= "</ul>";
// $itemFull .= $itemBoxTop . $props . $itemBoxBottom;
// echo $itemFull;
$props .= '</ul>';
echo $props;
echo $itemBoxBottom;
ob_flush();
$htmlFinal .= $props . $itemBoxBottom;
}// end loop
}
$htmlFinal .= $tableBottom;
@ -206,13 +203,11 @@ if ($cmd == "genDocUniqueItems") {
if ($cmd == "genDocCube") {
$htmlFinal = '';
$htmlFinal .= $htmltop;
echo $htmltop;
ob_flush();
echo $htmltop;
ob_flush();
$table = <<<EOT
<table border=1 class="cubetable">
<thead>
<table border=1 class="cubetable">
<thead>
<tr>
<th>Recipe</th>
<th>Input 1</th>
@ -226,7 +221,7 @@ if ($cmd == "genDocCube") {
<th> 2</th>
<th> 3</th>
</tr>
</thead>
</thead>
<tbody>
EOT;
echo $table;
@ -266,42 +261,33 @@ EOT;
// get all cube rows
// changed enabled=1 to enabled > 0 for CubeOps.dll users
$sql = "
SELECT *
FROM cubemain
WHERE enabled > 0
AND `input 1` <> 'ib3'
AND `description` NOT LIKE '%Stone x%'
AND `description` NOT LIKE '%Unstacker%'
";
$sql = "SELECT *
FROM cubemain
WHERE enabled > 0
AND `input 1` <> 'ib3'
AND `description` NOT LIKE '%Stone x%'
AND `description` NOT LIKE '%Unstacker%' ";
$res = PDO_FetchAll($sql);
// ddump($res);
// process each cube row here
foreach ($res as $r) {
$desc = str_replace('+', '<br>+<br>', $r['description']);
$desc = str_replace('->', '<br><span class="" style="color: gold;font-size:1.25em;">=<br>', $desc);
$desc = str_replace('->', '<br><span class="" style="color: gold;">=<br>', $desc);
$desc .= "</span>";
// grab all inputs
$input_codes = array_filter(
[
"input 1" => $r["input 1"],
"input 2" => $r["input 2"],
"input 3" => $r["input 3"],
"input 4" => $r["input 4"],
"input 5" => $r["input 5"],
"input 6" => $r["input 6"],
"input 7" => $r["input 7"],
]
);
$input_codes = array_filter([
"input 1" => $r["input 1"],
"input 2" => $r["input 2"],
"input 3" => $r["input 3"],
"input 4" => $r["input 4"],
"input 5" => $r["input 5"],
"input 6" => $r["input 6"],
"input 7" => $r["input 7"],
]);
foreach ($input_codes as $inputNum => $value) {
if (str_contains($value, ',')) {
$input_codes[$inputNum] = explode(",", $value); // hpot,qty=3
@ -310,14 +296,12 @@ EOT;
// if spelldescstr is set, use it. Else use item string tbl
// first find the item code in either armor, misc, or weapons
// then get spelldesc/spelldescstr
// $sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
// $str = PDO_FetchOne($sql);
$str = $strings[$oarray[0]];
// $sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
// $str = PDO_FetchOne($sql);
$str = $strings[$oarray[0]]; // Assuming $strings array is defined
// if empty str == 4-letter code, call $idoc->getItemName()
if (empty($str)) {
$input_codes[$inputNum][0] = ($oarray[0]);
$input_codes[$inputNum][0] = $oarray[0];
} else {
$input_codes[$inputNum][0] = $str;
}
@ -333,14 +317,12 @@ EOT;
// if spelldescstr is set, use it. Else use item string tbl
// first find the item code in either armor, misc, or weapons
// then get spelldesc/spelldescstr
// $sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
// $str = PDO_FetchOne($sql);
$str = $strings[$oarray[0]];
// $sql = "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
// $str = PDO_FetchOne($sql);
$str = $strings[$oarray[0]]; // Assuming $strings array is defined
// if empty str == 4-letter code, so just display
if (empty($str)) {
$input_codes[$inputNum][0] = ($oarray[0]);
$input_codes[$inputNum][0] = $oarray[0];
} else {
$input_codes[$inputNum][0] = $str;
}
@ -353,24 +335,32 @@ EOT;
// processs output, output b, output c
// grab all inputs
$output_codes = array_filter(
[
"output" => str_replace('"', "", $r["output"]),
"output b" => str_replace('"', "", $r["output b"]),
"output c" => str_replace('"', "", $r["output c"])
]
[
"output" => str_replace('"', "", $r["output"]),
"output b" => str_replace('"', "", $r["output b"]),
"output c" => str_replace('"', "", $r["output c"])
]
);
// ddump($output_codes);
// var_dump($output_codes);
// output_codes is an array
// output codes of outputs, like output, output b, output c.
// each output can have 3 or 4 level item code or a amu,mag,pre=331 code
// outputNum is output a, or output b, or output c, should have been called outputLetter whatever
foreach ($output_codes as $outputNum => $value) {
//outputNum will be output, or output b, or c
// value will be 3/4 letter code or sometimes 'Cow Portal' or words
// or rin,mag,pre=353
// if value contains a comma, e.g., rin,mag,pre=353
// then explode it at the comma
if (str_contains($value, ',')) {
$output_codes[$outputNum] = explode(",", $value); // hpot,qty=3
$oarray = explode(",", $value); // hpot,qty=3
$sql = $strings[$oarray[0]]; // "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
$str = $strings[$oarray[0]]; // "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);
@ -389,7 +379,7 @@ EOT;
$output_codes[$outputNum] = explode(",", $value); // hpot,qty=3
$oarray = explode(",", $value); // hpot,qty=3
$sql = $strings[$oarray[0]]; //"SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
$str = $strings[$oarray[0]]; //"SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
// clean color codes
// $str = PDO_FetchOne($sql);
@ -409,7 +399,7 @@ EOT;
$output_codes[$outputNum]["img"] = $idoc->getImage($oarray[0]);
}
//var_dump($output_codes);
// if output[1] or output[2], output[3], output[4] contains `=' sign
// parse_str or explode at = to get modifer and value
// if modifier = pre or suf, find ID in magic prefix/suffix line.
@ -487,17 +477,16 @@ EOT;
"par" => $par,
"min" => $min,
"max" => $max,
// "val1" => $funcval['val1'],
// "func1" => $funcval['func1']
// 'item' => $return
// "val1" => $funcval['val1'],
// "func1" => $funcval['func1']
// 'item' => $return
];
$output['mods'][$k]["str"] = $idesc->getDesc($params);
}
// dump($output);
// var_dump($output);
//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
@ -551,11 +540,7 @@ EOT;
$output["output"][0] = preg_replace($p, "", $output["output"][0]);
}
$key1 = array_search($output["input $i"][0], $itemtypesTbl);
//var_dump($output);
// if the item is in itemtypes grab it, it's 4 letter code fron itemtypes
$htmlRow .= '<span style="color: #AF833B;">' . $output["output"][0] . "</span><br>";
$key1 = array_search($output["input $i"][0], $itemtypesTbl);
if (str_contains($output["output"][1], "ÿc")) {
@ -563,9 +548,9 @@ EOT;
$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>";
$htmlRow .= '<span style="color: #AF833B;">' . $i_params[$output["output"][0]] . "</span><br>";
} else {
$htmlRow .= $output["output"][0] . "<br>";
$htmlRow .= $i_params[$output["output"][0]] . "<br>";
}
if ($i_params[$output["output"][1]]) {
$htmlRow .= $i_params[$output["output"][1]] . "<br>";
@ -626,7 +611,7 @@ EOT;
}
$htmlRow .= "</td>";
$htmlRow .= "<td class='_output3'>"; // change _output3 to normal
$htmlRow .= "<td class='_output3'>"; // change _output3 to normal
if (!empty($output["output c"]["img"])) {
$htmlRow .= "<img src='img/items/{$output["output c"]["img"]}'><br>";
if (str_contains($output["output c"][0], "ÿc")) {
@ -673,21 +658,19 @@ EOT;
echo $htmlbottom;
ob_flush();
$htmlFinal .= $tableBottom . $htmlbottom;
// echo $htmlFinal;
// echo $htmlFinal;
// save file and redirect to it
file_put_contents("$dir/cubemain.html", $htmlFinal);
header("Location: docs/{$_SESSION['modname']}/cubemain.html");
}
if ($cmd == "getImages") {
$sql = "
SELECT code,invfile,type,type2 FROM armor
UNION ALL
SELECT code,invfile,type,type2 FROM misc
UNION ALL
SELECT code,invfile,type,type2 FROM weapons";
$sql = "SELECT code,invfile,type,type2 FROM armor
UNION ALL
SELECT code,invfile,type,type2 FROM misc
UNION ALL
SELECT code,invfile,type,type2 FROM weapons";
$res = PDO_FetchAll($sql);
$isc = null;
foreach ($res as $r) {
@ -807,7 +790,6 @@ if ($cmd == "genDocGems") {
//echo $table;
$htmlFinal .= $table;
//ob_flush();
// $gems are all the gems, processed, now display them
foreach ($gems as $g) {
@ -859,16 +841,15 @@ if ($cmd == "genDocGems") {
$htmlFinal .= $htmlRow;
//echo $htmlRow;
// ob_flush();
// ob_flush();
}
$htmlFinal .= $tableBottom . $htmlbottom;
//echo $tableBottom . $htmlbottom;
//ob_flush();
//ob_start();
file_put_contents("$dir/gems.html", $htmlFinal);
header("Location: /docs/{$_SESSION['modname']}/gems.html",TRUE,301);
header("Location: /docs/{$_SESSION['modname']}/gems.html", TRUE, 301);
}
@ -925,31 +906,14 @@ if ($cmd == 'genDocRunewords') {
$rr[5] = str_replace('', '', $strings[$rune['Rune5']]);
$rr[6] = str_replace('', '', $strings[$rune['Rune6']]);
if (str_contains($rr[1], "ÿc")) {
$p = "/ÿc[\d:;\/.]/i";
$rr[1] = preg_replace($p, "", $rr[1]);
}
if (str_contains($rr[2], "ÿc")) {
$p = "/ÿc[\d:;\/.]/i";
$rr[2] = preg_replace($p, "", $rr[2]);
}
if (str_contains($rr[3], "ÿc")) {
$p = "/ÿc[\d:;\/.]/i";
$rr[3] = preg_replace($p, "", $rr[3]);
}
if (str_contains($rr[4], "ÿc")) {
$p = "/ÿc[\d:;\/.]/i";
$rr[4] = preg_replace($p, "", $rr[4]);
}
if (str_contains($rr[5], "ÿc")) {
$p = "/ÿc[\d:;\/.]/i";
$rr[5] = preg_replace($p, "", $rr[5]);
}
if (str_contains($rr[6], "ÿc")) {
$p = "/ÿc[\d:;\/.]/i";
$rr[6] = preg_replace($p, "", $rr[6]);
for ($i = 1; $i <= 6; $i++) {
if (str_contains($rr[$i], "ÿc")) {
$p = "/ÿc[\d:;\/.]/i";
$rr[$i] = preg_replace($p, "", $rr[$i]);
}
}
$rr = array_filter($rr);
$rune_count = count($rr);
$rune_count_duplicates = array_count_values($rr);
@ -1176,27 +1140,23 @@ EOT;
$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']}";
$statFields = ['stat1', 'stat2', 'stat3'];
$calcFields = ['calc1', 'calc2', 'calc3'];
foreach ($statFields as $field) {
if (isset($r[$field])) {
$stats[$field] = "{$r[$field]}";
}
}
if ($r['calc1']) {
$stats['calc1'] = "{$r['calc1']}";
}
if ($r['calc2']) {
$stats['calc2'] = "{$r['calc2']}";
}
if ($r['calc3']) {
$stats['calc3'] = "{$r['calc3']}";
foreach ($calcFields as $field) {
if (isset($r[$field])) {
$stats[$field] = "{$r[$field]}";
}
}
$data = array_filter($data);
if ($stats)
$stat = array_filter($stats);
@ -1246,6 +1206,7 @@ EOT;
// Armor.txt docs generator
if ($cmd == 'genDocArmor') {
$tableTop = <<<EOT
@ -1281,15 +1242,10 @@ EOT;
} else {
$indestructable = "No";
}
$imgUnique = (!empty($r['uniqueinvfile'])) ? "<br><img src='img/items/{$r['uniqueinvfile']}.png'>" : "";
$imgSet = (!empty($r['setinvfile'])) ? "<br><img src='img/items/{$r['setinvfile']}.png'>" : "";
$imgUnique = (!empty($r['uniqueinvfile'])) ? "<br><img src='img/items/{$r['uniqueinvfile']}.png'>" : "";
$imgSet = (!empty($r['setinvfile'])) ? "<br><img src='img/items/{$r['setinvfile']}.png'>" : "";
if (!empty($r['auto prefix'])) {
$sql = "SELECT * FROM automagic WHERE `group` = ?";
$ret = PDO_FetchRow($sql, [$r['auto prefix']]);
@ -1327,7 +1283,7 @@ EOT;
$strbonus = (!empty($r['StrBonus'])) ? "Strength Bonus: <span class='white'>{$r['StrBonus']}" : "";
$block = (!empty($r['block'])) ? "Block: <span class='white'>{$r['block']}</span>" : "";
$tr .= <<<EOT
<tr>
<td style="text-align: left;">
@ -1360,35 +1316,30 @@ EOT;
<li class="blue" style="margin-bottom: 30px;"><span class="white">{$props[2]}</span></li>
<li class="blue">$strbonus</li>
<li class="blue">$block</li>
</ul>
</td>
<td>Level: <br> {$r['level']}</td>
<td>Level Required: <br> {$r['levelreq']}</td>
<td>Level Required: <br> {$r['levelreq']}</td>
<td>Requird Strength: <br> {$r['reqstr']}</td>
<td>Min AC: <br> {$r['minac']}</td>
<td>Max AC: <br> {$r['maxac']}</td>
<td>Block: <br> {$r['block']}</td>
</tr>
EOT;
}
$htmlFinal = $htmltop . $tableTop . $tr . $tableBottom . $htmlbottom;
ob_flush();
echo $htmlFinal;
//file_put_contents("$dir/armor.html", $htmlFinal);
//header("Location: docs/{$_SESSION['modname']}/armor.html");
file_put_contents("$dir/armor.html", $htmlFinal);
header("Location: docs/{$_SESSION['modname']}/armor.html");
}
if ($cmd == 'genDocWeapons') {
// Generate weapons.txt docs
if ($cmd == 'genDocWeapons') {
$tableTop = <<<EOT
<style>
body { font-family: Tahoma,Arial,Sans-Serif}
@ -1413,7 +1364,6 @@ EOT;
$res = PDO_FetchAll($sql);
foreach ($res as $r) {
$name = (!empty($strings[$r['namestr']])) ? $strings[$r['namestr']] : $r['name'];
if ($r['indestructible'] == '1') {
@ -1422,9 +1372,8 @@ EOT;
$indestructable = "No";
}
$imgUnique = (!empty($r['uniqueinvfile'])) ? "<br><img src='img/items/{$r['uniqueinvfile']}.png'>" : "";
$imgSet = (!empty($r['setinvfile'])) ? "<br><img src='img/items/{$r['setinvfile']}.png'>" : "";
$imgUnique = (!empty($r['uniqueinvfile'])) ? "<br><img src='img/items/{$r['uniqueinvfile']}.png'>" : "";
$imgSet = (!empty($r['setinvfile'])) ? "<br><img src='img/items/{$r['setinvfile']}.png'>" : "";
if (!empty($r['auto prefix'])) {
$sql = "SELECT * FROM automagic WHERE `group` = ?";
@ -1461,15 +1410,15 @@ EOT;
}
$strbonus = (!empty($r['StrBonus'])) ? "Strength Bonus: <span class='white'>{$r['StrBonus']}" : "";
if (empty($r['mindmg']) OR empty($r['maxdmg'])){
if (empty($r['mindmg']) OR empty($r['maxdmg'])) {
$mindmg = $r['2handmindam'];
$maxdmg = $r['2handmaxdam'];
} else {
$mindmg = $r['mindmg'];
$maxdmg = $r['maxdmg'];
$mindmg = $r['mindmg'];
$maxdmg = $r['maxdmg'];
}
$tr .= <<<EOT
<tr>
<td style="text-align: left">
@ -1502,18 +1451,14 @@ EOT;
<li class="blue" style="margin-bottom: 30px;"><span class="white">{$props[2]}</span></li>
<li class="blue">$strbonus</li>
<li class="blue">$block</li>
</ul>
</td>
<td>Level: <br> {$r['level']}</td>
<td>Level Required: <br> {$r['levelreq']}</td>
<td>Level Required: <br> {$r['levelreq']}</td>
<td>Requird Strength: <br> {$r['reqstr']}</td>
<td>Min Dmg: <br> {$mindmg}</td>
<td>Max Dmg: <br> {$maxdmg}</td>
</tr>
EOT;
}

View File

@ -28,7 +28,7 @@ $htmltop = <<<EOT
body{
background: white;
font-family: ExocetHeavy;
font-family: ;
}
table, table th, table td, table tr {
background: #000;