Skip to content

Instantly share code, notes, and snippets.

@mataha
Last active May 26, 2022 23:21
Show Gist options
  • Save mataha/a876d31a281bafc69a97d938c3f21f46 to your computer and use it in GitHub Desktop.
Save mataha/a876d31a281bafc69a97d938c3f21f46 to your computer and use it in GitHub Desktop.
;(function () {
function getRandomWaifu() {
return "Ai Hayasaka";
}
const name = window.prompt("Type your character's name:", getRandomWaifu());
if (!name) {
alert("Invalid character name.");
return false;
}
const definitions = window.cfg?.item_definition;
const character = definitions?.character?.rows_?.find(
character => character?.name_en === name
);
if (!character) {
alert("A character with the specified name does not exist.");
return false;
}
const requirements =
character?.star_5_material
.split(",")
.map(requirement => {
const [id, quantity] = requirement
.split("-")
.map(property => {
if (property.includes("|")) {
return Math.min.apply(null, property.split("|"));
} else {
return property;
}
});
const item = definitions?.item?.map_?.[id]?.name_en ?? "Item";
return { item, quantity };
})
.reduce(
(previous, current) =>
`${previous}\n${current.item} - ${current.quantity}`,
"",
) ?? "\nWho knows?";
alert(`You need to have the following materials to bond ${name}:
${requirements}`);
return true;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment