Last active
May 26, 2022 23:21
-
-
Save mataha/a876d31a281bafc69a97d938c3f21f46 to your computer and use it in GitHub Desktop.
This file contains 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
;(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