Merge branch 'dev' of https://github.com/hppeng-wynn/hppeng-wynn.github.io into dev
This commit is contained in:
commit
3213e9e914
7 changed files with 133 additions and 57 deletions
12
build.js
12
build.js
|
@ -133,6 +133,7 @@ class Build{
|
|||
this.base_skillpoints = result[1];
|
||||
this.total_skillpoints = result[2];
|
||||
this.assigned_skillpoints = result[3];
|
||||
this.activeSetCounts = result[4];
|
||||
|
||||
// For strength boosts like warscream, vanish, etc.
|
||||
this.damageMultiplier = 1.0;
|
||||
|
@ -221,6 +222,17 @@ class Build{
|
|||
if (item.get(staticID)) { statMap.set(staticID, statMap.get(staticID) + item.get(staticID)); }
|
||||
}
|
||||
}
|
||||
for (const [setName, count] of this.activeSetCounts) {
|
||||
const bonus = sets[setName].bonuses[count-1];
|
||||
for (const id in bonus) {
|
||||
if (skp_order.includes(id)) {
|
||||
// pass. Don't include skillpoints in ids
|
||||
}
|
||||
else {
|
||||
statMap.set(id,(statMap.get(id) || 0)+bonus[id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The stuff relevant for damage calculation!!! @ferricles
|
||||
statMap.set("atkSpd", this.weapon.get("atkSpd"));
|
||||
|
|
|
@ -3,3 +3,5 @@ Damage calculator checking: https://its0x7.cf/build/
|
|||
Theme and overall inspiration: Wynndata (Dukio)
|
||||
- https://wynndata.tk
|
||||
|
||||
Additional Contributors:
|
||||
- QuantumNep (Layout code/layout ideas)
|
||||
|
|
61
display.js
61
display.js
|
@ -76,6 +76,38 @@ function apply_elemental_format(p_elem, id, suffix) {
|
|||
p_elem.appendChild(i_elem2);
|
||||
}
|
||||
|
||||
function displaySetBonuses(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('itemcenter');
|
||||
set_summary_elem.textContent = "Set Bonuses:";
|
||||
parent_div.append(set_summary_elem);
|
||||
|
||||
for (const [setName, count] of build.activeSetCounts) {
|
||||
let set_elem = document.createElement('p');
|
||||
set_elem.id = "set-"+setName;
|
||||
set_summary_elem.append(set_elem);
|
||||
|
||||
const bonus = sets[setName].bonuses[count-1];
|
||||
let mock_item = new Map();
|
||||
mock_item.set("fixID", true);
|
||||
mock_item.set("displayName", setName+" Set: "+count+"/"+sets[setName].items.length);
|
||||
let mock_minRolls = new Map();
|
||||
mock_item.set("minRolls", mock_minRolls);
|
||||
for (const id in bonus) {
|
||||
if (rolledIDs.includes(id)) {
|
||||
mock_minRolls.set(id, bonus[id]);
|
||||
}
|
||||
else {
|
||||
mock_item.set(id, bonus[id]);
|
||||
}
|
||||
}
|
||||
displayExpandedItem(mock_item, set_elem.id);
|
||||
}
|
||||
}
|
||||
|
||||
function displayBuildStats(build, parent_id){
|
||||
// Commands to "script" the creation of nice formatting.
|
||||
// #commands create a new element.
|
||||
|
@ -119,6 +151,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;
|
||||
|
@ -269,7 +314,7 @@ function displayExpandedItem(item, parent_id){
|
|||
" [ " + item.get("powders").map(x => powderNames.get(x)) + " ]";
|
||||
}
|
||||
}
|
||||
else if(rolledIDs.includes(id)&& item.get("minRolls").get(id)){ // && item.get("maxRolls").get(id) ){//rolled ID & non-0/non-null/non-und ID
|
||||
else if (rolledIDs.includes(id) && item.get("minRolls").get(id)){ // && item.get("maxRolls").get(id) ){//rolled ID & non-0/non-null/non-und ID
|
||||
let style = "positive";
|
||||
if (item.get("minRolls").get(id) < 0) {
|
||||
style = "negative";
|
||||
|
@ -306,11 +351,13 @@ function displayExpandedItem(item, parent_id){
|
|||
}//Just don't do anything if else
|
||||
}
|
||||
}
|
||||
let item_desc_elem = document.createElement('p');
|
||||
item_desc_elem.classList.add('itemp');
|
||||
item_desc_elem.classList.add('left');
|
||||
item_desc_elem.textContent = item.get("tier")+" "+item.get("type");
|
||||
parent_div.append(item_desc_elem);
|
||||
if (item.get("tier")) {
|
||||
let item_desc_elem = document.createElement('p');
|
||||
item_desc_elem.classList.add('itemp');
|
||||
item_desc_elem.classList.add('left');
|
||||
item_desc_elem.textContent = item.get("tier")+" "+item.get("type");
|
||||
parent_div.append(item_desc_elem);
|
||||
}
|
||||
}
|
||||
|
||||
function displayFixedID(active, id, value, elemental_format, style) {
|
||||
|
@ -525,7 +572,7 @@ function displaySpellDamage(parent_elem, build, spell, spellIdx) {
|
|||
save_damages.push(averageDamage);
|
||||
}
|
||||
else if (part.type == "heal") {
|
||||
let heal_amount = part.strength * build.getHealth() * Math.max(0, Math.min(1.5, 1 + 0.05 * stats.get("wDamPct")));
|
||||
let heal_amount = (part.strength * build.getHealth() * Math.max(0, Math.min(1.5, 1 + 0.05 * stats.get("wDamPct")))).toFixed(2);
|
||||
let healLabel = document.createElement("p");
|
||||
healLabel.textContent = heal_amount;
|
||||
healLabel.classList.add("damagep");
|
||||
|
|
13
index.html
13
index.html
|
@ -250,16 +250,12 @@
|
|||
<div class = "center build-weapon" id = "build-weapon" style = "grid-column:1;grid-row:3">
|
||||
<div class = "center" id = "build-weapon-stats"></div>
|
||||
</div>
|
||||
<div class = "center build-overall" id = "build-overall" style = "grid-column:4;grid-row:3">
|
||||
<p class="itemcenter">Overall Build Stats:<p>
|
||||
<div class = "center" id = "build-overall-stats"></div>
|
||||
</div>
|
||||
<div class = "center build-melee-stats" id = "build-melee-stats" style = "grid-column:3;grid-row:3">
|
||||
</div>
|
||||
<div class = "center build-order" id = "build-order" style = "grid-column:2;grid-row:3">
|
||||
</div>
|
||||
<!--div class = "center" id = "build-defense-stats" style = "grid-column:4;grid-row:3">
|
||||
</div-->
|
||||
<div class = "center" id = "build-defense-stats" style = "grid-column:4;grid-row:3">
|
||||
</div>
|
||||
</div>
|
||||
<div class = "spells">
|
||||
<div class = "center spell-info" id = "spell0" style = "grid-column:1;grid-row:1">
|
||||
|
@ -279,6 +275,11 @@
|
|||
<div class = "center" id = "spell3-info">Spell 4</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="misc">
|
||||
<div class = "center set-info" id = "set-info-div" style = "grid-column:1;grid-row:1">
|
||||
<div class = "center" id = "set-info">Set info</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="utils.js"></script>
|
||||
<script type="text/javascript" src="skillpoints.js"></script>
|
||||
|
|
|
@ -10,32 +10,47 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
if (item.get("reqs").every(x => x === 0)) {
|
||||
fixed.push(item);
|
||||
}
|
||||
else if (item.get("skillpoints").every(x => x === 0)) {
|
||||
// TODO hack: We will treat ALL set items as unsafe :(
|
||||
else if (item.get("skillpoints").every(x => x === 0) && item.get("set") === null) {
|
||||
noboost.push(item);
|
||||
}
|
||||
else {
|
||||
consider.push(item);
|
||||
}
|
||||
}
|
||||
function apply_skillpoints(skillpoints, item) {
|
||||
function apply_skillpoints(skillpoints, item, activeSetCounts) {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
skillpoints[i] += item.get("skillpoints")[i];
|
||||
}
|
||||
}
|
||||
|
||||
function remove_skillpoints(skillpoints, item) {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
skillpoints[i] -= item.get("skillpoints")[i];
|
||||
const setName = item.get("set");
|
||||
if (setName) { // undefined/null means no set.
|
||||
let setCount = activeSetCounts.get(setName);
|
||||
let old_bonus = {};
|
||||
if (setCount) {
|
||||
old_bonus = sets[setName].bonuses[setCount-1];
|
||||
activeSetCounts.set(setName, setCount + 1);
|
||||
}
|
||||
else {
|
||||
setCount = 0;
|
||||
activeSetCounts.set(setName, 1);
|
||||
}
|
||||
const new_bonus = sets[setName].bonuses[setCount];
|
||||
//let skp_order = ["str","dex","int","def","agi"];
|
||||
for (const i in skp_order) {
|
||||
const delta = (new_bonus[skp_order[i]] || 0) - (old_bonus[skp_order[i]] || 0);
|
||||
skillpoints[i] += delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out (naively) how many skillpoints need to be applied to get the current item to fit.
|
||||
// Doesn't handle -skp.
|
||||
function apply_to_fit(skillpoints, item, skillpoint_filter) {
|
||||
function apply_to_fit(skillpoints, item, skillpoint_filter, activeSetCounts) {
|
||||
let applied = [0, 0, 0, 0, 0];
|
||||
let total = 0;
|
||||
for (let i = 0; i < 5; i++) {
|
||||
if (item.get("skillpoints")[i] < 0 && skillpoint_filter[i] === true) {
|
||||
if (item.get("skillpoints")[i] < 0 && skillpoint_filter[i]) {
|
||||
applied[i] -= item.get("skillpoints")[i];
|
||||
total -= item.get("skillpoints")[i];
|
||||
}
|
||||
|
@ -49,24 +64,46 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
total += diff;
|
||||
}
|
||||
}
|
||||
|
||||
const setName = item.get("set");
|
||||
if (setName) { // undefined/null means no set.
|
||||
const setCount = activeSetCounts.get(setName);
|
||||
if (setCount) {
|
||||
const old_bonus = sets[setName].bonuses[setCount-1];
|
||||
const new_bonus = sets[setName].bonuses[setCount];
|
||||
//let skp_order = ["str","dex","int","def","agi"];
|
||||
for (const i in skp_order) {
|
||||
const delta = (new_bonus[skp_order[i]] || 0) - (old_bonus[skp_order[i]] || 0);
|
||||
if (delta < 0 && skillpoint_filter[i]) {
|
||||
applied[i] -= delta;
|
||||
total -= delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [applied, total];
|
||||
}
|
||||
|
||||
// Separate out the no req items and add them to the static skillpoint base.
|
||||
let static_skillpoints_base = [0, 0, 0, 0, 0]
|
||||
let static_activeSetCounts = new Map()
|
||||
for (const item of fixed) {
|
||||
apply_skillpoints(static_skillpoints_base, item);
|
||||
apply_skillpoints(static_skillpoints_base, item, static_activeSetCounts);
|
||||
}
|
||||
|
||||
let best = consider.concat(noboost);
|
||||
let final_skillpoints = static_skillpoints_base.slice();
|
||||
let best_skillpoints = [0, 0, 0, 0, 0];
|
||||
let best_total = Infinity;
|
||||
let best_activeSetCounts = static_activeSetCounts;
|
||||
|
||||
let allFalse = [false, false, false, false, false];
|
||||
if (consider.length > 0 || noboost.length > 0) {
|
||||
// Try every combination and pick the best one.
|
||||
for (let permutation of perm(consider)) {
|
||||
let activeSetCounts = new Map(static_activeSetCounts);
|
||||
|
||||
let has_skillpoint = allFalse.slice();
|
||||
|
||||
permutation = permutation.concat(noboost);
|
||||
|
@ -81,7 +118,7 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
let needed_skillpoints;
|
||||
let total_diff;
|
||||
for (const item of permutation) {
|
||||
result = apply_to_fit(skillpoints, item, has_skillpoint);
|
||||
result = apply_to_fit(skillpoints, item, has_skillpoint, activeSetCounts);
|
||||
needed_skillpoints = result[0];
|
||||
total_diff = result[1];
|
||||
|
||||
|
@ -89,40 +126,14 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
skillpoints_applied[i] += needed_skillpoints[i];
|
||||
skillpoints[i] += needed_skillpoints[i];
|
||||
}
|
||||
apply_skillpoints(skillpoints, item);
|
||||
apply_skillpoints(skillpoints, item, activeSetCounts);
|
||||
total_applied += total_diff;
|
||||
if (total_applied >= best_total) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if (total_applied < best_total) {
|
||||
// console.log(total_applied);
|
||||
// console.log(skillpoints_applied);
|
||||
// console.log("Iteration 2");
|
||||
// for (const item of permutation) {
|
||||
// console.log(item);
|
||||
//
|
||||
// remove_skillpoints(skillpoints, item);
|
||||
// console.log(skillpoints);
|
||||
// result = apply_to_fit(skillpoints, item, has_skillpoint);
|
||||
// needed_skillpoints = result[0];
|
||||
// total_diff = result[1];
|
||||
// for (let i = 0; i < 5; ++i) {
|
||||
// skillpoints_applied[i] += needed_skillpoints[i];
|
||||
// skillpoints[i] += needed_skillpoints[i];
|
||||
// }
|
||||
//
|
||||
// apply_skillpoints(skillpoints, item);
|
||||
// console.log(skillpoints);
|
||||
// console.log(total_diff);
|
||||
// total_applied += total_diff;
|
||||
// if (total_applied >= best_total) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
let pre = skillpoints.slice();
|
||||
result = apply_to_fit(skillpoints, weapon, allFalse.slice());
|
||||
result = apply_to_fit(skillpoints, weapon, allFalse.slice(), activeSetCounts);
|
||||
needed_skillpoints = result[0];
|
||||
total_diff = result[1];
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
|
@ -130,7 +141,7 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
skillpoints[i] += needed_skillpoints[i];
|
||||
}
|
||||
|
||||
apply_skillpoints(skillpoints, weapon);
|
||||
apply_skillpoints(skillpoints, weapon, activeSetCounts);
|
||||
total_applied += total_diff;
|
||||
|
||||
if (total_applied < best_total) {
|
||||
|
@ -140,13 +151,14 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
final_skillpoints = skillpoints;
|
||||
best_skillpoints = skillpoints_applied;
|
||||
best_total = total_applied;
|
||||
best_activeSetCounts = activeSetCounts;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
best_total = 0;
|
||||
result = apply_to_fit(final_skillpoints, weapon, allFalse.slice());
|
||||
result = apply_to_fit(final_skillpoints, weapon, allFalse.slice(), best_activeSetCounts);
|
||||
needed_skillpoints = result[0];
|
||||
total_diff = result[1];
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
|
@ -157,5 +169,5 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
best_total += total_diff;
|
||||
}
|
||||
let equip_order = fixed.concat(best);
|
||||
return [equip_order, best_skillpoints, final_skillpoints, best_total];
|
||||
return [equip_order, best_skillpoints, final_skillpoints, best_total, best_activeSetCounts];
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ a.link{
|
|||
text-align: left;
|
||||
}
|
||||
|
||||
.build, .spells {
|
||||
.build, .spells, .misc {
|
||||
padding: 2%;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
|
@ -58,7 +58,7 @@ a.link{
|
|||
background: #110110;
|
||||
}
|
||||
|
||||
.build-helmet, .build-chestplate, .build-leggings, .build-boots, .build-ring1, .build-ring2, .build-bracelet, .build-necklace, .build-weapon, .build-order, .build-overall, .build-melee-stats, .spell-info {
|
||||
.build-helmet, .build-chestplate, .build-leggings, .build-boots, .build-ring1, .build-ring2, .build-bracelet, .build-necklace, .build-weapon, .build-order, .build-overall, .build-melee-stats, .spell-info, .set-info {
|
||||
color: #aaa;
|
||||
background: #110110;
|
||||
border: 3px solid #BCBCBC;
|
||||
|
|
4
test.js
4
test.js
|
@ -11,7 +11,7 @@ console.log(url_tag);
|
|||
* END testing section
|
||||
*/
|
||||
|
||||
const BUILD_VERSION = "3.2";
|
||||
const BUILD_VERSION = "4.0";
|
||||
|
||||
document.getElementById("header").textContent = "Wynn build calculator "+BUILD_VERSION+" (db version "+DB_VERSION+")";
|
||||
|
||||
|
@ -96,6 +96,7 @@ for (const it of itemTypes) {
|
|||
itemLists.set(it, []);
|
||||
}
|
||||
let itemMap = new Map();
|
||||
/* Mapping from item names to set names. */
|
||||
let idMap = new Map();
|
||||
|
||||
/*
|
||||
|
@ -423,6 +424,7 @@ function calculateBuildStats() {
|
|||
}
|
||||
|
||||
displayBuildStats(player_build, "build-overall-stats");
|
||||
displaySetBonuses(player_build, "set-info");
|
||||
|
||||
let parent_elem = document.getElementById("build-melee-stats");
|
||||
let meleeStats = player_build.getMeleeStats();
|
||||
|
|
Loading…
Add table
Reference in a new issue