wynnbuilder-idk/js/load_ing.js
hppeng 1d6b302f38 parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354753 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354749 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354744 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354739 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354735 -0700

parent 3e725eded8
author hppeng <hppeng> 1699417872 -0800
committer hppeng <hppeng> 1720354730 -0700

parent 3e725eded8
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)
2024-07-07 05:19:16 -07:00

245 lines
7.8 KiB
JavaScript

const ING_DB_VERSION = 32;
// @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.js
let idb;
let ireload = false;
let iload_in_progress = false;
let iload_complete = false;
let ings;
let recipes;
let ingMap = new Map();
let ingList = [];
let recipeMap;
let recipeList = [];
let ingIDMap = new Map();
let recipeIDMap;
/*
* Load item set from local DB. Calls init() on success.
*/
async function ing_load_local() {
return new Promise(function(resolve, reject) {
let get_tx = idb.transaction(['ing_db', 'recipe_db'], 'readonly');
let ings_store = get_tx.objectStore('ing_db');
let recipes_store = get_tx.objectStore('recipe_db');
let request3 = ings_store.getAll();
request3.onerror = function(event) {
reject("Could not read local ingredient db...");
}
request3.onsuccess = function(event) {
console.log("Successfully read local ingredient db.");
}
let request4 = recipes_store.getAll();
request4.onerror = function(event) {
reject("Could not read local recipe db...");
}
request4.onsuccess = function(event) {
console.log("Successfully read local recipe db.");
}
get_tx.oncomplete = function(event) {
ings = request3.result;
recipes = request4.result;
init_ing_maps();
iload_complete = true;
idb.close();
resolve()
}
});
}
function clean_ing(ing) {
if (ing.remapID === undefined) {
if (ing.displayName === undefined) {
ing.displayName = ing.name;
}
}
}
async function load_ings_old_version(version_str) {
iload_in_progress = true;
let getUrl = window.location;
let baseUrl = `${getUrl.protocol}//${getUrl.host}/`;
// No random string -- we want to use caching
let url = `${baseUrl}/data/${version_str}/ingreds.json`;
let result = await (await fetch(url)).json();
ings = result;
for (const id in ings) {
clean_ing(ings[id]);
}
url = `${baseUrl}/data/${version_str}/recipes.json`;
result = await (await fetch(url)).json();
recipes = result.recipes;
init_maps();
iload_complete = true;
}
/*
* Load item set from remote DB (aka a big json file). Calls init() on success.
*/
async function load_ings() {
let getUrl = window.location;
let baseUrl = `${getUrl.protocol}//${getUrl.host}/`;
// "Random" string to prevent caching!
let url = baseUrl + "/ingreds_compress.json?"+new Date();
let result = await (await fetch(url)).json();
result = await (await fetch(url)).json();
ings = result;
url = baseUrl + "/recipes_compress.json?"+new Date();
result = await (await fetch(url)).json();
recipes = result.recipes;
// https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/clear
/*let clear_tx2 = db.transaction(['ing_db'], 'readwrite');
let clear_ings = clear_tx2.objectStore('ing_db');
let clear_tx3 = db.transaction(['recipe_db'], 'readwrite');
let clear_recipes = clear_tx3.objectStore('recipe_db');
await clear_ings.clear();
await clear_recipes.clear();
await clear_tx2.complete;
await clear_tx3.complete;*/
let add_promises = [];
let add_tx2 = idb.transaction(['ing_db'], 'readwrite');
let ings_store = add_tx2.objectStore('ing_db');
for (const id in ings) {
clean_ing(ings[id]);
add_promises.push(ings_store.add(ings[id], id));
}
let add_tx3 = idb.transaction(['recipe_db'], 'readwrite');
let recipes_store = add_tx3.objectStore('recipe_db');
for (const recipe in recipes) {
add_promises.push(recipes_store.add(recipes[recipe], recipe));
}
add_promises.push(add_tx2.complete);
add_promises.push(add_tx3.complete);
await Promise.all(add_promises);
init_ing_maps();
iload_complete = true;
idb.close();
}
async function load_ing_init() {
return new Promise((resolve, reject) => {
let request = window.indexedDB.open("ing_db", ING_DB_VERSION)
request.onerror = function() {
reject("DB failed to open...");
}
request.onsuccess = async function() {
idb = request.result;
if (iload_in_progress) {
while (!iload_complete) {
await sleep(100);
}
console.log("Skipping load...")
}
else {
iload_in_progress = true
if (ireload) {
console.log("Using new data...")
await load_ings();
}
else {
console.log("Using stored data...")
await ing_load_local();
}
}
resolve();
}
request.onupgradeneeded = function(e) {
ireload = true;
let idb = e.target.result;
try {
idb.deleteObjectStore('ing_db');
}
catch (error) {
console.log("Could not delete ingredient DB. This is probably fine");
}
try {
idb.deleteObjectStore('recipe_db');
}
catch (error) {
console.log("Could not delete recipe DB. This is probably fine");
}
idb.createObjectStore('ing_db');
idb.createObjectStore('recipe_db');
console.log("DB setup complete...");
}
});
}
function init_ing_maps() {
recipeMap = new Map();
recipeIDMap = new Map();
let ing = {
name: "No Ingredient",
displayName: "No Ingredient",
tier: 0,
lvl: 0,
skills: ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING", "COOKING", "ALCHEMISM", "SCRIBING"],
ids: {},
itemIDs: {"dura": 0, "strReq": 0, "dexReq": 0,"intReq": 0,"defReq": 0,"agiReq": 0,},
consumableIDs: {"dura": 0, "charges": 0},
posMods: {"left": 0, "right": 0, "above": 0, "under": 0, "touching": 0, "notTouching": 0},
id: 4000
};
ingMap.set(ing.displayName, ing);
ingList.push(ing.displayName);
ingIDMap.set(ing.id, ing.displayName);
let numerals = new Map([[1, "I"], [2, "II"], [3, "III"], [4, "IV"], [5, "V"], [6, "VI"]]);
// pairs of (dura, req)
let powder_ing_info = [
[-35,0],[-52.5,0],[-70,10],[-91,20],[-112,28],[-133,36]
];
for (let i = 0; i < 5; i ++) {
for (let powder_tier = 0; powder_tier < 6; ++powder_tier) {
powder_info = powder_ing_info[powder_tier];
let ing = {
name: "" + damageClasses[i+1] + " Powder " + numerals.get(powder_tier + 1),
tier: 0,
lvl: 0,
skills: ["ARMOURING", "TAILORING", "WEAPONSMITHING", "WOODWORKING", "JEWELING"],
ids: {},
isPowder: true,
pid: 6*i + powder_tier,
itemIDs: {"dura": powder_info[0], "strReq": 0, "dexReq": 0,"intReq": 0,"defReq": 0,"agiReq": 0},
consumableIDs: {"dura": 0, "charges": 0},
posMods: {"left": 0, "right": 0, "above": 0, "under": 0, "touching": 0, "notTouching": 0}
};
ing.id = 4001 + ing.pid;
ing.displayName = ing.name;
ing.itemIDs[skp_order[i] + "Req"] = powder_info[1];
ingMap.set(ing.displayName, ing);
ingList.push(ing.displayName);
ingIDMap.set(ing.id, ing.displayName);
}
}
for (const ing of ings) {
ingMap.set(ing.displayName, ing);
ingList.push(ing.displayName);
ingIDMap.set(ing.id, ing.displayName);
}
for (const recipe of recipes) {
recipeMap.set(recipe.name, recipe);
recipeList.push(recipe.name);
recipeIDMap.set(recipe.id, recipe.name);
}
}