diff --git a/Cargo.toml b/Cargo.toml index 32016cd..78ff695 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,15 +4,15 @@ version = "1.4.0" edition = "2024" [dependencies] -askama = "0.14" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -toml = "0.8" -tracing = "0.1" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } -itertools = "0.14" -blake3 = "1.8" -ordered-float = { version = "5.0", features = ["serde"] } +askama = "0.14.0" +serde = { version = "1.0.228", features = ["derive"] } +serde_json = "1.0.145" +toml = "0.9.8" +tracing = "0.1.41" +tracing-subscriber = { version = "0.3.20", features = ["env-filter"] } +itertools = "0.14.0" +blake3 = "1.8.2" +ordered-float = { version = "5.1.0", features = ["serde"] } [features] default = ["bbs", "ddd", "kh3", "kh2", "kh1"] diff --git a/input/kh3/ingredients/basil.toml b/input/kh3/ingredients/basil.toml index f1a1b0e..edd3cdf 100644 --- a/input/kh3/ingredients/basil.toml +++ b/input/kh3/ingredients/basil.toml @@ -1,2 +1,12 @@ name = "Basil" group = "herb" + +[[locations]] +world = "Kingdom of Corona" +room = "The Forest" +note = "Spawn in Thoroughfare and go back to The Forest around the trees" + +[[locations]] +world = "Toy Box" +room = "Andy's House" +note = "Outside the house in the garden" diff --git a/input/kh3/ingredients/bay_leaf.toml b/input/kh3/ingredients/bay_leaf.toml index 513a63c..4a6ee39 100644 --- a/input/kh3/ingredients/bay_leaf.toml +++ b/input/kh3/ingredients/bay_leaf.toml @@ -1,2 +1,16 @@ name = "Bay Leaf" group = "herb" + +[[locations]] +world = "Any" +room = "Moogle Shop" + +[[locations]] +world = "Kingdom of Corona" +room = "The Forest" +note = "Spawn in Thoroughfare and go back to The Forest around the trees" + +[[locations]] +world = "Toy Box" +room = "Andy's House" +note = "Outside the house in the garden" diff --git a/input/kh3/ingredients/beef.toml b/input/kh3/ingredients/beef.toml index 87834dd..36550ff 100644 --- a/input/kh3/ingredients/beef.toml +++ b/input/kh3/ingredients/beef.toml @@ -1,2 +1,11 @@ name = "Beef" group = "meat" + +[[locations]] +world = "Any" +room = "Moogle Shop" + +[[locations]] +world = "Toy Box" +room = "Galaxy Toys" +notes = "Rest Area" diff --git a/input/kh3/ingredients/black_truffle.toml b/input/kh3/ingredients/black_truffle.toml index da10b59..6a843c6 100644 --- a/input/kh3/ingredients/black_truffle.toml +++ b/input/kh3/ingredients/black_truffle.toml @@ -1,2 +1,6 @@ name = "Black Truffle" group = "mushroom" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/black_trumpet.toml b/input/kh3/ingredients/black_trumpet.toml index d258053..8726282 100644 --- a/input/kh3/ingredients/black_trumpet.toml +++ b/input/kh3/ingredients/black_trumpet.toml @@ -1,2 +1,6 @@ name = "Black Trumpet" group = "mushroom" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/butter.toml b/input/kh3/ingredients/butter.toml index f28a939..31790b1 100644 --- a/input/kh3/ingredients/butter.toml +++ b/input/kh3/ingredients/butter.toml @@ -1,2 +1,6 @@ name = "Butter" group = "other" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/caviar.toml b/input/kh3/ingredients/caviar.toml index 567540a..53a7ff8 100644 --- a/input/kh3/ingredients/caviar.toml +++ b/input/kh3/ingredients/caviar.toml @@ -1,2 +1,6 @@ name = "Caviar" group = "other" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/celery.toml b/input/kh3/ingredients/celery.toml index 98cf249..a676937 100644 --- a/input/kh3/ingredients/celery.toml +++ b/input/kh3/ingredients/celery.toml @@ -1,2 +1,6 @@ name = "Celery" group = "vegetable" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/chanterelle.toml b/input/kh3/ingredients/chanterelle.toml index e410b7d..69f5d46 100644 --- a/input/kh3/ingredients/chanterelle.toml +++ b/input/kh3/ingredients/chanterelle.toml @@ -1,2 +1,11 @@ name = "Chanterelle" group = "mushroom" + +[[locations]] +world = "Any" +room = "Moogle Shop" + +[[locations]] +world = "Kingdom of Corona" +room = "The Forest" +note = "Spawn in Thoroughfare and go back to The Forest around the trees" diff --git a/input/kh3/ingredients/cheese.toml b/input/kh3/ingredients/cheese.toml index c4b7d1f..1ad36d5 100644 --- a/input/kh3/ingredients/cheese.toml +++ b/input/kh3/ingredients/cheese.toml @@ -1,2 +1,11 @@ name = "Cheese" group = "other" + +[[locations]] +world = "Any" +room = "Moogle Shop" + +[[locations]] +world = "Toy Box" +room = "Galaxy Toys" +notes = "1F on the right side stands" diff --git a/input/kh3/ingredients/chocolate.toml b/input/kh3/ingredients/chocolate.toml index 6b14fd4..40b8514 100644 --- a/input/kh3/ingredients/chocolate.toml +++ b/input/kh3/ingredients/chocolate.toml @@ -1,2 +1,11 @@ name = "Chocolate" group = "other" + +[[locations]] +world = "Any" +room = "Moogle Shop" + +[[locations]] +world = "Toy Box" +room = "Galaxy Toys" +notes = "2F on the right side at the very end of the platform" diff --git a/input/kh3/ingredients/cloves.toml b/input/kh3/ingredients/cloves.toml index c4501d5..10332b6 100644 --- a/input/kh3/ingredients/cloves.toml +++ b/input/kh3/ingredients/cloves.toml @@ -1,2 +1,6 @@ name = "Cloves" group = "herb" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/cornichon.toml b/input/kh3/ingredients/cornichon.toml index ff9e047..5c25d9a 100644 --- a/input/kh3/ingredients/cornichon.toml +++ b/input/kh3/ingredients/cornichon.toml @@ -1,2 +1,21 @@ name = "Cornichon" group = "other" + +[[locations]] +world = "Any" +room = "Moogle Shop" + +[[locations]] +world = "Toy Box" +room = "Galaxy Toys" +note = "1F outside the store to the right" + +[[locations]] +world = "Toy Box" +room = "Galaxy Toys" +note = "Rest Area" + +[[locations]] +world = "Toy Box" +room = "Galaxy Toys" +note = "Action Figures, in the very back of the store" diff --git a/input/kh3/ingredients/dill.toml b/input/kh3/ingredients/dill.toml index a9d51db..f780853 100644 --- a/input/kh3/ingredients/dill.toml +++ b/input/kh3/ingredients/dill.toml @@ -1,2 +1,7 @@ name = "Dill" group = "herb" + +[[locations]] +world = "Monstropolis" +room = "Lobby & Offices" +note = "Vending Machine at the Laugh Floor's entrance" diff --git a/input/kh3/ingredients/eel.toml b/input/kh3/ingredients/eel.toml index ed9019e..c705972 100644 --- a/input/kh3/ingredients/eel.toml +++ b/input/kh3/ingredients/eel.toml @@ -1,2 +1,11 @@ name = "Eel" group = "seafood" + +[[locations]] +world = "Any" +room = "Moogle Shop" + +[[locations]] +world = "Kingdom of Corona" +room = "The Forest" +note = "Spawn in Thoroughfare and go back to The Forest near the water" diff --git a/input/kh3/ingredients/filet_mignon.toml b/input/kh3/ingredients/filet_mignon.toml index 520738b..df4867f 100644 --- a/input/kh3/ingredients/filet_mignon.toml +++ b/input/kh3/ingredients/filet_mignon.toml @@ -1,2 +1,12 @@ name = "Filet Mignon" group = "meat" + +[[locations]] +world = "Monstropolis" +room = "Lobby & Offices" +note = "Laugh Floor on the desk in the very back" + +[[locations]] +world = "The Carribean" +room = "Fort" +note = "In a box on the front terrace from the spawn" diff --git a/input/kh3/ingredients/king_oyster_mushroom.toml b/input/kh3/ingredients/king_oyster_mushroom.toml index 182ee24..33655d8 100644 --- a/input/kh3/ingredients/king_oyster_mushroom.toml +++ b/input/kh3/ingredients/king_oyster_mushroom.toml @@ -1,2 +1,6 @@ name = "King Oyster Mushroom" group = "mushroom" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/lemon.toml b/input/kh3/ingredients/lemon.toml index 0767353..8dfc3ac 100644 --- a/input/kh3/ingredients/lemon.toml +++ b/input/kh3/ingredients/lemon.toml @@ -1,2 +1,6 @@ name = "Lemon" group = "fruit" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/lobster.toml b/input/kh3/ingredients/lobster.toml index 4c41960..93662c7 100644 --- a/input/kh3/ingredients/lobster.toml +++ b/input/kh3/ingredients/lobster.toml @@ -1,2 +1,7 @@ name = "Lobster" group = "seafood" + +[[locations]] +world = "Kingdom of Corona" +room = "The Forest" +note = "Spawn in Thoroughfare and go back to The Forest near the water" diff --git a/input/kh3/ingredients/miller_mushroom.toml b/input/kh3/ingredients/miller_mushroom.toml index a77ad15..4f87962 100644 --- a/input/kh3/ingredients/miller_mushroom.toml +++ b/input/kh3/ingredients/miller_mushroom.toml @@ -1,2 +1,6 @@ name = "Miller Mushroom" group = "mushroom" + +[[locations]] +world = "The Carribean" +room = "Hudded Isles" diff --git a/input/kh3/ingredients/morel.toml b/input/kh3/ingredients/morel.toml index f765526..d3b83f6 100644 --- a/input/kh3/ingredients/morel.toml +++ b/input/kh3/ingredients/morel.toml @@ -1,2 +1,6 @@ name = "Morel" group = "mushroom" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/olive_oil.toml b/input/kh3/ingredients/olive_oil.toml index eb4f8a1..05f8e3a 100644 --- a/input/kh3/ingredients/olive_oil.toml +++ b/input/kh3/ingredients/olive_oil.toml @@ -1,2 +1,6 @@ name = "Olive Oil" group = "other" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/onion.toml b/input/kh3/ingredients/onion.toml index 0183beb..22233f7 100644 --- a/input/kh3/ingredients/onion.toml +++ b/input/kh3/ingredients/onion.toml @@ -1,2 +1,6 @@ name = "Onion" group = "vegetable" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/parsley.toml b/input/kh3/ingredients/parsley.toml index f2b9a19..7b868e7 100644 --- a/input/kh3/ingredients/parsley.toml +++ b/input/kh3/ingredients/parsley.toml @@ -1,2 +1,11 @@ name = "Parsley" group = "herb" + +[[locations]] +world = "Any" +room = "Moogle Shop" + +[[locations]] +world = "Toy Box" +room = "Andy's House" +note = "Outside the house in the garden" diff --git a/input/kh3/ingredients/porcini.toml b/input/kh3/ingredients/porcini.toml index 6581dcf..cbe5b11 100644 --- a/input/kh3/ingredients/porcini.toml +++ b/input/kh3/ingredients/porcini.toml @@ -1,2 +1,6 @@ name = "Porcini" group = "mushroom" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/rice.toml b/input/kh3/ingredients/rice.toml index 1448586..34faec7 100644 --- a/input/kh3/ingredients/rice.toml +++ b/input/kh3/ingredients/rice.toml @@ -1,2 +1,6 @@ name = "Rice" group = "other" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/rosemary.toml b/input/kh3/ingredients/rosemary.toml index 58bfb8e..ab99d2f 100644 --- a/input/kh3/ingredients/rosemary.toml +++ b/input/kh3/ingredients/rosemary.toml @@ -1,2 +1,11 @@ name = "Rosemary" group = "herb" + +[[locations]] +world = "Any" +room = "Moogle Shop" + +[[locations]] +world = "Toy Box" +room = "Andy's House" +note = "Outside the house in the garden" diff --git a/input/kh3/ingredients/saffron.toml b/input/kh3/ingredients/saffron.toml index 4b9e44c..fb66f83 100644 --- a/input/kh3/ingredients/saffron.toml +++ b/input/kh3/ingredients/saffron.toml @@ -1,2 +1,6 @@ name = "Saffron" group = "herb" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/input/kh3/ingredients/scallop.toml b/input/kh3/ingredients/scallop.toml index 08195e7..e7c54f8 100644 --- a/input/kh3/ingredients/scallop.toml +++ b/input/kh3/ingredients/scallop.toml @@ -5,3 +5,8 @@ group = "seafood" world = "Kingdom of Corona" room = "Thoroughfare" note = "At the wharf to the left from save point" + +[[locations]] +world = "Kingdom of Corona" +room = "The Forest" +note = "Spawn in Thoroughfare and go back to The Forest near the water" diff --git a/input/kh3/ingredients/sea_bass.toml b/input/kh3/ingredients/sea_bass.toml index 04a502d..996f0c9 100644 --- a/input/kh3/ingredients/sea_bass.toml +++ b/input/kh3/ingredients/sea_bass.toml @@ -5,3 +5,8 @@ group = "seafood" world = "Kingdom of Corona" room = "Thoroughfare" note = "At the wharf to the left from save point" + +[[locations]] +world = "Kingdom of Corona" +room = "The Forest" +note = "Spawn in Thoroughfare and go back to The Forest near the water" diff --git a/input/kh3/ingredients/sole.toml b/input/kh3/ingredients/sole.toml index 13b1d06..1bd08b6 100644 --- a/input/kh3/ingredients/sole.toml +++ b/input/kh3/ingredients/sole.toml @@ -1,6 +1,10 @@ name = "Sole" group = "seafood" +[[locations]] +world = "Any" +room = "Moogle Shop" + [[locations]] world = "Kingdom of Corona" room = "Thoroughfare" diff --git a/input/kh3/ingredients/thyme.toml b/input/kh3/ingredients/thyme.toml index b2b2e75..34216b8 100644 --- a/input/kh3/ingredients/thyme.toml +++ b/input/kh3/ingredients/thyme.toml @@ -1,2 +1,11 @@ name = "Thyme" group = "herb" + +[[locations]] +world = "Any" +room = "Moogle Shop" + +[[locations]] +world = "Toy Box" +room = "Andy's House" +note = "Outside the house in the garden" diff --git a/input/kh3/ingredients/veal.toml b/input/kh3/ingredients/veal.toml index 25bcb83..f861113 100644 --- a/input/kh3/ingredients/veal.toml +++ b/input/kh3/ingredients/veal.toml @@ -1,2 +1,6 @@ name = "Veal" group = "meat" + +[[locations]] +world = "Any" +room = "Moogle Shop" diff --git a/public/scripts/kh1/synth.js b/public/scripts/kh1/synth.js index 696f853..794c836 100644 --- a/public/scripts/kh1/synth.js +++ b/public/scripts/kh1/synth.js @@ -1,5 +1,8 @@ import "../common/prototypes.js"; +const RECIPE_STORAGE_NAME = "kh1/synth/recipe."; +const LIST_STORAGE_NAME = "kh1/synth/needed-maths"; + let markedNeededMaterials = []; document.addEventListener("DOMContentLoaded", (event) => { @@ -7,12 +10,13 @@ document.addEventListener("DOMContentLoaded", (event) => { for (const recipe of recipes) { recipe.checked = - localStorage.getItem("kh1-synth-" + recipe.id) === "true" ?? false; + localStorage.getItem(RECIPE_STORAGE_NAME + recipe.id) === "true" ?? + false; updateSynthRecipeState(recipe); recipe.addEventListener("input", function () { // Change the recipe's state and update and needed materials list based on the remaining recipes - localStorage.setItem("kh1-synth-" + this.id, this.checked); + localStorage.setItem(RECIPE_STORAGE_NAME + this.id, this.checked); updateSynthRecipeState(this); calcNeededMats(); }); @@ -26,8 +30,8 @@ document.addEventListener("DOMContentLoaded", (event) => { } // Turn the single saved string into an array with each material - if (localStorage.getItem("kh1-synth-needed-mats") != null) { - let saved = localStorage.getItem("kh1-synth-needed-mats"); + if (localStorage.getItem(LIST_STORAGE_NAME) != null) { + let saved = localStorage.getItem(LIST_STORAGE_NAME); saved = saved.split(","); markedNeededMaterials = saved; markedNeededMaterials = markedNeededMaterials.filter( @@ -128,7 +132,7 @@ function updateMarkedNeededMats(ingredient) { markedNeededMaterials.push(ingredient); } markedNeededMaterials = markedNeededMaterials.filter((n) => n && n !== ""); - localStorage.setItem("kh1-synth-needed-mats", markedNeededMaterials); + localStorage.setItem(LIST_STORAGE_NAME, markedNeededMaterials); } function markNeededMat(mat) { diff --git a/public/scripts/kh3/food-sim.js b/public/scripts/kh3/food-sim.js index e1f29d8..bec4fab 100644 --- a/public/scripts/kh3/food-sim.js +++ b/public/scripts/kh3/food-sim.js @@ -1,17 +1,27 @@ -let globalStats = { str: 0, mag: 0, def: 0, hp: 0, mp: 0 }; +const STORAGE_NAME = "kh3/food-sim/recipe."; const types = ["starters", "soups", "fish", "meat", "deserts"]; + +let globalStats = { str: 0, mag: 0, def: 0, hp: 0, mp: 0 }; let typeItem = []; let hasSelection = [false, false, false, false, false]; +let ingredientsList = []; document.addEventListener("DOMContentLoaded", (event) => { updateStats(); types.forEach(function (type, typeIdx) { + let savedRecipe = localStorage.getItem(STORAGE_NAME + typeIdx); + const recipes = document.querySelectorAll( "div.recipes." + type + " .recipe", ); recipes.forEach(function (item, index) { + let recipeName = item.querySelector(".title").innerText; + if (savedRecipe != undefined && recipeName == savedRecipe) { + selectRecipe(item, typeIdx); + } + item.addEventListener("click", function () { if (!hasSelection[typeIdx]) { hasSelection[typeIdx] = true; @@ -71,6 +81,16 @@ document.addEventListener("DOMContentLoaded", (event) => { }); function unselectRecipe(index) { + // Remove all ingredients of this recipe + let ingredients = typeItem[index].querySelectorAll(".ingredients ul li"); + for (let ingredient of ingredients) { + ingredientsList = ingredientsList.filter( + (ing) => ing != ingredient["innerText"], + ); + } + + localStorage.removeItem(STORAGE_NAME + index); + typeItem[index].style["box-shadow"] = "0px 0px 10px rgba(0, 0, 0, 0.4)"; let stats = JSON.parse(typeItem[index].dataset["stats"]); removeStats(stats); @@ -80,6 +100,17 @@ function selectRecipe(item, index) { typeItem[index] = item; item.style["box-shadow"] = "0px 0px 10px rgba(0, 255, 0, 0.8)"; + // Add all ingredients of this recipe to a global list + let ingredients = item.querySelectorAll(".ingredients ul li"); + for (let ingredient of ingredients) { + ingredientsList.push(ingredient["innerText"]); + } + + let recipeName = item.querySelector(".title").innerText; + console.log(item); + console.log(item.querySelectorAll(".title")); + localStorage.setItem(STORAGE_NAME + index, recipeName); + let stats = JSON.parse(item.dataset["stats"]); addStats(stats); } @@ -149,6 +180,14 @@ function updateStats() { ); updatePoint(poly, 2, HP_MAX_POINT, hpProgress, globalStats.hp, "stat-hp"); updatePoint(poly, 3, MP_MAX_POINT, mpProgress, globalStats.mp, "stat-mp"); + + // let list = document.getElementById("ingredients-list"); + // list.innerHTML = ""; + // for (let ingredient of ingredientsList) { + // let ingredientElem = document.createElement("li"); + // ingredientElem.innerText = ingredient; + // list.appendChild(ingredientElem); + // } } function updatePoint(poly, statId, max, progress, value, statElem) { diff --git a/templates/pages/kh3/food-sim.html b/templates/pages/kh3/food-sim.html index 407a9b6..b174830 100644 --- a/templates/pages/kh3/food-sim.html +++ b/templates/pages/kh3/food-sim.html @@ -57,6 +57,8 @@ + +