This commit is contained in:
ferricles 2021-03-22 14:33:13 -07:00
commit 4cf385828b
4 changed files with 33 additions and 13 deletions

View file

@ -120,7 +120,7 @@ class Build{
if (helmet.statMap.get("type") !== "helmet") { if (helmet.statMap.get("type") !== "helmet") {
throw new Error("Not a helmet"); throw new Error("Not a helmet");
} }
this.powders[0] = this.powders[0].slice(0,helmet.statMap.slots); this.powders[0] = this.powders[0].slice(0,helmet.statMap.get("slots"));
helmet.statMap.set("powders",this.powders[0].slice()); helmet.statMap.set("powders",this.powders[0].slice());
helmet.applyPowders(); helmet.applyPowders();
this.helmet = helmet.statMap; this.helmet = helmet.statMap;
@ -148,7 +148,7 @@ class Build{
if (chestplate.statMap.get("type") !== "chestplate") { if (chestplate.statMap.get("type") !== "chestplate") {
throw new Error("Not a chestplate"); throw new Error("Not a chestplate");
} }
this.powders[1] = this.powders[1].slice(0,chestplate.statMap.slots); this.powders[1] = this.powders[1].slice(0,chestplate.statMap.get("slots"));
chestplate.statMap.set("powders",this.powders[1].slice()); chestplate.statMap.set("powders",this.powders[1].slice());
chestplate.applyPowders(); chestplate.applyPowders();
this.chestplate = chestplate.statMap; this.chestplate = chestplate.statMap;
@ -174,7 +174,7 @@ class Build{
if (leggings.statMap.get("type") !== "leggings") { if (leggings.statMap.get("type") !== "leggings") {
throw new Error("Not a leggings"); throw new Error("Not a leggings");
} }
this.powders[2] = this.powders[2].slice(0,leggings.statMap.slots); this.powders[2] = this.powders[2].slice(0,leggings.statMap.get("slots"));
leggings.statMap.set("powders",this.powders[2].slice()); leggings.statMap.set("powders",this.powders[2].slice());
leggings.applyPowders(); leggings.applyPowders();
this.leggings = leggings.statMap; this.leggings = leggings.statMap;
@ -200,7 +200,7 @@ class Build{
if (boots.statMap.get("type") !== "boots") { if (boots.statMap.get("type") !== "boots") {
throw new Error("Not a boots"); throw new Error("Not a boots");
} }
this.powders[3] = this.powders[3].slice(0,boots.statMap.slots); this.powders[3] = this.powders[3].slice(0,boots.statMap.get("slots"));
boots.statMap.set("powders",this.powders[3].slice()); boots.statMap.set("powders",this.powders[3].slice());
boots.applyPowders(); boots.applyPowders();
this.boots = boots.statMap; this.boots = boots.statMap;
@ -322,7 +322,7 @@ class Build{
} else if (this.weapon.get("crafted")) { //customs can also be crafted, but custom takes priority. } else if (this.weapon.get("crafted")) { //customs can also be crafted, but custom takes priority.
this.craftedItems.push(weapon); this.craftedItems.push(weapon);
} }
this.powders[4] = this.powders[4].slice(0,this.weapon.slots); this.powders[4] = this.powders[4].slice(0,this.weapon.get("slots"));
this.weapon.set("powders",this.powders[4].slice()); this.weapon.set("powders",this.powders[4].slice());
document.getElementsByClassName("powder-specials")[0].style.display = "grid"; document.getElementsByClassName("powder-specials")[0].style.display = "grid";
} catch (Error) { } catch (Error) {

View file

@ -91,6 +91,10 @@ let powderInputs = [
function populateItemList(type) { function populateItemList(type) {
let item_list = document.getElementById(type+"-items"); let item_list = document.getElementById(type+"-items");
for (const item of itemLists.get(type)) { for (const item of itemLists.get(type)) {
let item_obj = itemMap.get(item);
if (item_obj["restrict"] && item_obj["restrict"] === "DEPRECATED") {
continue;
}
let el = document.createElement("option"); let el = document.createElement("option");
el.value = item; el.value = item;
item_list.appendChild(el); item_list.appendChild(el);
@ -132,6 +136,10 @@ function init() {
let ring1_list = document.getElementById("ring1-items"); let ring1_list = document.getElementById("ring1-items");
let ring2_list = document.getElementById("ring2-items"); let ring2_list = document.getElementById("ring2-items");
for (const ring of itemLists.get("ring")) { for (const ring of itemLists.get("ring")) {
let item_obj = itemMap.get(ring);
if (item_obj["restrict"] && item_obj["restrict"] === "DEPRECATED") {
continue;
}
let el1 = document.createElement("option"); let el1 = document.createElement("option");
let el2 = document.createElement("option"); let el2 = document.createElement("option");
el1.value = ring; el1.value = ring;
@ -146,6 +154,10 @@ function init() {
let weapon_list = document.getElementById("weapon-items"); let weapon_list = document.getElementById("weapon-items");
for (const weaponType of weaponTypes) { for (const weaponType of weaponTypes) {
for (const weapon of itemLists.get(weaponType)) { for (const weapon of itemLists.get(weaponType)) {
let item_obj = itemMap.get(weapon);
if (item_obj["restrict"] && item_obj["restrict"] === "DEPRECATED") {
continue;
}
let el = document.createElement("option"); let el = document.createElement("option");
el.value = weapon; el.value = weapon;
weapon_list.appendChild(el); weapon_list.appendChild(el);

View file

@ -4,6 +4,9 @@ class NameQuery {
constructor(string) { this.queryString = string.toLowerCase(); } constructor(string) { this.queryString = string.toLowerCase(); }
filter(item) { filter(item) {
if (item.get("restrict") && item.get("restrict") === "DEPRECATED") {
return false;
}
return (item.get("displayName").toLowerCase().includes(this.queryString)); return (item.get("displayName").toLowerCase().includes(this.queryString));
} }

View file

@ -10,7 +10,8 @@ function calculate_skillpoints(equipment, weapon) {
if (item.get("crafted")) { if (item.get("crafted")) {
crafted.push(item); crafted.push(item);
} }
else if (item.get("reqs").every(x => x === 0)) { else if (item.get("reqs").every(x => x === 0) && item.get("skillpoints").every(x => x >= 0)) {
// All reqless item without -skillpoints.
fixed.push(item); fixed.push(item);
} }
// TODO hack: We will treat ALL set items as unsafe :( // TODO hack: We will treat ALL set items as unsafe :(
@ -52,15 +53,15 @@ function calculate_skillpoints(equipment, weapon) {
let total = 0; let total = 0;
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
if (item.get("skillpoints")[i] < 0 && skillpoint_min[i]) { if (item.get("skillpoints")[i] < 0 && skillpoint_min[i]) {
unadjusted = skillpoints[i] + item.get("skillpoints")[i]; const unadjusted = skillpoints[i] + item.get("skillpoints")[i];
delta = skillpoint_min[i] - unadjusted; const delta = skillpoint_min[i] - unadjusted;
if (delta > 0) { if (delta > 0) {
applied[i] += delta; applied[i] += delta;
total += delta; total += delta;
} }
} }
if (item.get("reqs")[i] == 0) continue; if (item.get("reqs")[i] == 0) continue;
skillpoint_min[i] = Math.max(skillpoint_min[i], item.get("reqs")[i] + item.get("skillpoints")[i]); skillpoint_min[i] = Math.max(skillpoint_min[i], item.get("reqs")[i]);// + item.get("skillpoints")[i]);
const req = item.get("reqs")[i]; const req = item.get("reqs")[i];
const cur = skillpoints[i]; const cur = skillpoints[i];
if (req > cur) { if (req > cur) {
@ -78,10 +79,14 @@ function calculate_skillpoints(equipment, weapon) {
const new_bonus = sets[setName].bonuses[setCount]; const new_bonus = sets[setName].bonuses[setCount];
//let skp_order = ["str","dex","int","def","agi"]; //let skp_order = ["str","dex","int","def","agi"];
for (const i in skp_order) { for (const i in skp_order) {
const delta = (new_bonus[skp_order[i]] || 0) - (old_bonus[skp_order[i]] || 0); const set_delta = (new_bonus[skp_order[i]] || 0) - (old_bonus[skp_order[i]] || 0);
if (delta < 0 && skillpoint_min[i]) { if (set_delta < 0 && skillpoint_min[i]) {
applied[i] -= delta; const unadjusted = skillpoints[i] + set_delta;
total -= delta; const delta = skillpoint_min[i] - unadjusted;
if (delta > 0) {
applied[i] += delta;
total += delta;
}
} }
} }
} }