DescFunc 28,13 done, added ajax prop update, need work

This commit is contained in:
color.diff=auto 2021-05-03 00:27:13 -06:00
parent 2fcc98dddb
commit f008b24b1f
5 changed files with 97 additions and 40 deletions

View File

@ -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);
}

View File

@ -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("<p></p>");
$.each(props, function (i, v) {
console.log(props);
$('.item_desc').html("<p></p>");
$.each(props, function (i, v) {
if (v.par1) {
$s1 = '';
}
if(v.string){
$('.item_desc p').append(v.string[0]+"<br>");
$('.item_desc p').append('<li class="'+i+'">'+v.string[0]+"</li>");
}
});
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) {

View File

@ -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;
}

View File

@ -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 = '<span style="font-family: Lato; color: white; font-weight: 900">' . $value . "</span>";
$s1 = $params['string1'];
$s2 = $params['string2'];
$prop = $params['prop'];
$par = $params['par'];
$min = $params['min'];
$max = $params['max'];
$min = '<span style="color: white; font-weight: 900">' . $params['min'] . "</span>";
$max = '<span style="color: white; font-weight: 900">' . $params['max'] . "</span>";
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) {

View File

@ -1,6 +1,6 @@
<div style="height: 40px; margin: 40px 10px;"><h2>Unique Item Maker</h2></div>
<div class="row">
<div class="offset-6 col"><h3 style="font-family:fixed; font-size:80%;">Preview</h3>
<div class="offset-4 col"><h3 style="font-family:fixed; font-size:80%;">Preview</h3>
<div class="" style="height: 117px; background: url(/img/items/bg.png) no-repeat">
<img style="" class="item" src="">
<div class="item_desc">
@ -21,8 +21,8 @@
<div class="row" style="">
<div class="col-5">
<select name="uniqueitems" class="custom-select uniqueitems-select">
<option value=""></option>
<select style="height: 260px;padding:10px;margin-bottom: 20px;" name="uniqueitems" class="custom-select uniqueitems-select" multiple>
<!--<option value=""></option>-->
<?php foreach ($uniqueitems as $u) { ?>
<option value="<?php echo $u['index'] ?>"><?php echo $u['index'] ?></option>
<?php } ?>