Merge branch 'master' into dev

This commit is contained in:
b 2021-01-09 21:49:34 -06:00
commit ad355127d4
3 changed files with 46 additions and 0 deletions

View file

@ -197,11 +197,29 @@ class Build{
return damages_results.concat([totalDamNorm,totalDamCrit,normDPS,critDPS,avgDPS,adjAtkSpd]);
}
/*
* Gets a list of active sets and set counts.
*/
getSetBonuses() {
let activeSetCounts = new Map()
for (const item of this.items) {
console.log(item.get("name"));
const setName = setMap.get(item.get("name"));
if (setName) { // undefined/null means no set.
activeSetCounts.set(setName, (activeSetCounts.get(setName) || 0) + 1);
}
}
return activeSetCounts;
}
/* Get all stats for this build. Stores in this.statMap.
@pre The build itself should be valid. No checking of validity of pieces is done here.
*/
initBuildStats(){
let activeSetCounts = this.getSetBonuses();
this.activeSetCounts = activeSetCounts;
let staticIDs = ["hp", "eDef", "tDef", "wDef", "fDef", "aDef"];
//Create a map of this build's stats
@ -221,6 +239,12 @@ class Build{
if (item.get(staticID)) { statMap.set(staticID, statMap.get(staticID) + item.get(staticID)); }
}
}
for (const [setName, count] of activeSetCounts) {
const bonus = sets[setName].bonuses[count-1];
for (const id in bonus) {
statMap.set(id,(statMap.get(id) || 0)+bonus[id]);
}
}
// The stuff relevant for damage calculation!!! @ferricles
statMap.set("atkSpd", this.weapon.get("atkSpd"));

View file

@ -119,6 +119,19 @@ function displayBuildStats(build, parent_id){
setHTML(parent_id, "");
let parent_div = document.getElementById(parent_id);
let set_summary_elem = document.createElement('p');
set_summary_elem.classList.add('itemp');
set_summary_elem.classList.add('left');
set_summary_elem.textContent = "Set Summary:";
parent_div.append(set_summary_elem);
for (const [setName, count] of build.activeSetCounts) {
let set_elem = document.createElement('p');
set_elem.classList.add('itemp');
set_elem.classList.add('left');
set_elem.textContent = " "+setName+" Set: "+count+"/"+sets[setName].items.length;
set_summary_elem.append(set_elem);
}
let stats = build.statMap;
let active_elem;

View file

@ -96,6 +96,8 @@ for (const it of itemTypes) {
itemLists.set(it, []);
}
let itemMap = new Map();
/* Mapping from item names to set names. */
let setMap = new Map();
let idMap = new Map();
/*
@ -160,6 +162,13 @@ function init() {
idMap.set(item.id, item.displayName);
}
for (const setName in sets) {
const set = sets[setName];
for (const itemName of set.items) {
setMap.set(itemName, setName);
}
}
for (const armorType of armorTypes) {
populateItemList(armorType);
// Add change listener to update armor slots.