Compare commits

...

2 Commits

15 changed files with 79 additions and 44 deletions

View File

@ -2,7 +2,6 @@ name = "Air Pirate"
[[world]]
name = "Neverland"
room = ""
[[drops]]
name = "Hi-Potion"

View File

@ -1,8 +1,7 @@
name = "Air Soldier"
[[world]]
name = ""
room = ""
name = "Wonderland"
[[drops]]
name = "Potion"

View File

@ -2,6 +2,7 @@ name = "Bandit"
[[world]]
name = "Agrabah"
room = ["Desert: Cave", "Treasure Room", "Lamp Chamber"]
[[world]]
name = "Monstro"

View File

@ -3,6 +3,10 @@ name = "Bouncywild"
[[world]]
name = "Deep Jungle"
[[world]]
name = "Monstro"
room = ["Bowels", "Stomach"]
[[world]]
name = "End of the World"

View File

@ -2,6 +2,11 @@ name = "Darkball"
[[world]]
name = "Traverse Town"
room = ["3rd District", "Gizmo Shop"]
[[world]]
name = "Agrabah"
room = ["Bazaar", "Palace Gates"]
[[world]]
name = "Hollow Bastion"
@ -9,6 +14,10 @@ name = "Hollow Bastion"
[[world]]
name = "End of the World"
[[world]]
name = "Neverland"
room = ["Ship: Freezer", "Captain's Cabin"]
[[drops]]
name = "Hi-Potion"
kind = "item"

View File

@ -2,6 +2,7 @@ name = "Defender"
[[world]]
name = "Traverse Town"
room = ["3rd District", "Hotel Hallway", "Gizmo Shop"]
[[world]]
name = "Hollow Bastion"

View File

@ -11,6 +11,7 @@ name = "Monstro"
[[world]]
name = "Deep Jungle"
room = ["Jungle: Cliff"]
[[world]]
name = "Hollow Bastion"

View File

@ -2,6 +2,7 @@ name = "Pirate"
[[world]]
name = "Neverland"
room = ["Captain's Cabin"]
[[world]]
name = "Monstro"

View File

@ -5,6 +5,7 @@ name = "Deep Jungle"
[[world]]
name = "Monstro"
room = ["Chamber 5", "Chamber 6"]
[[world]]
name = "End of the World"

View File

@ -1,19 +1,8 @@
name = "Red Nocturne"
[[world]]
name = "Traverse Town"
[[world]]
name = "Wonderland"
[[world]]
name = "Agrabah"
[[world]]
name = "Hollow Bastion"
[[world]]
name = "Monstro"
room = ["Chamber 6"]
[[world]]
name = "End of the World"

View File

@ -1,8 +1,11 @@
name = "Shadow"
[[world]]
name = "Traverse Town"
room = ""
name = "Wonderland"
[[world]]
name = "Neverland"
room = ["Ship: Freezer"]
[[drops]]
name = "Potion"

View File

@ -1,8 +1,8 @@
name = "Soldier"
[[world]]
name = "Traverse Town"
room = ""
name = "Agrabah"
room = ["Main Street"]
[[drops]]
name = "Spirit Shard"

View File

@ -0,0 +1,8 @@
Array.prototype.remove = function (element) {
this.forEach((item, index) => {
if (item === element) {
this.splice(index, 1);
}
});
return this;
};

View File

@ -1,29 +1,37 @@
import "../common/prototypes.js";
let markedNeededMaterials = [];
document.addEventListener("DOMContentLoaded", (event) => {
const recipes = document.querySelectorAll(".recipe");
for (const recipe of recipes) {
recipe.checked =
localStorage.getItem("kh1-synth-" + recipe.id) === "true" ?? false;
update_synth_completions(recipe);
updateSynthRecipeState(recipe);
recipe.addEventListener("input", function () {
localStorage.setItem("kh1-synth-" + this.id, this.checked);
update_synth_completions(this);
calc_total_ingredients();
updateSynthRecipeState(this);
calcNeededMats();
});
}
const recipes_labels = document.querySelectorAll(".recipe-wrapper > label");
for (const label of recipes_labels) {
const recipesLabels = document.querySelectorAll(".recipe-wrapper > label");
for (const label of recipesLabels) {
label.addEventListener("mouseenter", function () {
highlight_ingredients(this);
highlightNeededMats(this);
});
}
calc_total_ingredients();
markedNeededMaterials = Array(
localStorage.getItem("kh1-synth-needed-mats") ?? [],
);
calcNeededMats();
});
function update_synth_completions(recipe) {
function updateSynthRecipeState(recipe) {
if (recipe.checked) {
recipe.parentElement.classList.add("complete");
} else {
@ -31,25 +39,17 @@ function update_synth_completions(recipe) {
}
}
function highlight_ingredients(label) {
function highlightNeededMats(label) {
let mats = [];
const ingredients = label.querySelectorAll("ul li");
const checkbox = label.parentElement.querySelectorAll(".recipe")[0];
const elems = document.querySelectorAll("#mats ul li");
if (checkbox.checked) {
for (const elem of elems) {
elem.style.color = "#fff";
}
return;
}
for (const ingredient of ingredients) {
const name = ingredient.dataset["synthItemName"];
mats.push(name);
}
const elems = document.querySelectorAll("#mats ul li");
for (const elem of elems) {
const isCrossed = elem.style.textDecoration === "line-through";
if (isCrossed) {
@ -64,7 +64,7 @@ function highlight_ingredients(label) {
}
}
function calc_total_ingredients() {
function calcNeededMats() {
const needed = new Map();
const recipes = document.querySelectorAll(".recipe");
@ -81,8 +81,8 @@ function calc_total_ingredients() {
let amount = Number(ingredient.dataset["synthItemAmount"]);
if (needed.has(name)) {
let new_amount = Number(needed.get(name)) + amount;
needed.set(name, new_amount);
let newAmount = Number(needed.get(name)) + amount;
needed.set(name, newAmount);
} else {
needed.set(name, amount);
}
@ -99,12 +99,30 @@ function calc_total_ingredients() {
const liElem = document.createElement("li");
liElem.innerHTML = entry[0] + " x" + entry[1];
liElem.addEventListener("click", function () {
const isCrossed = this.style.textDecoration === "line-through";
this.style.textDecoration = isCrossed ? "none" : "line-through";
this.style.color = isCrossed ? "#fff" : "#f00";
updateMarkedNeededMats(entry[0]);
markNeededMat(this);
});
if (markedNeededMaterials.includes(entry[0])) {
markNeededMat(liElem);
}
uiList.appendChild(liElem);
}
matsList.appendChild(uiList);
}
function updateMarkedNeededMats(ingredient) {
if (markedNeededMaterials.includes(ingredient)) {
markedNeededMaterials.remove(ingredient);
} else {
markedNeededMaterials.push(ingredient);
}
localStorage.setItem("kh1-synth-needed-mats", markedNeededMaterials);
}
function markNeededMat(mat) {
const isCrossed = mat.style.textDecoration === "line-through";
mat.style.textDecoration = isCrossed ? "none" : "line-through";
mat.style.color = isCrossed ? "#fff" : "#f00";
}

View File

@ -87,5 +87,6 @@ impl Display for EnemyDropChance {
#[derive(Debug, Deserialize, PartialEq, Eq)]
pub struct SpawnLocation {
pub name: String,
pub room: Option<String>,
#[serde(default)]
pub rooms: Vec<String>,
}