UNPKG

heidei_simulator

Version:

A tiny, silly package inspired by the viral "Heidei and the five" story

68 lines (59 loc) 2.78 kB
const input = require("prompt-sync")(); const GraphemeSplitter = require("grapheme-splitter"); const splitter = new GraphemeSplitter(); function typeWrite(text, speed = 50) { return new Promise((resolve) => { const chars = splitter.splitGraphemes(text); let i = 0; const interval = setInterval(() => { process.stdout.write(chars[i]); i++; if (i >= chars.length) { clearInterval(interval); process.stdout.write("\n"); resolve(); } }, speed); }); } async function heidei() { console.clear(); await typeWrite("Welcome to the heidei Simulator 👋", 50); let name = input("Enter your name: "); console.clear(); await typeWrite(`Hello, ${name}! You have exactly £5 in your pocket.`, 50); await typeWrite("What do you want to do?", 50); await typeWrite("1. Buy some chips 🍟", 50); await typeWrite("2. Give it to someone in need", 50); await typeWrite("3. Just keep it 💼", 50); let choice = input("Choose (1/2/3): "); console.clear(); if (choice === "1") { await typeWrite("You bought some chips... 🥲", 50); await typeWrite("The internet expected more from a hero like you!", 50); await typeWrite("You lost an offer from B-laban to make 'heidei Dubai'", 50); await typeWrite("You're pathetic!", 50); } else if (choice === "2") { await typeWrite("YOU DID IT! You gave away the £5 ... now you're a viral!", 50); await typeWrite("Internet’s calling you 'World Champion in Doing Good'!", 50); await typeWrite("B-laban is calling you to make a new brand of 'Dubai Cake'", 50); await typeWrite("'heidei Dubai' is officially released! and you are rich!", 50); await typeWrite("What do you wanna do next?", 50); await typeWrite("1. Keep giving to the poor ❤️", 50); await typeWrite("2. Stop giving and enjoy your wealth 💰", 50); let subChoice = input("Choose (1/2): "); console.clear(); if (subChoice === "1") { await typeWrite("heidei is proud of you! 🌟 Keep spreading goodness!", 50); } else { await typeWrite("The internet expected more from a hero like you! 😅", 50); } } else if (choice === "3") { await typeWrite("You kept the £5. No cheers. Just you... with five lonely pounds.", 50); return `${name} chose to keep it and stay under the radar`; } else { await typeWrite("That’s not a valid choice! heidei is confused!", 50); return `Confused heidei mode activated`; } } module.exports = { heidei };