D2 ItemData cleanup. Fast enough rendering.

This commit is contained in:
color.diff=auto 2021-05-13 03:00:59 -06:00
parent 016ea0e5d2
commit 2cb355ab47
2 changed files with 45 additions and 168 deletions

View File

@ -17,15 +17,19 @@
<style>
body{
background: black;
text-align: left;
font-family: Lato;
background: white;
font-family: ExocetHeavy;
}
table, table th, table td, table tr {
background: #111;
color: #ccc;
}
.item {
text-align: left;
text-align: center;
position:relative;
right:0px;
margin: 0 auto;
}
.item_desc {
@ -69,7 +73,35 @@
.blue {
color: #4169E1;
}
td {
height: 240px;
text-align: center;
vertical-align: middle;
padding: 10px;
}
.uname {
background: #222;
}
.ulvl {
}
.ulvlreq {
}
.utype {
background: #111;
}
.ucode {
}
.uitem {
}
</style>
<script src="res/jquery-3.5.1.min.js"></script>
@ -82,6 +114,7 @@
$(document).ready(function() {
$('.cubetable').dataTable();
$('.utable').dataTable();
} );

View File

@ -7,7 +7,7 @@ class D2ItemData {
public function getImages() {
$sql = "
SELECT code,invfile,type,type2 FROM armor
SELECT code,invfile,type,type2 FROM armor
UNION ALL
SELECT code,invfile,type,type2 FROM misc
UNION ALL
@ -38,73 +38,19 @@ class D2ItemData {
$res = (PDO_FetchRow($sql, [$index]));
/*
*
*
*
* Grag invfile code all 3 item tables wherever it is
*
*
*
*
*
* Get invfile code all 3 item tables wherever it is
*
*/
if (empty($this->images)) {
$this->getImages();
}
// if (empty($res['invfile'])) {
$res['invfile'] = $this->images[$res['code']]['invfile'];
$return = $res;
$res['invfile'] = $this->images[$res['code']]['invfile'];
$return = $res;
// if no invfile, get from other tables
// try to get from armor, weapons, misc
// $sql = "SELECT invfile FROM armor WHERE code=?";
// $invfile[] = PDO_FetchRow($sql, [$res['code']]);
//
// $sql = "SELECT invfile FROM weapons WHERE code=?";
// $invfile[] = PDO_FetchRow($sql, [$res['code']]);
//
// $sql = "SELECT invfile FROM misc WHERE code=?";
// $invfile[] = PDO_FetchRow($sql, [$res['code']]);
//
// $invfile = array_filter($invfile);
//
// foreach ($invfile as $i) {
// $x[] = $i;
// }
//
// if (!empty($x[0])) {
// $x[0] = array_filter($x[0]);
// }
// $invClean = $x[0];
// if (!empty($invClean)) {
// $return = array_merge($res, $invClean);
// } else {
// $return = $res;
// }
//$return = array_merge($res, $invClean);
// } else {
// $return = $res;
// }
// var_dump($return);
/*
*
*
*
*
*
*
* for all props for this unique item, get ISC strings
*/
$props = array_filter([
@ -141,10 +87,7 @@ class D2ItemData {
]);
// need par, min, max value for each prop
//
//
// ( Also need func1 and val1 for each prop )
//
// for each prop, get stat
$counter = 1;
foreach ($props as $key => $val) {
@ -162,9 +105,6 @@ class D2ItemData {
$counter++;
}
//ddump($props);
$counter = 1;
//each stat now goes into getIscStrings
foreach ($props as $k => $v) {
@ -173,15 +113,9 @@ class D2ItemData {
$counter++;
}
// SELECT * FROM strings WHERE `Key`='ModStr3a' returns always Amazon Skills
// todo: put values in params, so I can get generated string for that prop
// Values in params, so I can get generated string for that prop
$counter = 1;
foreach ($props as $k => $v) { // for each property Prop1 Prop2
// $sql = "SELECT val$counter,func$counter FROM `properties` WHERE `code`=\"{$return['prop' . $counter]}\"";
// $funcval = PDO_FetchRow($sql);
//
// var_dump($funcval);
$params = [
'string1' => $v['desc']['string1'],
'string2' => $v['desc']['string2'],
@ -196,9 +130,6 @@ class D2ItemData {
"par" => $return['par' . $counter],
"min" => $return['min' . $counter],
"max" => $return['max' . $counter],
// "val1" => $funcval['val1'],
// "func1" => $funcval['func1']
// 'item' => $return
];
/*
@ -243,91 +174,10 @@ class D2ItemData {
}
}
// function getIscStringsX($iscStat) {
//// $sql = "
////SELECT s1.String as string1, s2.String as string2, descfunc, descval
//// FROM itemstatcost as i
//// LEFT JOIN strings AS `s1` ON `i`.descstrpos = `s1`.`Key`
//// LEFT JOIN strings AS `s2` ON `i`.DescStr2 = `s2`.`Key`
//// WHERE `Stat` = '$iscStat'
////";
//
//
// $sql = "SELECT String as string1
// FROM itemstatcost as i
// LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key`
// WHERE `Stat` = '$iscStat'";
// $string1 = PDO_FetchOne($sql);
//
// $sql = "SELECT String as string2
// FROM itemstatcost as i
// LEFT JOIN strings AS `s` ON `i`.DescStr2 = `s`.`Key`
// WHERE `Stat` = '$iscStat'";
// $string2 = PDO_FetchOne($sql);
//
// $sql = "SELECT descfunc
// FROM itemstatcost as i
// LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key`
// WHERE `Stat` = '$iscStat'";
// $descfunc = PDO_FetchOne($sql);
//
// $sql = "SELECT descval
// FROM itemstatcost as i
// LEFT JOIN strings AS `s` ON `i`.descstrpos = `s`.`Key`
// WHERE `Stat` = '$iscStat'";
// $descval = PDO_FetchOne($sql);
//
//
// //ddump();
//
// return ["string1"=>$string1, "string2"=>$string2, "descfunc"=>$descfunc, "descval"=>$descval];
// }
//
// function getIscStringsXXX($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 getIscStrings($iscStat) {
if (empty($this->strings)) {
$this->getStrings();
}
return ($this->strings[$iscStat]);
}
@ -363,15 +213,9 @@ class D2ItemData {
LEFT JOIN strings as s4
ON i.dgrpstr2= s4.Key
";
// where p.code = iscstat
$strings = PDO_FetchAll($sql);
//var_dump($strings);
foreach ($strings as $k => $v) {
$this->strings[$v['prop']] = $v;
}
}
}