UNPKG

emoji-guess

Version:

Emoji Quest is an interactive command-line game designed for fun! ๐ŸŽ‰ Challenge yourself to decode emoji combinations while enjoying vibrant terminal animations. No pressureโ€”just pure fun! ๐Ÿ˜ƒ

184 lines (166 loc) โ€ข 5.59 kB
#!/usr/bin/env node import chalk from "chalk"; import gradient, { rainbow } from "gradient-string"; import figlet from "figlet"; import inquirer from "inquirer"; import { createSpinner } from "nanospinner"; import chalkAnimation from "chalk-animation"; let PlayerName; let Score = 0; const TOTAL_QUESTIONS = 5; // Number of questions to ask per game const sleep = (ms = 2000) => new Promise((resolve) => setTimeout(resolve, ms)); console.clear(); async function Welcome() { const title = chalkAnimation.glitch("๐ŸŽ‰ EMOJI QUEST! ๐ŸŽ‰",0.5); await sleep(); title.stop(); const gameTitle = chalkAnimation.rainbow("๐ŸŽฎ The Ultimate Emoji Challenge ๐ŸŽฎ\n"); await sleep(); gameTitle.stop(); console.log(` ${chalk.bgCyan.black(' HOW TO PLAY ')} ${chalk.cyan('โ€ข')} You'll face ${TOTAL_QUESTIONS} random emoji combinations ${chalk.cyan('โ€ข')} Each correct answer earns you ${chalk.green('20 points')} ${chalk.cyan('โ€ข')} Get any question wrong and... ${chalk.bgRed(' GAME OVER ')} ${chalk.cyan('โ€ข')} Reach ${chalk.yellow((TOTAL_QUESTIONS * 20))} points to win! ๐Ÿ† `); } async function askName() { const answer = await inquirer.prompt({ name: 'player_name', type: 'input', message: chalk.yellow('๐Ÿ‘พ What shall we call you, brave challenger?'), default() { return 'Skibidi'; }, }); PlayerName = answer.player_name; } const questions = [ { emoji: '๐Ÿ”ฅ๐Ÿฅท', choices: ['Fire Fighter', 'Dragon Ninja', 'Ninja Hatori'], correct: 'Fire Fighter' }, { emoji: '๐ŸŒŠ๐Ÿƒ', choices: ['Wave Runner', 'Beach Sprint', 'Water Chase'], correct: 'Wave Runner' }, { emoji: '๐ŸŽต๐Ÿง ', choices: ['Music Mind', 'Brain Beats', 'Sound Think'], correct: 'Brain Beats' }, { emoji: '๐ŸŒŸ๐Ÿ‘จโ€๐Ÿš€', choices: ['Star Walker', 'Space Captain', 'Cosmic Man'], correct: 'Star Walker' }, { emoji: '๐ŸŽจ๐Ÿฆ‹', choices: ['Art Flutter', 'Paint Wings', 'Butterfly Design'], correct: 'Paint Wings' }, { emoji: '๐ŸŒ™๐Ÿบ', choices: ['Night Wolf', 'Moon Hunter', 'Lunar Howl'], correct: 'Moon Hunter' }, { emoji: 'โšก๐Ÿง™โ€โ™‚๏ธ', choices: ['Lightning Wizard', 'Storm Mage', 'Thunder Spell'], correct: 'Storm Mage' }, { emoji: '๐ŸŽฎ๐ŸงŸ', choices: ['Game Over', 'Zombie Player', 'Digital Undead'], correct: 'Zombie Player' }, { emoji: '๐ŸŒˆ๐Ÿฆ„', choices: ['Color Horse', 'Rainbow Unicorn', 'Magic Pony'], correct: 'Rainbow Unicorn' }, { emoji: '๐Ÿœ๐Ÿ‘ป', choices: ['Noodle Spirit', 'Ramen Ghost', 'Haunted Bowl'], correct: 'Ramen Ghost' }, { emoji: '๐ŸŽช๐Ÿค–', choices: ['Circus Bot', 'Robot Show', 'Mechanical Carnival'], correct: 'Circus Bot' }, { emoji: '๐Ÿฐ๐Ÿ‰', choices: ['Castle Drake', 'Dragon Keep', 'Royal Wings'], correct: 'Dragon Keep' }, { emoji: '๐ŸŽญ๐ŸŽช', choices: ['Circus Drama', 'Theater Tent', 'Festival Mask'], correct: 'Theater Tent' }, { emoji: '๐ŸŒ‹๐Ÿƒโ€โ™‚๏ธ', choices: ['Lava Runner', 'Volcano Escape', 'Heat Sprint'], correct: 'Volcano Escape' }, { emoji: '๐ŸŽฉ๐Ÿฐ', choices: ['Magic Rabbit', 'Hat Trick', 'Wonder Bunny'], correct: 'Hat Trick' } ]; function shuffleArray(array) { for (let i = array.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } return array; } async function askQuestion(questionData) { const answers = await inquirer.prompt({ name: 'question', type: 'list', message: chalk.cyan(`Question ${Score/20 + 1}/${TOTAL_QUESTIONS}: What does this emoji combo mean: ${questionData.emoji}`), choices: shuffleArray([...questionData.choices]) // Shuffle the choices too }); return handleAnswer(answers.question === questionData.correct); } async function handleAnswer(isCorrect) { const spinner = createSpinner('๐Ÿค” Analyzing your answer...').start(); await sleep(); if (isCorrect) { Score += 20; spinner.success({ text: `${chalk.green('๐ŸŽฏ CORRECT!')} ${PlayerName}, you've earned 20 points! Total: ${chalk.yellow(Score)} points` }); } else { spinner.error({ text: `${chalk.red('๐Ÿ’ฅ GAME OVER!')} Sorry, ${PlayerName}! Final Score: ${chalk.yellow(Score)} points` }); console.log("Ok bie ๐Ÿ’€ ๐Ÿ’€ ๐Ÿ’€") process.exit(1); } } function Winner() { console.clear(); const msg = `${PlayerName} WON!`; figlet(msg, (err, data) => { console.log(gradient.rainbow.multiline(data)); console.log(`\n${chalk.green('๐ŸŒŸ Congratulations on conquering the Emoji Quest! ๐ŸŒŸ')}\n`); console.log("Ok bie ๐Ÿ’€ ๐Ÿ’€ ๐Ÿ’€") }); } // Main game flow await Welcome(); await askName(); // Get random questions const gameQuestions = shuffleArray([...questions]).slice(0, TOTAL_QUESTIONS); for (const question of gameQuestions) { await askQuestion(question); await sleep(1000); } Winner();