two sentence horror now doesn't discard any sentence

This commit is contained in:
Jill 2023-10-29 14:10:13 +03:00
parent 25e4cbd60e
commit f4e2b0e77f
Signed by: oat
GPG Key ID: 33489AA58A955108
1 changed files with 82 additions and 28 deletions

View File

@ -1,8 +1,65 @@
import { GuildMember, SlashCommandBuilder, Interaction, messageLink } from 'discord.js';
import { getTextResponsePrettyPlease, randomWord, sendSegments, startGame } from '../lib/game';
import { GuildMember, SlashCommandBuilder, Interaction, messageLink, User } from 'discord.js';
import { getTextResponsePrettyPlease, sendSegments, startGame } from '../lib/game';
import { shuffle } from 'd3-array';
import { knownServers } from '../lib/knownServers';
const horrorStarters = [
'I was playing with my boobs.',
'Bird 1: Uh oh.',
'My girlfriend smirked as she waved the positive pregnancy test in my face.',
'I cum in the sink.',
'My girlfriend had dementia and was slowly regaining her memories.',
'"You are what you eat." said the blue fairy unwisely.',
'Just saw the FNAF movie...',
'After rubbing the lamp, I wished for a million bucks.',
'math teacher: the boat is 50 feet long.',
'I am petrified of water, even drinking it terrifies me.',
'I heard my wife knock on the bathroom door.',
'"God isnt real!" Said the atheist.',
'I was walking to my local Waffle House.',
'Knowing I have intense feet fetish, my wife surprised me last night with her lovely feet in view as I entered the room.',
'I was playing with my big boobs then I remembered.',
'As per routing, I put my headphones on and a video of an anime girl doing ear-licking ASMR to help me to bed.',
'My grandma has 206 bones in her body.',
'"You dont have object permanence" said the doctor.',
'I saw a kid at my school not stand up for the National Anthem.',
'After my one-night stand with the mysterious beauty, my penis began to itch and ache terribly.',
'I went werewolf hunting for the first time.',
'"For my first wish" he said, "I want to be a girl!".',
'When she found the man starving and on the brink of death, she had only one thing to offer - her still lactating breast',
'"Girl dont have penises," I said confidently.',
'I was grabbing a quick midnight snack, but that\'s when I saw him.',
'I was about to make out with a woman untill...',
'My eyes widened in shock and horror as I watched my son tear open his Christmas present.',
'I hate being virgin.',
'Obama was elected president...',
'I went into my first day as a police officer happy, as could be.',
'why does peopl like to call joe bidet "sleepy joe"...',
'My boss exploded.',
'As I lay naked strapped to bed, i couldn\'t wait till my husband came back home.',
'There are two trans girl inside a wolf.',
'This morning, I woke up left-handed.',
'I prayed to God for me to not have a sleep paralysis demon on top of me every night.'
];
async function getContinuation(player: User, i: number, halves: string[], backwards = false) {
const currentHalf = halves[i];
let nextHalf = await getTextResponsePrettyPlease(
player,
`> _${currentHalf}_\n${backwards ? 'What would this sentence be **preceeded by**? (Write the first sentence.)' : '**Continue** this sentence with a twist!'}`,
(msg) => !(msg.includes('. ') || msg.includes('! ') || msg.includes('? '))
);
if (!(nextHalf.endsWith('.') || nextHalf.endsWith('!') || nextHalf.endsWith('?'))) nextHalf = nextHalf + '.';
return nextHalf;
}
function shift<T>(arr: T[]): T[] {
return [...arr.slice(1), arr[0]];
}
module.exports = {
data: new SlashCommandBuilder()
.setName('twosentencehorror')
@ -14,38 +71,35 @@ module.exports = {
if (!interaction.isChatInputCommand()) return;
startGame(interaction, member.user, 'Two Sentence Horror', async (players, channel) => {
const firstPlayers = shuffle(players);
const secondPlayers = [...firstPlayers.slice(1), firstPlayers[0]]; // shift by 1
players = shuffle(players);
const firstHalves = await Promise.all(firstPlayers.map(async (firstPlayer) => {
let firstHalf = await getTextResponsePrettyPlease(
firstPlayer,
`Start a horror story... (1 sentence max!) (try working with: “${randomWord()}”)\n\n**Send a message to continue**`,
(msg) => !(msg.includes('. ') || msg.includes('! ') || msg.includes('? '))
);
const initialHalves = shuffle(horrorStarters).slice(0, players.length);
if (!(firstHalf.endsWith('.') || firstHalf.endsWith('!') || firstHalf.endsWith('?'))) firstHalf = firstHalf + '.';
// bottom branch
const secondHalves1 = await Promise.all(players.map((player, i) => getContinuation(player, i, initialHalves, false)));
players = shift(players);
// bottom branch
const firstHalves1 = await Promise.all(players.map((player, i) => getContinuation(player, i, secondHalves1, true)));
players = shift(players);
// top branch
const secondHalves2 = await Promise.all(players.map((player, i) => getContinuation(player, i, initialHalves, false)));
players = shift(players);
// top branch
const firstHalves2 = await Promise.all(players.map((player, i) => getContinuation(player, i, secondHalves2, true)));
players = shift(players);
// bottom branch
const secondHalves1Alt = await Promise.all(players.map((player, i) => getContinuation(player, i, firstHalves2, false)));
players = shift(players);
return firstHalf;
}));
const secondHalves = await Promise.all(secondPlayers.map(async (secondPlayer, i) => {
const firstHalf = firstHalves[i];
let secondHalf = await getTextResponsePrettyPlease(
secondPlayer,
`> _${firstHalf}_\nContinue this sentence with a twist!`,
(msg) => !(msg.includes('. ') || msg.includes('! ') || msg.includes('? '))
);
if (!(secondHalf.endsWith('.') || secondHalf.endsWith('!') || secondHalf.endsWith('?'))) secondHalf = secondHalf + '.';
return secondHalf;
}));
const pairs = [
[initialHalves, secondHalves1Alt],
[firstHalves2, secondHalves1],
[firstHalves1, secondHalves2]
].flatMap(([firstHalves, secondHalves]) => firstHalves.map((first, i) => first + ' ' + secondHalves[i]));
const segments = [
'Here\'s the bone-chilling stories you\'ve all created:\n',
...firstHalves.map((firstHalf, i) => '- ' + firstHalf + ' ' + secondHalves[i]),
...pairs.map(sentences => `- ${sentences}`),
'\nThank you for participating :)'
];