Compare commits

..

No commits in common. "7e7653ec83001429b0948b99123d9552da55a481" and "66e76351198fdc0ed65f0f8317fc0101675ff0bd" have entirely different histories.

13 changed files with 69 additions and 77 deletions

View File

@ -1,4 +1,4 @@
export function getGame(url = window.location.href) { export function getGame(url) {
let last = url.lastIndexOf("/", url.length); let last = url.lastIndexOf("/", url.length);
let first = url.lastIndexOf("/", last - 1) + 1; let first = url.lastIndexOf("/", last - 1) + 1;
return url.substring(first, last); return url.substring(first, last);

View File

@ -1,11 +1,15 @@
import * as storage from "./storage.js"; import { getGame } from "./helper.js";
const TRACKED_STORAGE_NAME = "/drops/tracked/"; const TRACKED_STORAGE_NAME = "/drops/tracked/";
let gameName;
export let showOnlyTracked = false; export let showOnlyTracked = false;
export let kindFilter = new Set(); export let kindFilter = new Set();
export function init() { export function init() {
gameName = getGame(window.location.href);
loadTracked(); loadTracked();
const onlyTrackedFilter = document.querySelector( const onlyTrackedFilter = document.querySelector(
@ -61,12 +65,10 @@ function loadTracked() {
for (const category of categories) { for (const category of categories) {
let id = let id =
TRACKED_STORAGE_NAME + category.dataset["matKind"] + "-" + category.dataset["matType"];
category.dataset["matKind"] + id = gameName + TRACKED_STORAGE_NAME + id;
"-" +
category.dataset["matType"];
let isTracked = storage.get(id) === "true"; let isTracked = localStorage.getItem(id) === "true";
if (isTracked) { if (isTracked) {
category.dataset["isTracked"] = true; category.dataset["isTracked"] = true;
let trackButton = category.querySelector(".category button"); let trackButton = category.querySelector(".category button");
@ -82,19 +84,16 @@ function loadTracked() {
export function track(element) { export function track(element) {
let parent = element.parentElement.parentElement; let parent = element.parentElement.parentElement;
let id = let id = parent.dataset["matKind"] + "-" + parent.dataset["matType"];
TRACKED_STORAGE_NAME + id = gameName + TRACKED_STORAGE_NAME + id;
parent.dataset["matKind"] +
"-" +
parent.dataset["matType"];
let isTracked = parent.dataset["isTracked"] ?? false; let isTracked = parent.dataset["isTracked"] ?? false;
isTracked = isTracked === "true" ? false : true; isTracked = isTracked === "true" ? false : true;
if (isTracked) { if (isTracked) {
storage.set(id, true); localStorage.setItem(id, true);
} else { } else {
storage.remove(id); localStorage.removeItem(id);
} }
parent.dataset["isTracked"] = isTracked; parent.dataset["isTracked"] = isTracked;

View File

@ -1,13 +0,0 @@
import { getGame } from "./helper.js";
export function remove(key) {
localStorage.removeItem(getGame() + key);
}
export function get(key) {
return localStorage.getItem(getGame() + key);
}
export function set(key, value) {
localStorage.setItem(getGame() + key, value);
}

View File

@ -1,22 +1,29 @@
import "../common/prototypes.js"; import "../common/prototypes.js";
import * as storage from "../common/storage.js"; import { getGame } from "../common/helper.js";
const RECIPE_STORAGE_NAME = "/synth/"; const RECIPE_STORAGE_NAME = "/synth/";
const LIST_STORAGE_NAME = "/synth/finished-mats"; const LIST_STORAGE_NAME = "/synth/needed-mats";
let markedNeededMaterials = []; let markedNeededMaterials = [];
let gameName;
document.addEventListener("DOMContentLoaded", (event) => { document.addEventListener("DOMContentLoaded", (event) => {
gameName = getGame(window.location.href);
const recipes = document.querySelectorAll(".recipe"); const recipes = document.querySelectorAll(".recipe");
for (const recipe of recipes) { for (const recipe of recipes) {
recipe.checked = recipe.checked =
storage.get(RECIPE_STORAGE_NAME + recipe.id) === "true" ?? false; localStorage.getItem(gameName + RECIPE_STORAGE_NAME + recipe.id) ===
"true" ?? false;
updateSynthRecipeState(recipe); updateSynthRecipeState(recipe);
recipe.addEventListener("input", function () { recipe.addEventListener("input", function () {
// Change the recipe's state and update and needed materials list based on the remaining recipes // Change the recipe's state and update and needed materials list based on the remaining recipes
storage.set(RECIPE_STORAGE_NAME + this.id, this.checked); localStorage.setItem(
gameName + RECIPE_STORAGE_NAME + this.id,
this.checked,
);
updateSynthRecipeState(this); updateSynthRecipeState(this);
calcNeededMats(); calcNeededMats();
}); });
@ -30,8 +37,8 @@ document.addEventListener("DOMContentLoaded", (event) => {
} }
// Turn the single saved string into an array with each material // Turn the single saved string into an array with each material
if (storage.get(LIST_STORAGE_NAME) != null) { if (localStorage.getItem(gameName + LIST_STORAGE_NAME) != null) {
let saved = storage.get(LIST_STORAGE_NAME); let saved = localStorage.getItem(gameName + LIST_STORAGE_NAME);
saved = saved.split(","); saved = saved.split(",");
markedNeededMaterials = saved; markedNeededMaterials = saved;
markedNeededMaterials = markedNeededMaterials.filter( markedNeededMaterials = markedNeededMaterials.filter(
@ -132,7 +139,7 @@ function updateMarkedNeededMats(ingredient) {
markedNeededMaterials.push(ingredient); markedNeededMaterials.push(ingredient);
} }
markedNeededMaterials = markedNeededMaterials.filter((n) => n && n !== ""); markedNeededMaterials = markedNeededMaterials.filter((n) => n && n !== "");
storage.set(LIST_STORAGE_NAME, markedNeededMaterials); localStorage.setItem(gameName + LIST_STORAGE_NAME, markedNeededMaterials);
} }
function markNeededMat(mat) { function markNeededMat(mat) {

View File

@ -1,6 +1,4 @@
import * as storage from "../common/storage.js"; const STORAGE_NAME = "kh3/food-sim/recipe.";
const STORAGE_NAME = "/food-sim/recipe-";
const types = ["starters", "soups", "fish", "meat", "deserts"]; const types = ["starters", "soups", "fish", "meat", "deserts"];
let globalStats = { str: 0, mag: 0, def: 0, hp: 0, mp: 0 }; let globalStats = { str: 0, mag: 0, def: 0, hp: 0, mp: 0 };
@ -12,7 +10,7 @@ document.addEventListener("DOMContentLoaded", (event) => {
updateStats(); updateStats();
types.forEach(function (type, typeIdx) { types.forEach(function (type, typeIdx) {
let savedRecipe = storage.get(STORAGE_NAME + typeIdx); let savedRecipe = localStorage.getItem(STORAGE_NAME + typeIdx);
const recipes = document.querySelectorAll( const recipes = document.querySelectorAll(
"div.recipes." + type + " .recipe", "div.recipes." + type + " .recipe",
@ -21,7 +19,6 @@ document.addEventListener("DOMContentLoaded", (event) => {
recipes.forEach(function (item, index) { recipes.forEach(function (item, index) {
let recipeName = item.querySelector(".title").innerText; let recipeName = item.querySelector(".title").innerText;
if (savedRecipe != undefined && recipeName == savedRecipe) { if (savedRecipe != undefined && recipeName == savedRecipe) {
hasSelection[typeIdx] = true;
selectRecipe(item, typeIdx); selectRecipe(item, typeIdx);
} }
@ -92,7 +89,7 @@ function unselectRecipe(index) {
); );
} }
storage.remove(STORAGE_NAME + index); localStorage.removeItem(STORAGE_NAME + index);
typeItem[index].style["box-shadow"] = "0px 0px 10px rgba(0, 0, 0, 0.4)"; typeItem[index].style["box-shadow"] = "0px 0px 10px rgba(0, 0, 0, 0.4)";
let stats = JSON.parse(typeItem[index].dataset["stats"]); let stats = JSON.parse(typeItem[index].dataset["stats"]);
@ -110,7 +107,7 @@ function selectRecipe(item, index) {
} }
let recipeName = item.querySelector(".title").innerText; let recipeName = item.querySelector(".title").innerText;
storage.set(STORAGE_NAME + index, recipeName); localStorage.setItem(STORAGE_NAME + index, recipeName);
let stats = JSON.parse(item.dataset["stats"]); let stats = JSON.parse(item.dataset["stats"]);
addStats(stats); addStats(stats);

View File

@ -1,7 +1,5 @@
import * as storage from "../common/storage.js"; const CODES_STORAGE_NAME = "kh3/pro-codes-sim/codes/";
const MERIT_STORAGE_NAME = "kh3/pro-codes-sim/merit/";
const CODES_STORAGE_NAME = "/pro-codes-sim/codes/";
const MERIT_STORAGE_NAME = "/pro-codes-sim/merit/";
const STAR_MULTIPLIER = 1.25; const STAR_MULTIPLIER = 1.25;
let selectionAllState = false; let selectionAllState = false;
@ -16,7 +14,9 @@ document.addEventListener("DOMContentLoaded", (event) => {
// Loading enabled codes // Loading enabled codes
for (let code of codes) { for (let code of codes) {
const hasCodeToggled = const hasCodeToggled =
storage.get(CODES_STORAGE_NAME + code.id) === "true" ? true : false; localStorage.getItem(CODES_STORAGE_NAME + code.id) === "true"
? true
: false;
if (hasCodeToggled) { if (hasCodeToggled) {
// Normally the toggleCode gets called after the checkbox is checked, // Normally the toggleCode gets called after the checkbox is checked,
// since we don't interact with it at this point we mark it as checked manually here // since we don't interact with it at this point we mark it as checked manually here
@ -28,7 +28,8 @@ document.addEventListener("DOMContentLoaded", (event) => {
// Loading marked fights and their merit // Loading marked fights and their merit
for (let fight of fights) { for (let fight of fights) {
const source = fight.dataset["meritSource"]; const source = fight.dataset["meritSource"];
const merit = Number(storage.get(MERIT_STORAGE_NAME + source)) ?? 0; const merit =
Number(localStorage.getItem(MERIT_STORAGE_NAME + source)) ?? 0;
if (merit > 0) { if (merit > 0) {
markFight(fight, merit); markFight(fight, merit);
} }
@ -49,7 +50,7 @@ function markFight(data, loadedMerit = 0) {
updateMeritCounter(); updateMeritCounter();
fightMerit[source] = 0; fightMerit[source] = 0;
storage.remove(MERIT_STORAGE_NAME + source); localStorage.removeItem(MERIT_STORAGE_NAME + source);
data.innerText = "Mark"; data.innerText = "Mark";
data.classList.remove("danger"); data.classList.remove("danger");
@ -63,7 +64,7 @@ function markFight(data, loadedMerit = 0) {
updateMeritCounter(); updateMeritCounter();
fightMerit[source] = merit; fightMerit[source] = merit;
storage.set(MERIT_STORAGE_NAME + source, merit); localStorage.setItem(MERIT_STORAGE_NAME + source, merit);
data.innerText = "Unmark"; data.innerText = "Unmark";
data.classList.add("danger"); data.classList.add("danger");
@ -76,12 +77,12 @@ function toggleCode(code) {
if (code.checked) { if (code.checked) {
stars += codeStars; stars += codeStars;
storage.set(CODES_STORAGE_NAME + code.id, true); localStorage.setItem(CODES_STORAGE_NAME + code.id, true);
} else { } else {
stars -= codeStars; stars -= codeStars;
selectionAllState = false; selectionAllState = false;
updateAllButton(); updateAllButton();
storage.remove(CODES_STORAGE_NAME + code.id); localStorage.removeItem(CODES_STORAGE_NAME + code.id);
} }
updateStarsCounter(); updateStarsCounter();
} }
@ -98,7 +99,7 @@ function toggleAllCodes() {
} }
code.checked = true; code.checked = true;
stars += Number(code.dataset["stars"]); stars += Number(code.dataset["stars"]);
storage.set(CODES_STORAGE_NAME + code.id, true); localStorage.setItem(CODES_STORAGE_NAME + code.id, true);
} }
} else { } else {
selectionAllState = false; selectionAllState = false;
@ -109,7 +110,7 @@ function toggleAllCodes() {
} }
code.checked = false; code.checked = false;
stars -= Number(code.dataset["stars"]); stars -= Number(code.dataset["stars"]);
storage.remove(CODES_STORAGE_NAME + code.id); localStorage.removeItem(CODES_STORAGE_NAME + code.id);
} }
} }

View File

@ -97,7 +97,7 @@ table.board {
height: 70%; height: 70%;
position: relative; position: relative;
left: 15px; left: 15px;
background-color: #eee; background-color: #cbf;
z-index: 10; z-index: 10;
align-content: center; align-content: center;
font-size: 14px; font-size: 14px;
@ -222,5 +222,6 @@ table.board {
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 0; z-index: 0;
color: #eee; /*color: #3c3c3c;*/
color: #ccbbff;
} }

View File

@ -39,15 +39,15 @@ pub struct Module;
impl RuntimeModule for Module { impl RuntimeModule for Module {
fn start_module() { fn start_module() {
tracing::info!("Loading BBS abilities data from {}", ABILITIES_PATH); tracing::info!("Loading abilities data from {}", ABILITIES_PATH);
let abilities_str = std::fs::read_to_string(ABILITIES_PATH).unwrap(); let abilities_str = std::fs::read_to_string(ABILITIES_PATH).unwrap();
let abilities = serde_json::from_str::<Vec<Ability>>(&abilities_str).unwrap(); let abilities = serde_json::from_str::<Vec<Ability>>(&abilities_str).unwrap();
tracing::info!("Loading BBS finishers data from {}", ABILITIES_PATH); tracing::info!("Loading finishers data from {}", ABILITIES_PATH);
let finishers_str = std::fs::read_to_string(FINISHERS_PATH).unwrap(); let finishers_str = std::fs::read_to_string(FINISHERS_PATH).unwrap();
let finishers = serde_json::from_str::<HashMap<String, Finisher>>(&finishers_str).unwrap(); let finishers = serde_json::from_str::<HashMap<String, Finisher>>(&finishers_str).unwrap();
tracing::info!("Loading BBS commands data from {}", ABILITIES_PATH); tracing::info!("Loading commands data from {}", ABILITIES_PATH);
let commands_str = std::fs::read_to_string(COMMANDS_PATH).unwrap(); let commands_str = std::fs::read_to_string(COMMANDS_PATH).unwrap();
let mut commands = serde_json::from_str::<Vec<Command>>(&commands_str).unwrap(); let mut commands = serde_json::from_str::<Vec<Command>>(&commands_str).unwrap();
@ -66,7 +66,7 @@ impl RuntimeModule for Module {
} }
} }
tracing::info!("Generating BBS melding table template"); tracing::info!("Generating the BBS melding table template");
let melding_template = CommandsTemplate { commands, crystals }; let melding_template = CommandsTemplate { commands, crystals };
create_file("./out/bbs", "melding", melding_template).unwrap(); create_file("./out/bbs", "melding", melding_template).unwrap();

View File

@ -22,7 +22,7 @@ pub struct Module;
impl RuntimeModule for Module { impl RuntimeModule for Module {
fn start_module() { fn start_module() {
tracing::info!("Loading DDD ability boards data from {}", ABILITIES_PATH); tracing::info!("Loading ability boards data from {}", ABILITIES_PATH);
let mut boards: Vec<Board> = vec![]; let mut boards: Vec<Board> = vec![];
// Loading multiple files into one vector due to the size of each board // Loading multiple files into one vector due to the size of each board
let paths = std::fs::read_dir(ABILITIES_PATH) let paths = std::fs::read_dir(ABILITIES_PATH)
@ -49,7 +49,7 @@ impl RuntimeModule for Module {
} }
boards.sort_by(|a, b| a.order.cmp(&b.order)); boards.sort_by(|a, b| a.order.cmp(&b.order));
tracing::info!("Generating DDD ability boards template"); tracing::info!("Generating the DDD ability boards template");
let boards_template = AbilitiesTemplate { boards }; let boards_template = AbilitiesTemplate { boards };
create_file("./out/ddd", "boards", boards_template).unwrap(); create_file("./out/ddd", "boards", boards_template).unwrap();

View File

@ -25,10 +25,10 @@ pub struct Module;
impl RuntimeModule for Module { impl RuntimeModule for Module {
fn start_module() { fn start_module() {
tracing::info!("Loading KH1 synthesis data from {}", SYNTHESIS_PATH); tracing::info!("Loading synthesis data from {}", SYNTHESIS_PATH);
let synth = Synthesis::new(SYNTHESIS_PATH); let synth = Synthesis::new(SYNTHESIS_PATH);
tracing::info!("Generating KH1 synth template"); tracing::info!("Generating the KH1 synth template");
let synth_template = SynthTemplate { data: synth }; let synth_template = SynthTemplate { data: synth };
create_file("./out/kh1", "synth", synth_template).unwrap(); create_file("./out/kh1", "synth", synth_template).unwrap();

View File

@ -25,20 +25,20 @@ pub struct Module;
impl RuntimeModule for Module { impl RuntimeModule for Module {
fn start_module() { fn start_module() {
tracing::info!("Loading KH1FM enemy data from {}", ENEMIES_PATH); tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
let enemies = Enemy::import(ENEMIES_PATH); let enemies = Enemy::import(ENEMIES_PATH);
let drops = Drops::new(Game::Kh1(GameProps::final_mix()), enemies); let drops = Drops::new(Game::Kh1(GameProps::final_mix()), enemies);
tracing::info!("Loading KH1FM synthesis data from {}", SYNTHESIS_PATH); tracing::info!("Loading synthesis data from {}", SYNTHESIS_PATH);
let synth = Synthesis::new(SYNTHESIS_PATH); let synth = Synthesis::new(SYNTHESIS_PATH);
tracing::info!("Generating KH1FM drops template"); tracing::info!("Generating the KH1FM, drops template");
let drops_template = DropsTemplate { data: drops }; let drops_template = DropsTemplate { data: drops };
create_file("./out/kh1fm", "drops", drops_template).unwrap(); create_file("./out/kh1fm", "drops", drops_template).unwrap();
tracing::info!("Generating KH1FM synth template"); tracing::info!("Generating the KH1FM synth template");
let synth_template = SynthTemplate { data: synth }; let synth_template = SynthTemplate { data: synth };
create_file("./out/kh1fm", "synth", synth_template).unwrap(); create_file("./out/kh1fm", "synth", synth_template).unwrap();

View File

@ -18,12 +18,12 @@ pub struct Module;
impl RuntimeModule for Module { impl RuntimeModule for Module {
fn start_module() { fn start_module() {
tracing::info!("Loading KH2FM enemy data from {}", ENEMIES_PATH); tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
let enemies = Enemy::import(ENEMIES_PATH); let enemies = Enemy::import(ENEMIES_PATH);
let drops = Drops::new(Game::Kh2(GameProps::final_mix()), enemies); let drops = Drops::new(Game::Kh2(GameProps::final_mix()), enemies);
tracing::info!("Generating KH2FM drops template"); tracing::info!("Generating the KH2FM drops template");
let drops_template = DropsTemplate { data: drops }; let drops_template = DropsTemplate { data: drops };
create_file("./out/kh2fm", "drops", drops_template).unwrap(); create_file("./out/kh2fm", "drops", drops_template).unwrap();

View File

@ -48,36 +48,36 @@ pub struct Module;
impl RuntimeModule for Module { impl RuntimeModule for Module {
fn start_module() { fn start_module() {
tracing::info!("Loading KH3 enemy data from {}", ENEMIES_PATH); tracing::info!("Loading enemy data from {}", ENEMIES_PATH);
let enemies = Enemy::import(ENEMIES_PATH); let enemies = Enemy::import(ENEMIES_PATH);
let drops = Drops::new(Game::Kh3, enemies); let drops = Drops::new(Game::Kh3, enemies);
tracing::info!("Loading KH3 ingredients data from {}", ENEMIES_PATH); tracing::info!("Loading ingredients data from {}", ENEMIES_PATH);
let ingredients = Ingredient::import(INGREDIENTS_PATH); let ingredients = Ingredient::import(INGREDIENTS_PATH);
tracing::info!("Loading KH3 recipes data from {}", RECIPES_PATH); tracing::info!("Loading recipes data from {}", RECIPES_PATH);
let recipes_str = std::fs::read_to_string(RECIPES_PATH).unwrap(); let recipes_str = std::fs::read_to_string(RECIPES_PATH).unwrap();
let recipes = toml::from_str::<Recipes>(&recipes_str).unwrap(); let recipes = toml::from_str::<Recipes>(&recipes_str).unwrap();
tracing::info!("Loading KH3 pro codes data from {}", PRO_CODES_PATH); tracing::info!("Loading pro codes data from {}", PRO_CODES_PATH);
let pro_codes_str = std::fs::read_to_string(PRO_CODES_PATH).unwrap(); let pro_codes_str = std::fs::read_to_string(PRO_CODES_PATH).unwrap();
let pro_codes = toml::from_str::<ProCodes>(&pro_codes_str).unwrap(); let pro_codes = toml::from_str::<ProCodes>(&pro_codes_str).unwrap();
let pro_code_fights_str = std::fs::read_to_string(PRO_CODE_FIGHTS_PATH).unwrap(); let pro_code_fights_str = std::fs::read_to_string(PRO_CODE_FIGHTS_PATH).unwrap();
let pro_code_fights = toml::from_str::<ProCodeFights>(&pro_code_fights_str).unwrap(); let pro_code_fights = toml::from_str::<ProCodeFights>(&pro_code_fights_str).unwrap();
tracing::info!("Generating KH3 drops template"); tracing::info!("Generating the KH3 drops template");
let drops_template = DropsTemplate { data: drops }; let drops_template = DropsTemplate { data: drops };
create_file("./out/kh3", "drops", drops_template).unwrap(); create_file("./out/kh3", "drops", drops_template).unwrap();
tracing::info!("Generating KH3 ingredients template"); tracing::info!("Generating the KH3 ingredients template");
let ingredients_template = IngredientsTemplate { ingredients }; let ingredients_template = IngredientsTemplate { ingredients };
create_file("./out/kh3", "ingredients", ingredients_template).unwrap(); create_file("./out/kh3", "ingredients", ingredients_template).unwrap();
tracing::info!("Generating KH3 recipes template"); tracing::info!("Generating the KH3 recipes template");
let food_template = RecipesTemplate { recipes }; let food_template = RecipesTemplate { recipes };
create_file("./out/kh3", "food-sim", food_template).unwrap(); create_file("./out/kh3", "food-sim", food_template).unwrap();
tracing::info!("Generating KH3 pro codes template"); tracing::info!("Generating the KH3 pro codes template");
let pro_codes_template = ProCodesTemplate { let pro_codes_template = ProCodesTemplate {
pro_codes: pro_codes.codes, pro_codes: pro_codes.codes,
fights: pro_code_fights.fights, fights: pro_code_fights.fights,