Last active
January 30, 2023 14:04
-
-
Save inaniwaudon/aa0fcc0aa7cd3bb19e3afd841b32c8ff 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
const characters = [ | |
"ふたり", | |
"廣", | |
"PA", | |
"星", | |
"ぼ", | |
"リョウ", | |
"虹", | |
"喜多", | |
"ヨヨ", | |
] as const; | |
type character = typeof characters[number]; | |
const shuffle = () => { | |
while (true) { | |
const randomSelect = (array: character[]) => | |
array[Math.floor(Math.random() * array.length)]; | |
const firstPerson = randomSelect([...characters]); | |
const secondPerson = randomSelect( | |
characters.filter((c) => c != firstPerson) | |
); | |
const isInOrder = | |
characters.indexOf(firstPerson) < characters.indexOf(secondPerson); | |
const sortedFirstPerson = isInOrder ? firstPerson : secondPerson; | |
const sortedSecondPerson = isInOrder ? secondPerson : firstPerson; | |
if (sortedFirstPerson === "ふたり") { | |
if (sortedSecondPerson === "ぼ") { | |
return "後藤姉妹"; | |
} | |
continue; | |
} | |
if (sortedFirstPerson !== "ぼ" && sortedSecondPerson === "ヨヨ") { | |
continue; | |
} | |
if (sortedFirstPerson === "廣") { | |
if (!["ぼ", "星"].includes(sortedSecondPerson)) { | |
continue; | |
} | |
if (sortedSecondPerson === "星") { | |
return "きく星"; | |
} | |
} | |
if (sortedFirstPerson === "PA") { | |
if (!["星", "ぼ"].includes(sortedSecondPerson)) { | |
continue; | |
} | |
if (sortedSecondPerson === "ぼ") { | |
return "ひとPA"; | |
} | |
} | |
if (sortedFirstPerson === "星") { | |
if (!["ぼ", "虹"].includes(sortedSecondPerson)) { | |
continue; | |
} | |
if (sortedSecondPerson === "虹") { | |
return "伊地知姉妹"; | |
} | |
} | |
return sortedFirstPerson + sortedSecondPerson; | |
} | |
}; | |
for (let i = 0; i < 10; i++) { | |
console.log(shuffle()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment