With some switch/case
and some conditionals, I’ve got a cutie lil game I made for the codecademy class. Load it up if you like!
Edit note, for readability I altered some of the spacing and tabbing.
var user = prompt("You are wandering along Deck 7. People don't use this one as much as the others, and doesn't smell as much like gorba root, the principal trade roughage of The Captaincy. As you rest your bones to look out the viewport onto the planet whose gorba the crew of The Captaincy just acquired, your Eye Viewer switches to life: \n\n'ALERT ---- ALERT ---- ALERT\n\n SHIP IS BEING INVADED ---- EVACUATE TO ESCAPE SHUTTLES FOR IMMEDIATE DISCHARGE\n\n SHUTTLES TO DISCHARGE IN THIRTY SECONDS'\n\n Oh no!! What do you do?\n - If you would like to contemplate a bit more, type 'think'.\n - If you would like to look around for something to entertain yourself on the no doubt long, slow voyage to the next system with unknown shuttlemates, type 'look'.\n - If you want to just get to da choppah, type 'shuttle'.").toLowerCase(); switch(user) { case 'think': var thinking = prompt("what do you think about? you can think about 'escape', your 'cat', or 'cheese'.").toLowerCase(); if (thinking === 'escape') { console.log("excellent! you get to the shuttle. you live!"); } else if (thinking === 'cat') { console.log("such a fuzzy whatnot kitty! too bad you are dead now."); } else { console.log("you're thinking about WHAT?? ok, you're dead. imagine that, if the ship is going down, you have to EVACUATE."); } break; case 'look': var looking = prompt("you look over the ship, and you find your e-reader with 500 of your future favorite books and a 4000-pack of eternally shelf-stable, forever delicious squeaky cheese! HOORAY! if you take it, type 'true,' if you don't (ya crum-head) type 'false'."); var secondThing = prompt("ok, now do you get to the shuttle? type 'true' or 'false'."); if (looking && secondThing) { console.log("Moments after you and your VERY ATTRACTIVE shuttlemates strap in to your anti-G gel beds, SHWOOMPF K-CHK K-CHK KSHHHHHHHHHHHHHhhh hhhhh, you have taken off! Enjoy the next several years, and your squeaky cheese! You won!"); } else if (looking || secondThing) { console.log("I guess you got one of them? but not both? you still win, I guess?"); } else { console.log("not really sure but I guess you lost."); } break; case 'shuttle': console.log("you made it! but your tummy's grumbling."); break; default: console.log("your unpredictable behavior is reprehensible."); }
Need to wrap the long strings so that they are readable. Nice writing.
http://inform7.com
Thanks! I’ve edited the code block so it reads a lil nicer.
I know you are excited about switch statements, but did you have to kill my cat too?
it was required for the spell! I promise I’ll get you a replacement duck.
BETTER:
the cat’s not dead, but now your neighbor gets to hang out with him instead since you took your sweet time getting to the shuttle.