Created
June 7, 2023 20:38
-
-
Save xdjoshuaaz/91be977eb6bcd07bad810461caec904f to your computer and use it in GitHub Desktop.
eco game calc sync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var data = await fetch("http://eco-web-server/elixr-mods/framework/api/v1/get-prices/false").then(resp => resp.json()) | |
| var calcIngredients = getAllAngularRootElements()[0].__ngContext__.filter(x => x && typeof x === "object" && "craftingParentComponent" in x)[0].craftingParentComponent.ingredientsComponent.itemIngredients; | |
| var supermap = calcIngredients.reduce((map, obj) => { | |
| map[obj.name] = obj.nameID; | |
| map[obj.nameID] = obj.name; | |
| return map; | |
| }, {}) | |
| for (var ingredient of ingredients) { | |
| var id = ingredient.id; // calc id = BasicUpgrade1Item | |
| var name = supermap[id] || id; // eco name = Basic Upgrade 1 | |
| if (!(name in pricesByTagItemName)) { | |
| continue; | |
| } | |
| var prices = pricesByTagItemName[name]; | |
| var minPrice = Math.min.apply(null, prices.map(x => x.Price)); | |
| var maxPrice = Math.max.apply(null, prices.map(x => x.Price)); | |
| if (ingredient.pr !== minPrice) { | |
| console.log(`ingredient ${name} was ${ingredient.pr}, is now ${minPrice}/${maxPrice}`); | |
| ingredient.pr = minPrice; | |
| } | |
| } | |
| window.localStorage.ingredients = JSON.stringify(ingredients); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment