From f008b24b1f37770e06a9c972145390ae8f1bf43f Mon Sep 17 00:00:00 2001 From: "color.diff=auto" Date: Mon, 3 May 2021 00:27:13 -0600 Subject: [PATCH] DescFunc 28,13 done, added ajax prop update, need work --- ajax/uniqueitems.php | 30 +++++++++++++++---- res/app.js | 63 ++++++++++++++++++++++++++-------------- res/style.css | 8 +++-- src/D2ItemDesc.php | 30 ++++++++++++++----- src/tabs/UniqueItems.php | 6 ++-- 5 files changed, 97 insertions(+), 40 deletions(-) diff --git a/ajax/uniqueitems.php b/ajax/uniqueitems.php index 27157ed..a823fd4 100644 --- a/ajax/uniqueitems.php +++ b/ajax/uniqueitems.php @@ -147,21 +147,21 @@ if ($cmd == "getUniqueItem") { //var_dump($return); - // 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 $value = $v['par1'] ?? $v['min1']; - + $params = [ 'string1' => $v['desc']['string1'], 'string2' => $v['desc']['string2'], 'descfunc' => $v['desc']['descfunc'], 'descval' => $v['desc']['descval'], - "par" => $return['par'.$counter], - "min" => $return['min'.$counter], - "max" => $return['max'.$counter] + "prop" => $return['prop' . $counter], + "par" => $return['par' . $counter], + "min" => $return['min' . $counter], + "max" => $return['max' . $counter] ]; if (!empty($v['desc'])) { @@ -258,4 +258,24 @@ if ($cmd == 'search') { } } echo $html; +} + + +/* + * @cmd = getString + * + * + * + * + */ +if ($cmd == 'getString') { + $prop = $_GET['prop']; + + $sql = "SELECT stat1,stat2,stat3,stat4,stat5,stat6,stat7 FROM `properties` WHERE `code` = '$prop'"; + $stat = array_filter(PDO_FetchRow($sql)); + + $s = array_filter(getIscStrings($stat['stat1'])); + + header('Content-Type: application/json'); + echo json_encode($s, JSON_INVALID_UTF8_IGNORE); } \ No newline at end of file diff --git a/res/app.js b/res/app.js index 8352094..96f9df2 100644 --- a/res/app.js +++ b/res/app.js @@ -45,7 +45,9 @@ function search() { }); } - +function capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); +} $(document).ready(function () { $('.form-text').hide(); @@ -137,30 +139,55 @@ $(document).ready(function () { $(this).fadeOut("slow"); }); + + + $('').change(function () { + if (this.checked) { + $('option[disabled="disabled"]').hide(); + } else { + $('option[disabled="disabled"]').show(); + } + }); + + + + + // every time we change a prop dropdown, + // + // 1 send to server, + // 2 grab string, + // 3 update item display + $('select[name^="prop"]').change(function(){ + prop = capitalizeFirstLetter($(this).attr("name")); + val = escape(this.value); + $.get("/ajax/uniqueitems.php?cmd=getString&prop=" + val, function (data) { + console.log(data) + $("."+prop).html(data.string1); + }); + }); + + + + + + + + + // cmd = getUniqueItem $('.uniqueitems-select').change(function () { $(".item").attr("src", "/img/items/1.png"); $.get("/ajax/uniqueitems.php?cmd=getUniqueItem&index=" + this.value, function (data) { props = data.props; + $('.item_desc').html("

"); + $.each(props, function (i, v) { - console.log(props); - $('.item_desc').html("

"); - $.each(props, function (i, v) { - - if (v.par1) { - $s1 = ''; - } - - if(v.string){ - $('.item_desc p').append(v.string[0]+"
"); + $('.item_desc p').append('
  • '+v.string[0]+"
  • "); } - }); - - invImg = "/img/items/" + data.invfile + ".png"; $(".item").attr("src", invImg); @@ -175,14 +202,6 @@ $(document).ready(function () { }); - - - - - - - - // cmd = sortBy $('input[name="sort"]').change(function () { $.get("/ajax/uniqueitems.php?cmd=sortBy&sort=" + this.value, function (data) { diff --git a/res/style.css b/res/style.css index 5ef20e4..a3e82ae 100644 --- a/res/style.css +++ b/res/style.css @@ -167,7 +167,7 @@ option { .item_desc { height: auto; - width: 420px; + width: 640px; position: absolute; left: 110px; top: 23px; @@ -180,6 +180,10 @@ option { } .item_desc p { - font-size: 14px; + font-size: 13px; color: #4169E1; +} + +ul, li, ul li { + list-style-type: none; } \ No newline at end of file diff --git a/src/D2ItemDesc.php b/src/D2ItemDesc.php index d40b9d2..b2753ab 100644 --- a/src/D2ItemDesc.php +++ b/src/D2ItemDesc.php @@ -173,6 +173,16 @@ class D2ItemDesc { '20' => 'StrSklTabItem21' ]; + public $charClass = [ + "ama" => "Amazon", + "sor" => "Sorceress", + "nec" => "Necromancer", + "pal" => "Paladin", + "bar" => "Barbarian", + "dru" => "Druid", + "ass" => "Assassin" + ]; + public function getDesc($value, $params = []) { if (empty($params)) return false; @@ -180,10 +190,10 @@ class D2ItemDesc { $v = '' . $value . ""; $s1 = $params['string1']; $s2 = $params['string2']; + $prop = $params['prop']; $par = $params['par']; - $min = $params['min']; - $max = $params['max']; - + $min = '' . $params['min'] . ""; + $max = '' . $params['max'] . ""; foreach ($this->skilltabs as $s) { $sql = "SELECT `String` FROM `strings` WHERE `Key`='$s'"; $this->skilltabsDesc[] = PDO_FetchRow($sql); @@ -207,7 +217,7 @@ class D2ItemDesc { } if ($params['descfunc'] == 3) { - $this->str = "$v $s1"; + $this->str = "$s1"; } if ($params['descfunc'] == 4) { @@ -246,7 +256,7 @@ class D2ItemDesc { } if ($params['descfunc'] == 13) { - $this->str = "+$v to [class] Skill Levels"; + $this->str = "+$min to {$this->charClass[$prop]} Skill Levels"; } if ($params['descfunc'] == 14) { @@ -257,9 +267,9 @@ WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR `StrSkillTab2`='{$this->skilltabs[$par]}' OR `StrSkillTab3`='{$this->skilltabs[$par]}'"; - $x = PDO_FetchOne($sql); + $class = PDO_FetchOne($sql); - $this->str = "+$min - $max{$this->skilltabsDescClean[$par]['String']} Skill Levels ([$x] Only)"; + $this->str = "+$min-$max{$this->skilltabsDescClean[$par]['String']} Skill Levels ($class Only)"; } if ($params['descfunc'] == 15) { $this->str = "[chance]% to case [slvl] [skill] on [event]"; @@ -313,7 +323,11 @@ WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR } if ($params['descfunc'] == 28) { - $this->str = "+$v to [skill] "; + $sql = "SELECT `skill` FROM `skills` WHERE `skilldesc`='$par'"; + $skill = PDO_FetchOne($sql); + + + $this->str = "+$min to $skill "; } } else if ($params['descval'] == 0) { if ($params['descfunc'] == 1) { diff --git a/src/tabs/UniqueItems.php b/src/tabs/UniqueItems.php index d21bd9d..5f5fe64 100644 --- a/src/tabs/UniqueItems.php +++ b/src/tabs/UniqueItems.php @@ -1,6 +1,6 @@

    Unique Item Maker

    -

    Preview

    +

    Preview

    @@ -21,8 +21,8 @@
    - +