wynnbuilder-forked-for-changes/js/builder/build.js

144 lines
5.8 KiB
JavaScript
Raw Normal View History

2022-07-29 18:22:39 +00:00
/**
* This file defines a class representing the player Build.
*
* Keeps track of equipment list, equip order, skillpoint assignment (initial),
* Aggregates item stats into a statMap to be used in damage calculation.
*/
const classDefenseMultipliers = new Map([ ["relik",0.60], ["bow",0.70], ["wand", 0.80], ["dagger", 1.0], ["spear", 1.0]]);
2021-01-10 10:02:23 +00:00
/*
* Class that represents a wynn player's build.
2021-01-17 21:01:20 +00:00
*/
2.0.3 update (#260) * Mage atree changes * Bump version to 2.0.3.1 just tree for now * Warrior tree :pray: * Shaman tree WIP some things are too jank to stay * Fixes to bamboozle behavior also echo was -60% instead of -65% in the file??? wtf * Shurikens damage boost by echo meme * Fix description text in echo, update old version atree file * Fix shaman tree thanks spegg! * Spegg atree changes assassin tree fixed many of my shaman mistakes and other changes we missed over the months somehow? * Updated archer ability tree Thanks @mr_me! All credit to them. * Fixes to spegg's fixes implement beast lore * Change how Chant of the Lunatic is calculated coursing restraints ingame is 15% damage bonus * Updated ingredients manually thanks @watermelon (snownlite)! * Forgor to bump ing db version * Fix ingredient display jank * 2.0.3 items (#259) * API update also add new IDs to a bunch of places... tech debt whyyy * Forgot to update ingreds... * Change heal power ID name to stack with tree abils, fix multi totem effect on totemic shatter and req for mana traps * Forgot to bump item db version * Implement major IDs not implemented: Gentle Glow, and Forest's Blessing damage increase (since I don't know the exact numbers) and radiance boost is not implemented (radiance is currently handled way too jank) might wait for buffs rework to handle radiance. * patch item searcher TODO: make this not disgusting... build_encode_decode file has gotten too big --------- Co-authored-by: hppeng <hppeng> Co-authored-by: RawFish69 <108964215+RawFish69@users.noreply.github.com>
2023-07-15 01:34:30 +00:00
class Build {
2021-01-07 00:02:10 +00:00
2021-01-17 21:01:20 +00:00
/**
* @description Construct a build.
* @param {Number} level : Level of the player.
2022-07-29 18:22:39 +00:00
* @param {String[]} items: List of equipment names that make up the build.
* In order: Helmet, Chestplate, Leggings, Boots, Ring1, Ring2, Brace, Neck, Tomes [x7].
* @param {Item} weapon: Weapon that this build is using.
2021-01-09 08:52:58 +00:00
*/
2022-06-23 10:42:18 +00:00
constructor(level, items, weapon){
2021-01-17 21:01:20 +00:00
if (level < 1) { //Should these be constants?
2021-01-07 00:02:10 +00:00
this.level = 1;
2021-01-17 21:01:20 +00:00
} else if (level > 106) {
2021-01-07 00:02:10 +00:00
this.level = 106;
2021-01-17 21:01:20 +00:00
} else if (level <= 106 && level >= 1) {
2021-01-07 00:02:10 +00:00
this.level = level;
2021-01-17 21:01:20 +00:00
} else if (typeof level === "string") {
this.level = level;
} else {
errors.push("Level is not a string or number.");
2021-01-07 00:02:10 +00:00
}
2021-01-17 21:01:20 +00:00
document.getElementById("level-choice").value = this.level;
2021-01-07 06:41:41 +00:00
this.availableSkillpoints = levelToSkillPoints(this.level);
this.equipment = items;
this.weapon = weapon;
2022-06-23 10:42:18 +00:00
this.items = this.equipment.concat([this.weapon]);
// calc skillpoints requires statmaps only
2022-06-23 10:42:18 +00:00
let result = calculate_skillpoints(this.equipment.map((x) => x.statMap), this.weapon.statMap);
2022-08-07 18:37:49 +00:00
const _equip_order = result[0].slice();
this.equip_order = [];
for (const item of _equip_order) {
if (item.get('category') === 'tome' || item.has('NONE')) { continue; }
this.equip_order.push(item);
2022-07-30 00:06:54 +00:00
}
// How many skillpoints the player had to assign (5 number)
2021-01-07 06:41:41 +00:00
this.base_skillpoints = result[1];
// How many skillpoints the build ended up with (5 number)
2021-01-07 06:41:41 +00:00
this.total_skillpoints = result[2];
// How many skillpoints assigned (1 number, sum of base_skillpoints)
2021-01-07 06:41:41 +00:00
this.assigned_skillpoints = result[3];
this.activeSetCounts = result[4];
2021-01-08 04:31:29 +00:00
this.initBuildStats();
2021-01-07 00:02:10 +00:00
}
/*Returns build in string format
2021-01-07 06:41:41 +00:00
*/
2021-01-07 00:02:10 +00:00
toString(){
2022-06-23 10:42:18 +00:00
return [this.equipment,this.weapon].flat();
2021-01-07 00:02:10 +00:00
}
2021-01-08 05:36:57 +00:00
/* Get all stats for this build. Stores in this.statMap.
2021-01-07 21:32:36 +00:00
@pre The build itself should be valid. No checking of validity of pieces is done here.
*/
2021-01-08 04:31:29 +00:00
initBuildStats(){
2022-06-26 11:08:54 +00:00
let staticIDs = ["hp", "eDef", "tDef", "wDef", "fDef", "aDef", "str", "dex", "int", "def", "agi", "damMobs", "defMobs"];
2021-01-08 04:31:29 +00:00
2022-06-24 10:35:03 +00:00
let must_ids = [
"eMdPct","eMdRaw","eSdPct","eSdRaw","eDamPct","eDamRaw","eDamAddMin","eDamAddMax",
"tMdPct","tMdRaw","tSdPct","tSdRaw","tDamPct","tDamRaw","tDamAddMin","tDamAddMax",
"wMdPct","wMdRaw","wSdPct","wSdRaw","wDamPct","wDamRaw","wDamAddMin","wDamAddMax",
"fMdPct","fMdRaw","fSdPct","fSdRaw","fDamPct","fDamRaw","fDamAddMin","fDamAddMax",
"aMdPct","aMdRaw","aSdPct","aSdRaw","aDamPct","aDamRaw","aDamAddMin","aDamAddMax",
"nMdPct","nMdRaw","nSdPct","nSdRaw","nDamPct","nDamRaw","nDamAddMin","nDamAddMax", // neutral which is now an element
"mdPct","mdRaw","sdPct","sdRaw","damPct","damRaw","damAddMin","damAddMax", // These are the old ids. Become proportional.
2.0.3 update (#260) * Mage atree changes * Bump version to 2.0.3.1 just tree for now * Warrior tree :pray: * Shaman tree WIP some things are too jank to stay * Fixes to bamboozle behavior also echo was -60% instead of -65% in the file??? wtf * Shurikens damage boost by echo meme * Fix description text in echo, update old version atree file * Fix shaman tree thanks spegg! * Spegg atree changes assassin tree fixed many of my shaman mistakes and other changes we missed over the months somehow? * Updated archer ability tree Thanks @mr_me! All credit to them. * Fixes to spegg's fixes implement beast lore * Change how Chant of the Lunatic is calculated coursing restraints ingame is 15% damage bonus * Updated ingredients manually thanks @watermelon (snownlite)! * Forgor to bump ing db version * Fix ingredient display jank * 2.0.3 items (#259) * API update also add new IDs to a bunch of places... tech debt whyyy * Forgot to update ingreds... * Change heal power ID name to stack with tree abils, fix multi totem effect on totemic shatter and req for mana traps * Forgot to bump item db version * Implement major IDs not implemented: Gentle Glow, and Forest's Blessing damage increase (since I don't know the exact numbers) and radiance boost is not implemented (radiance is currently handled way too jank) might wait for buffs rework to handle radiance. * patch item searcher TODO: make this not disgusting... build_encode_decode file has gotten too big --------- Co-authored-by: hppeng <hppeng> Co-authored-by: RawFish69 <108964215+RawFish69@users.noreply.github.com>
2023-07-15 01:34:30 +00:00
"rMdPct","rMdRaw","rSdPct","rSdRaw","rDamPct","rDamRaw","rDamAddMin","rDamAddMax", // rainbow (the "element" of all minus neutral). rSdRaw is rainraw
"healPct",
2022-06-24 10:35:03 +00:00
]
2021-01-07 21:32:36 +00:00
//Create a map of this build's stats
let statMap = new Map();
2021-01-08 04:31:29 +00:00
for (const staticID of staticIDs) {
statMap.set(staticID, 0);
2021-01-07 21:32:36 +00:00
}
2022-06-24 10:35:03 +00:00
for (const staticID of must_ids) {
statMap.set(staticID, 0);
}
statMap.set("hp", levelToHPBase(this.level));
2021-01-30 12:03:40 +00:00
let major_ids = new Set();
for (const item of this.items){
const item_stats = item.statMap;
for (let [id, value] of item_stats.get("maxRolls")) {
if (staticIDs.includes(id)) {
continue;
}
2021-01-08 04:31:29 +00:00
statMap.set(id,(statMap.get(id) || 0)+value);
}
for (const staticID of staticIDs) {
if (item_stats.get(staticID)) {
2022-06-23 09:23:56 +00:00
statMap.set(staticID, statMap.get(staticID) + item_stats.get(staticID));
}
2021-01-07 21:32:36 +00:00
}
if (item_stats.get("majorIds")) {
for (const major_id of item_stats.get("majorIds")) {
2021-07-23 07:47:13 +00:00
major_ids.add(major_id);
}
2021-01-30 12:03:40 +00:00
}
2021-01-07 21:32:36 +00:00
}
statMap.set('damMult', new Map());
statMap.set('defMult', new Map());
parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354753 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354749 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354744 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354739 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354735 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354730 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354688 -0700 Update recipes.json (#265) Change ratio of gems to oil as it has been updated in 2.0.4 > Updated the Jeweling Recipe Changes (Bracelet- 2:1 gems:oil, Necklaces- 3:1 gems:oil) https://forums.wynncraft.com/threads/2-0-4-full-changelog-new-bank-lootruns-more.310535/ Finish updating recipes.json why are there 4 versions of this file active at any given time Fix damage calculation for rainbow raw wow this bug has been here for a LONG time also bump version for ing db Bunch of bugfixes - new major ID - divine honor: reduce earth damage - radiance: don't boost tomes, xp/loot bonuses atree: - parry: minor typo - death magnet: marked dep - nightcloak knife: 15s desc Api v3 (#267) * Tweak ordering to be consistent internally * v3 items (#266) * item_wrapper script for updating item data with v3 endpoint * metadata from v3 * v3 item format For the purpose of wynnbuilder, additional mapping might be needed. * v3 item format additional mapping might be needed for wb * v3 compressed item json * clean item json v3 format * Update translate map to api v3 partially... we will need to redo scripts to flatmap all the items * Fix items for 2.0.4.3 finally * New ingredients (and parse script update) just realized I forgot to commit the parse script this whole time * Forgot to commit data files, and bump ing db version * Sketchily reverse translate major ids internalname and separate lookup table lol * Forgot to update data files todo: script should update all files at once * Bump wynn version number already outdated... * Forgot to update 2.0.4.3 major ids --------- Co-authored-by: hppeng <hppeng> Co-authored-by: RawFish69 <108964215+RawFish69@users.noreply.github.com> Add missing fields to ingreds missing ids and consumableIDs tags in some ingreds Fix missing properties in item search setup these should be unified maybe to avoid duplicated code Fix sacshrine dependency on fluid healing also: fix ": " in item searcher I managed to mess up all major ids note: major ids min file is generated along with atree. it uses numeric ids, not just json compress 2.0.4.4 update (#269) * 2.0.4.4 update Fix v3 item api debug script Implement hellfire (discombob disallow not happening yet) * Fix boiling blood implementation slightly more intuitive also, janky first pass implementation for hellfire * Atree default update Allow sliders to specify a default value, for puppet and boiling blood for now * Fix rainbow def display on items and build stats Calculate into raw def correctly * Atree backend improvements Allow major ids to have dependencies Implement cherry bomb new ver. (wooo replace_spell just works out of the box!) Add comments to atree.js * Fix name of normal items don't you love it when wynn api makes breaking changes for no reason * Misc bugfix Reckless abandon req Tempest new damage ID in search * Fix major id search and temblor desc * Fix blockers on mage * Fix flaming uppercut implementation * Force base dps display to display less digits * Tomes finally pulling from the API but still with alias feature enabled! * Lootrun tomes (finally?) cool? maybe? * Fix beachside set set bonus --------- Co-authored-by: hppeng <hppeng> Fix rainbow def display on items and build stats Calculate into raw def correctly Fix major id search and temblor desc Force base dps display to display less digits Fix beachside set set bonus Fix build decode error reading only 7 tome fields no matter what Give NONE tomes correct ids in load_tome i hate this system so much Allow searching for max/min of ranges Fix crafted item damage display in the process, also update powder calculation logic! Should be fully correct now... TL;DR: Weapon damage is floating point; item display is wrong; ingame displays (damage floaters and compass) are floored. Fluid healing now multiplicative with heal efficiency ID NOTE: this breaks backwards compatibility with older atree jsons. Do we care about this? Realizing how much of a nightmare it will be (and already is) to keep atree fully backwards compatible. Maybe that will be something left to `git clone` instead. fix (#274)
2023-11-08 04:31:12 +00:00
statMap.get('damMult').set('tome', statMap.get('damMobs'));
statMap.get('defMult').set('tome', statMap.get('defMobs'));
2021-01-30 12:03:40 +00:00
statMap.set("activeMajorIDs", major_ids);
for (const [setName, count] of this.activeSetCounts) {
const bonus = sets.get(setName).bonuses[count-1];
2021-01-10 03:40:15 +00:00
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]);
}
2021-01-10 03:40:15 +00:00
}
}
statMap.set("poisonPct", 0);
statMap.set("critDamPct", 0);
parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354753 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354749 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354744 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354739 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354735 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354730 -0700 parent 3e725eded882cb6d353ca9b37931cb959dcdf9dc author hppeng <hppeng> 1699417872 -0800 committer hppeng <hppeng> 1720354688 -0700 Update recipes.json (#265) Change ratio of gems to oil as it has been updated in 2.0.4 > Updated the Jeweling Recipe Changes (Bracelet- 2:1 gems:oil, Necklaces- 3:1 gems:oil) https://forums.wynncraft.com/threads/2-0-4-full-changelog-new-bank-lootruns-more.310535/ Finish updating recipes.json why are there 4 versions of this file active at any given time Fix damage calculation for rainbow raw wow this bug has been here for a LONG time also bump version for ing db Bunch of bugfixes - new major ID - divine honor: reduce earth damage - radiance: don't boost tomes, xp/loot bonuses atree: - parry: minor typo - death magnet: marked dep - nightcloak knife: 15s desc Api v3 (#267) * Tweak ordering to be consistent internally * v3 items (#266) * item_wrapper script for updating item data with v3 endpoint * metadata from v3 * v3 item format For the purpose of wynnbuilder, additional mapping might be needed. * v3 item format additional mapping might be needed for wb * v3 compressed item json * clean item json v3 format * Update translate map to api v3 partially... we will need to redo scripts to flatmap all the items * Fix items for 2.0.4.3 finally * New ingredients (and parse script update) just realized I forgot to commit the parse script this whole time * Forgot to commit data files, and bump ing db version * Sketchily reverse translate major ids internalname and separate lookup table lol * Forgot to update data files todo: script should update all files at once * Bump wynn version number already outdated... * Forgot to update 2.0.4.3 major ids --------- Co-authored-by: hppeng <hppeng> Co-authored-by: RawFish69 <108964215+RawFish69@users.noreply.github.com> Add missing fields to ingreds missing ids and consumableIDs tags in some ingreds Fix missing properties in item search setup these should be unified maybe to avoid duplicated code Fix sacshrine dependency on fluid healing also: fix ": " in item searcher I managed to mess up all major ids note: major ids min file is generated along with atree. it uses numeric ids, not just json compress 2.0.4.4 update (#269) * 2.0.4.4 update Fix v3 item api debug script Implement hellfire (discombob disallow not happening yet) * Fix boiling blood implementation slightly more intuitive also, janky first pass implementation for hellfire * Atree default update Allow sliders to specify a default value, for puppet and boiling blood for now * Fix rainbow def display on items and build stats Calculate into raw def correctly * Atree backend improvements Allow major ids to have dependencies Implement cherry bomb new ver. (wooo replace_spell just works out of the box!) Add comments to atree.js * Fix name of normal items don't you love it when wynn api makes breaking changes for no reason * Misc bugfix Reckless abandon req Tempest new damage ID in search * Fix major id search and temblor desc * Fix blockers on mage * Fix flaming uppercut implementation * Force base dps display to display less digits * Tomes finally pulling from the API but still with alias feature enabled! * Lootrun tomes (finally?) cool? maybe? * Fix beachside set set bonus --------- Co-authored-by: hppeng <hppeng> Fix rainbow def display on items and build stats Calculate into raw def correctly Fix major id search and temblor desc Force base dps display to display less digits Fix beachside set set bonus Fix build decode error reading only 7 tome fields no matter what Give NONE tomes correct ids in load_tome i hate this system so much Allow searching for max/min of ranges Fix crafted item damage display in the process, also update powder calculation logic! Should be fully correct now... TL;DR: Weapon damage is floating point; item display is wrong; ingame displays (damage floaters and compass) are floored. Fluid healing now multiplicative with heal efficiency ID NOTE: this breaks backwards compatibility with older atree jsons. Do we care about this? Realizing how much of a nightmare it will be (and already is) to keep atree fully backwards compatible. Maybe that will be something left to `git clone` instead. fix (#274)
2023-11-08 04:31:12 +00:00
statMap.set("healMult", new Map());
statMap.get('healMult').set('item', statMap.get('healPct'));
2021-01-07 06:41:41 +00:00
2021-01-08 04:31:29 +00:00
// The stuff relevant for damage calculation!!! @ferricles
statMap.set("atkSpd", this.weapon.statMap.get("atkSpd"));
2021-01-08 04:31:29 +00:00
this.statMap = statMap;
}
2021-01-07 00:02:10 +00:00
}