Refactored Item display. Todo: auto doc gen debug loop

This commit is contained in:
color.diff=auto
2021-05-06 02:36:04 -06:00
parent f71ab1fc24
commit 5c6a657820
2066 changed files with 338969 additions and 204 deletions

0
src/D2Config.php Normal file → Executable file
View File

0
src/D2Database.php Normal file → Executable file
View File

0
src/D2Files.php Normal file → Executable file
View File

0
src/D2Functions.php Normal file → Executable file
View File

201
src/D2ItemData.php Executable file
View File

@@ -0,0 +1,201 @@
<?php
class D2ItemData {
public function uniqueItems($index, $doc = FALSE) {
$sql = "SELECT * FROM `uniqueitems` WHERE `enabled`='1' AND `index`=\"$index\"";
$res = array_filter(PDO_FetchRow($sql));
if (empty($res['invfile'])) {
// if no invfile, get from other tables
// try to get from armor, weapons, misc
$sql = "SELECT invfile FROM armor WHERE code='{$res['code']}'";
$invfile[] = PDO_FetchRow($sql);
$sql = "SELECT invfile FROM weapons WHERE code='{$res['code']}'";
$invfile[] = PDO_FetchRow($sql);
$sql = "SELECT invfile FROM misc WHERE code='{$res['code']}'";
$invfile[] = PDO_FetchRow($sql);
$invfile = array_filter($invfile);
foreach ($invfile as $i) {
$x[] = $i;
}
$invClean = array_filter($x[0]);
$return = array_merge($res, $invClean);
} else {
$return = $res;
}
// var_dump($return);
// for all props for this unique item, get ISC strings
$props = array_filter([
"Prop1" => array_filter(
["prop1" => $return['prop1'], "par1" => $return['par1'], "min1" => $return['min1'], "max1" => $return['max1']]
),
"Prop2" => array_filter(
["prop2" => $return['prop2'], "par1" => $return['par2'], "min1" => $return['min2'], "max1" => $return['max2']]
),
"Prop3" => array_filter(
["prop3" => $return['prop3'], "par1" => $return['par3'], "min1" => $return['min3'], "max1" => $return['max3']]
),
"Prop4" => array_filter(
["prop4" => $return['prop4'], "par1" => $return['par4'], "min1" => $return['min4'], "max1" => $return['max4']]
),
"Prop5" => array_filter(
["prop5" => $return['prop5'], "par1" => $return['par5'], "min1" => $return['min5'], "max1" => $return['max5']]
),
"Prop6" => array_filter(
["prop6" => $return['prop6'], "par1" => $return['par6'], "min1" => $return['min6'], "max1" => $return['max6']]
),
"Prop7" => array_filter(
["prop7" => $return['prop7'], "par1" => $return['par7'], "min1" => $return['min7'], "max1" => $return['max7']]
),
"Prop8" => array_filter(
["prop8" => $return['prop8'], "par1" => $return['par8'], "min1" => $return['min8'], "max1" => $return['max8']]
),
"Prop9" => array_filter(
["prop9" => $return['prop9'], "par1" => $return['par9'], "min1" => $return['min9'], "max1" => $return['max9']]
),
"Prop10" => array_filter(
["prop10" => $return['prop10'], "par1" => $return['par10'], "min1" => $return['min10'], "max1" => $return['max10']]
)
]);
// need par, min, max value for each prop
// for each prop, get stat
$counter = 1;
foreach ($props as $key => $val) {
// val = Prop1,Prop2 etc.
// for each propr, get all 7 stats in ISC
$sql = "SELECT stat1,stat2,stat3,stat4,stat5,stat6,stat7 FROM `properties` WHERE `code` = '{$val['prop' . $counter]}'";
$props[$key]['stat'] = PDO_FetchRow($sql);
if (!empty($props[$key]['stat'])){
$props[$key]['stat'] = array_filter($props[$key]['stat']);
}
$counter++;
}
//each stat now goes into getIscStrings
foreach ($props as $k => $v) {
$props[$k]['desc'] = array_filter($this->getIscStrings($v['stat']['stat1']));
}
// SELECT * FROM strings WHERE `Key`='ModStr3a' returns always Amazon Skills
// todo: put values in params, so I can get generated string for that prop
$counter = 1;
foreach ($props as $k => $v) { // for each property Prop1 Prop2
$params = [
'string1' => $v['desc']['string1'],
'string2' => $v['desc']['string2'],
'descfunc' => $v['desc']['descfunc'],
'descval' => $v['desc']['descval'],
"prop" => $return['prop' . $counter],
"par" => $return['par' . $counter],
"min" => $return['min' . $counter],
"max" => $return['max' . $counter],
// 'item' => $return
];
/*
* getDesc should process string1, not file guide copy pasta
*
*/
if (!empty($v['desc'])) {
require_once 'D2ItemDesc.php';
$idesc = new D2ItemDesc();
$props[$k]['string'][] = ($idesc->getDesc($params));
}
$counter++;
}
$return['props'] = $props;
$sqlArmor = "SELECT * FROM armor WHERE code='{$res['code']}'";
$sqlMisc = "SELECT * FROM misc WHERE code='{$res['code']}'";
$sqlWeapons = "SELECT * FROM weapons WHERE code='{$res['code']}'";
$baseItemInfo = PDO_FetchRow($sqlArmor);
$uTable = "armor";
if (empty($baseItemInfo)) {
$baseItemInfo = PDO_FetchRow($sqlMisc);
}
if (empty($baseItemInfo)) {
$baseItemInfo = PDO_FetchRow($sqlWeapons);
}
$return['baseItemInfo'] = array_filter($baseItemInfo);
if(!$doc){
header('Content-Type: application/json');
return json_encode($return, JSON_INVALID_UTF8_IGNORE | JSON_PRETTY_PRINT);
} else {
return $return;
}
}
function getIscStrings($iscStat) {
$sql = "
SELECT
(
SELECT String
FROM itemstatcost as i
LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key`
WHERE `Stat` = '$iscStat'
)
AS string1,
(
SELECT String
FROM itemstatcost as i
LEFT JOIN strings AS `s` ON `i`.DescStr2 = `s`.`Key`
WHERE `Stat` = '$iscStat'
)
AS string2,
(
SELECT descfunc
FROM itemstatcost as i
LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key`
WHERE `Stat` = '$iscStat'
)
AS descfunc,
(
SELECT descval
FROM itemstatcost as i
LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key`
WHERE `Stat` = '$iscStat'
)
AS descval
";
return PDO_FetchRow($sql);
}
public function genDoc($itemData){
}
}

52
src/D2ItemDesc.php Normal file → Executable file
View File

@@ -204,10 +204,6 @@ class D2ItemDesc {
$this->skilltabsDesc[] = PDO_FetchRow($sql);
}
foreach ($this->skilltabsDesc as $s) {
$this->skilltabsDescClean[] = str_replace('+%d', '', $s);
}
//ddump($this->skilltabsDescClean);
/*
@@ -265,7 +261,16 @@ class D2ItemDesc {
}
if ($params['descfunc'] == 11) {
$this->str = sprintf($s1, (100/$par));
//var_dump($params);
if ($par == '') {
$min = (int) $min;
$this->str = sprintf($s1, (100 / $min));
} else {
$par = (int) $par;
$this->str = sprintf($s1, (100 / $par));
}
}
if ($params['descfunc'] == 12) {
@@ -273,8 +278,18 @@ class D2ItemDesc {
}
if ($params['descfunc'] == 13) {
$this->str = "+$min to {$this->charClass[$prop]} Skill Levels";
$this->str = sprintf($s1,$max);
$chars = [
"ama" => "ModStr3a",
"pal" => "ModStr3b",
"nec" => "ModStr3c",
"sor" => "ModStr3d",
"bar" => "ModStr3e",
"dru" => "ModStre8a",
"ass" => "ModStre8b"
];
$sql = "SELECT `String` FROM `strings` WHERE `Key`='{$chars[$prop]}'";
$s1 = PDO_FetchOne($sql);
$this->str = "+$min $s1";
}
if ($params['descfunc'] == 14) {
@@ -286,7 +301,10 @@ class D2ItemDesc {
`StrSkillTab3`='{$this->skilltabs[$par]}'";
$class = PDO_FetchOne($sql);
$this->str = sprintf($s1, $min, $this->skilltabsDescClean[$par]['String']);
$s1 = $this->skilltabsDesc[$par]['String'];
$this->str = sprintf($s1, $min);
}
if ($params['descfunc'] == 15) {
$sql = "SELECT skill FROM `skills` WHERE `Id`='$par'";
@@ -295,7 +313,11 @@ class D2ItemDesc {
}
if ($params['descfunc'] == 16) {
$this->str = "Level $min-$max $par Aura When Equipped ";
if (!$max) {
$this->str = "Level $min $par Aura When Equipped ";
} else {
$this->str = "Level $min to $max $par Aura When Equipped ";
}
}
if ($params['descfunc'] == 17) {
@@ -344,7 +366,11 @@ class D2ItemDesc {
if ($params['descfunc'] == 27) {
$sql = "SELECT skill,charclass FROM `skills` WHERE `Id`='$par'";
$res = PDO_FetchRow($sql);
$this->str = "+$par to a Random Skill";
$sql = "SELECT `skill` FROM `skills` WHERE `skilldesc`='$par' OR `Id`='$par'";
$skill = PDO_FetchOne($sql);
$class = $this->charClass[$res['charclass']];
$this->str = "+$min to $skill ($class Only)";
}
if ($params['descfunc'] == 28) {
@@ -476,7 +502,7 @@ class D2ItemDesc {
}
}
/*
* Descval 0
* Descval 2
*
*
*
@@ -497,7 +523,7 @@ class D2ItemDesc {
}
if ($params['descfunc'] == 4) {
$this->str = "$s1 +$v%";
$this->str = "$s1 $v%";
}
if ($params['descfunc'] == 5) {
@@ -579,7 +605,7 @@ class D2ItemDesc {
}
if ($params['descfunc'] == 23) {
$this->str = "s1 [Monster] $v% $";
$this->str = "s1 [Monster] $v%";
}
if ($params['descfunc'] == 24) {

0
src/D2SaveFile.php Normal file → Executable file
View File

0
src/D2Tbl.php Normal file → Executable file
View File

0
src/D2TxtParser.php Normal file → Executable file
View File

0
src/bottom.php Normal file → Executable file
View File

0
src/footer.php Normal file → Executable file
View File

4
src/head.php Normal file → Executable file
View File

@@ -51,8 +51,8 @@
<link rel="stylesheet" href="/res/bootstrap.min.css">
<link rel="stylesheet" href="/res/font-awesome.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://bootswatch.com/4/sketchy/bootstrap.min.css">
<!-- <link href="https://fonts.googleapis.com/css2?family=Lato:wght@300&display=swap" rel="stylesheet">-->
<!-- <link rel="stylesheet" href="https://bootswatch.com/4/sketchy/bootstrap.min.css">-->
<link rel="stylesheet" href="/res/style.css">
<link rel="stylesheet" href="/res/<?php echo $css ?>">
<style>

0
src/header.php Normal file → Executable file
View File

0
src/index.php Normal file → Executable file
View File

0
src/tabs/Debug.php Normal file → Executable file
View File

0
src/tabs/Gems.php Normal file → Executable file
View File

0
src/tabs/SetItems.php Normal file → Executable file
View File

7
src/tabs/UniqueItems.php Normal file → Executable file
View File

@@ -1,7 +1,6 @@
<div style="height: 40px; margin: 40px 10px;"><h2>Unique Item Maker</h2></div>
<div class="row">
<div class="col sortby">
<p style="">Sort By: </p>
<div class="col sortby">Sort By:<br>
<div class="custom-control custom-radio custom-control-inline">
<input name="sort" id="sort_0" type="radio" class="custom-control-input" value="lvl">
<label for="sort_0" class="custom-control-label">Level</label>
@@ -19,7 +18,6 @@
<label for="sort_3" class="custom-control-label">Item Code</label>
</div>
<hr>
<p style="">Filter By: </p>
<div class="custom-control custom-radio custom-control-inline">
<input name="view" id="view_0" type="radio" class="custom-control-input" value="rin">
<label for="view_0" class="custom-control-label">Rings</label>
@@ -65,13 +63,14 @@
<div class="row">
<div class="col-4">
<button style="margin: 20px;" class="btn btn-outline-warning btnDebug">Debug Info</button>
<button style="margin: 20px;" class="btn btn-outline-info btnDocs">Generate Docs Info</button>
<pre class="debug_preview" style="display:none; background: #eee; height: 420px;width: 1123px;"></pre>
</div>
</div>
<div class="row" style="margin-bottom:40px;">
<div class="col" style="">
<p>Search for Item</p>
<input style="border: 1px solid #999; padding: 10px;width: 440px;" id="search" type="text custom-control-inline" placeholder="Search item" name="search">
<input style="border: 1px solid #999; padding: 10px;width: 420px;" id="search" type="text custom-control-inline" placeholder="Search item" name="search">
</div>
</div>

0
src/tabs/optionSubmit.php Normal file → Executable file
View File