fixed cubemain big problems, some remain. tcex saves now

This commit is contained in:
Hash Borgir 2023-08-18 18:16:55 -06:00
parent a60492e230
commit ab78848845
3 changed files with 68 additions and 67 deletions

View File

@ -41,7 +41,7 @@ if ($result) {
echo "Failed to update! Error: " . $db->lastErrorMsg();
}
$tsvFilePath = $_SESSION['path'] . "/TreasureClassEx.txt";
// Open the file for writing
$fileHandle = fopen($tsvFilePath, 'w');

View File

@ -270,6 +270,7 @@ EOT;
AND `input 1` <> 'ib1'
AND `input 2` <> 'ooc'
AND `description` NOT LIKE '%Stone x%'
AND `description` NOT LIKE 'Rune%'
AND `description` NOT LIKE '%Unstacker%' ";
$res = PDO_FetchAll($sql);
@ -290,48 +291,52 @@ EOT;
"input 7" => $r["input 7"],
]);
$input1_code = explode(',',$r['input 1'])[0];
foreach ($input_codes as $inputNum => $value) {
if (str_contains($value, ',')) {
$input_codes[$inputNum] = explode(",", $value); // hpot,qty=3
$oarray = explode(",", $value); // hpot,qty=3
$iarray = explode(",", $value); // hpot,qty=3
// For each input code // hpot,qty=3 like mpot/hpot/magharv
// 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]]; // Assuming $strings array is defined
$str = $strings[$iarray[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] = $iarray[0];
} else {
$input_codes[$inputNum][0] = $str;
}
// get image
$input_codes[$inputNum]["img"] = $idoc->getImage($oarray[0]);
$input_codes[$inputNum]["img"] = $idoc->getImage($iarray[0]);
$input_codes[$inputNum]['code'] = $iarray[0];
} else {
$value .= ",";
$input_codes[$inputNum] = explode(",", $value); // hpot,qty=3
$oarray = explode(",", $value); // hpot,qty=3
$iarray = explode(",", $value); // hpot,qty=3
// For each input code // hpot,qty=3 like mpot/hpot/magharv
// 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]]; // Assuming $strings array is defined
$str = $strings[$iarray[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] = $iarray[0];
$input_codes[$inputNum]['code'] = $iarray[0];
} else {
$input_codes[$inputNum][0] = $str;
}
// get image
$input_codes[$inputNum]["img"] = $idoc->getImage($oarray[0]);
$input_codes[$inputNum]["img"] = $idoc->getImage($iarray[0]);
}
}
@ -345,11 +350,15 @@ EOT;
]
);
//var_dump(array_filter($r));
//var_dump($r['input 1']);
//var_dump($input1_code);
//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
$oarray = [];
foreach ($output_codes as $outputNum => $value) {
//outputNum will be output, or output b, or c
@ -357,11 +366,16 @@ EOT;
// 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
$str = $strings[$oarray[0]]; // "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
if ($oarray[0] == 'usetype' || $oarray[0] == 'useitem') {
$oarray[0] = $input1_code;
}
//if (in_array($oarray[0], $strings)) {
$str = $strings[$oarray[0]];
//}
// "SELECT `String` FROM `strings` WHERE Key=\"{$oarray[0]}\"";
// clean str
// $str = PDO_FetchOne($sql);
if (str_contains($str, "ÿc")) {
@ -369,9 +383,11 @@ EOT;
$str = preg_replace($p, "", $str);
}
if ($output_codes[$outputNum] == 'usetype' || $output_codes[$outputNum] == 'useitem') {
$output_codes[$outputNum][0] = $input_codes[1];
}
// what if we set it to input codes 1 code
//var_dump($strings[$oarray[0]]);
// var_dump($oarray[0]);
// var_dump($str);
// if empty, str == 4-letter code, so just display
if (empty($str)) {
@ -379,36 +395,11 @@ EOT;
} else {
$output_codes[$outputNum][0] = $str;
}
$output_codes[$outputNum]["img"] = $idoc->getImage($oarray[0]);
} else { // else output code is three/four letter code
$value .= ",";
//var_dump($output_codes[$outputNum]);
$output_codes[$outputNum] = explode(",", $value); // hpot,qty=3
$oarray = explode(",", $value); // hpot,qty=3
$str = $strings[$oarray[0]]; //"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]);
} else {
$output_codes[$outputNum][0] = $str;
}
$output_codes[$outputNum]["img"] = $idoc->getImage($oarray[0]);
}
//var_dump($oarray);
//echo "Generated Output Codes Array";
//echo "input code: ". $input_codes['intput 1'][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
@ -426,13 +417,12 @@ EOT;
//var_dump($mod);
foreach ($mod as $m) {
if (str_contains($m, '=')) {
$e = explode("=", $m);
$e = explode("=", $mod[1]);
$output_codes[$outputNum]['code'] = $e[0];
$output_codes[$outputNum]['value'] = $e[1];
}
}
}
}
@ -466,6 +456,8 @@ EOT;
}
$output['mods'] = array_filter($m);
//var_dump($output['mods']);
$result = [];
// var_dump($output['mods']);
@ -475,7 +467,7 @@ EOT;
$min = ($v["mod " . $k + 1 . " min"]) ?? $max;
$max = ($v["mod " . $k + 1 . " max"]) ?? $min;
//var_dump($min);
//var_dump($isc[$prop]);
$output['mods'][$k]["isc"] = $isc[$prop];
$params = [
@ -492,7 +484,12 @@ EOT;
// 'item' => $return
];
//var_dump($idesc->getDesc($params));
$output['mods'][$k]["str"] = $idesc->getDesc($params);
}

View File

@ -325,6 +325,10 @@ class D2ItemDesc {
// }
if (empty($s1)) {
$this->str = $prop;
}
if (empty($par)) {
$v = $min;
}