Pikachuun

choon.js

Feb 9th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2. const readline = require("readline");
  3. const colors = require("colors");
  4. const rl = readline.createInterface({input: process.stdin, output: process.stdout});
  5. let choon = function() {
  6.     this.happiness = 0;
  7.     this.numfamiliar = 0;
  8.     this.pointless = 144.441;
  9.     this.name = "Choon";
  10.     this.spec = "human";
  11.     this.reisenCount = 0;
  12. }
  13. let args = [];
  14. for (var i = 2; i < process.argv.length; i++) {
  15.     if (process.argv[i]) args[i - 2] = process.argv[i];
  16. }
  17.  
  18. let newChoon = new choon();
  19. let happy = 0;
  20. let str = "";
  21. let buffer = "";
  22. let buffer2 = 0;
  23. if (args[0]) newChoon.name = args[0];
  24. console.log("A new Choon called \"" + newChoon.name + "\" was created.");
  25. let main = function () {
  26.     happy = 8 - (newChoon.happiness < 256) - (newChoon.happiness < 128) - (newChoon.happiness < 64) - (newChoon.happiness < 1) - (newChoon.happiness < 0) - (newChoon.happiness < -64) - (newChoon.happiness < -128) - (newChoon.happiness < -256);
  27.     rl.question(newChoon.name.gray + ' is awaiting your command... '.gray, function (cmd) {
  28.         cmd = cmd.toLowerCase();
  29.         if (cmd === "goodbye") {
  30.             str = [" is relieved to see you leave.", " is relieved to see you leave.", " ignores you.", " ignores you.", " waves goodbye.", " waves goodbye.", " gives you a goodbye hug.", " gives you a goodbye hug.", " starts to cry because you're leaving."][happy];
  31.             console.log(newChoon.name + str);
  32.             rl.close();
  33.             return process.exit(0);
  34.         } else if (cmd === "help") {
  35.             str = "List of commands:\ngoodbye, happy, give [reisen|manga], feed [cupcake|ramen|carrot|cereal]";
  36.         } else if (cmd === "happy") {
  37.             str = newChoon.name;
  38.             str += [" doesn't want to have anything to do with you.", " is giving you a death glare.", " appears to hate you.", " appears to dislike you.", " doesn't really have a solid opinion of you.", " appears to like you.", " appears to like you a lot.", " looks elated.", " is lost in his own world of happiness."][happy];
  39.         } else if (cmd.substr(0, 5) === "give " || cmd === "give") {
  40.             if (cmd === "give" || cmd === "give ") {
  41.                 str = "You can't give " + newChoon.name + " nothing...";
  42.             } else {
  43.                 buffer = cmd.substr(5);
  44.                 if (buffer === "reisen" && newChoon.reisenCount === 0) {
  45.                     str = "You gave " + newChoon.name + " Reisen. He looks really happy!";
  46.                     newChoon.reisenCount++;
  47.                     newChoon.happiness += 100;
  48.                 } else if (buffer === "reisen" && newChoon.reisenCount === 1) {
  49.                     str = "You gave " + newChoon.name + " Reisen II as well. He looks even happier.";
  50.                     newChoon.reisenCount++;
  51.                     newChoon.happiness += 50;
  52.                 } else if (buffer === "reisen" && newChoon.reisenCount === 2) {
  53.                     str = newChoon.name + " already has both Reisens. Where are you going to find another one?";
  54.                 } else if (buffer === "manga") {
  55.                     str = "You gave " + newChoon.name + " a manga. He reads it. ";
  56.                     buffer2 = Math.floor(Math.random()*20);
  57.                     if (buffer2 === 0) {
  58.                         str += "Bleh. Ecchi. He throws it away.";
  59.                         newChoon.happiness -= 50;
  60.                     } else if (buffer2 < 3) {
  61.                         str += "Yaoi. He gives it back as he isn't interested in reading that sort of thing.";
  62.                         newChoon.happiness -= 10;
  63.                     } else if (buffer2 < 5) {
  64.                         str += "Yuri. After sending the title to a group of his friends so they can read it later, he returns it.";
  65.                     } else if (buffer2 < 12) {
  66.                         str += "He seemed to enjoy the story, so he kept it for later.";
  67.                         newChoon.happiness += 10;
  68.                     } else if (buffer2 < 19) {
  69.                         str += "He liked the art style, so he kept it for later.";
  70.                         newChoon.happiness += 10;
  71.                     } else {
  72.                         str += "It's a good touhou manga. He kept it for later.";
  73.                         newChoon.happiness += 20;
  74.                     }
  75.                 } else if (buffer === "manga?") {
  76.                     str = "You gave " + newChoon.name + " a questionable manga. After glancing at the cover for a split second he threw it on the ground and burned it. Man, he really hated that.";
  77.                     newChoon.happiness -= 2147483648;
  78.                 } else {
  79.                     str = newChoon.name + " doesn't know what you gave him, but appreciates it anyway.";
  80.                 }
  81.             }
  82.         } else if (cmd.substr(0, 5) === "feed " || cmd === "feed") {
  83.             if (cmd === "feed" || cmd === "feed ") {
  84.                 str = "You can't feed " + newChoon.name + " nothing...";
  85.             } else {
  86.                 buffer = cmd.substr(5);
  87.                 if (buffer === "cupcake" || buffer === "cupcakes") {
  88.                     str = "You fed " + newChoon.name + " a cupcake. He seems to enjoy it!";
  89.                     newChoon.happiness += 20;
  90.                 } else if (buffer === "ramen") {
  91.                     str = "You fed " + newChoon.name + " a bowl of ramen. He seems to like the taste.";
  92.                     newChoon.happiness += 10;
  93.                 } else if (buffer === "reisen" && newChoon.reisenCount === 2) {
  94.                     str = "You don't have any more Reisens to attempt to feed him.";
  95.                 } else if (buffer === "reisen" && newChoon.reisenCount === 1) {
  96.                     str = "You thought about feeding " + newChoon.name + " Reisen II, until you realized that it was a terrible idea.";
  97.                 } else if (buffer === "reisen" && newChoon.reisenCount === 0) {
  98.                     str = "You thought about feeding " + newChoon.name + " Reisen. You sicko.";
  99.                 } else if (buffer === "walfaser" || buffer === "walfasers") {
  100.                     str = "You thought about feeding " + newChoon.name + " walfasers. Why would you even think that's a good idea?";
  101.                 } else if (buffer === "carrot" && newChoon.reisenCount === 2) {
  102.                     str = "You gave " + newChoon.name + " a carrot. He splits it into 2 and gives it to the Reisens, who seem to enjoy it.";
  103.                     newChoon.happiness += 10;
  104.                 } else if (buffer === "carrot" && newChoon.reisenCount === 1) {
  105.                     str = "You gave " + newChoon.name + " a carrot. He shares it with Reisen.";
  106.                     newChoon.happiness += 15;
  107.                 } else if (buffer === "carrot" && newChoon.reisenCount === 0) {
  108.                     str = "You gave " + newChoon.name + " a carrot. He chomps on it.";
  109.                     newChoon.happiness += 5;
  110.                 } else if (buffer === "cereal") {
  111.                     buffer2 = Math.floor(Math.random()*9);
  112.                     switch (buffer2) {
  113.                     case 8:
  114.                         str = "You fed " + newChoon.name + " a bowl of 'FSteak. He seems to enjoy playing with the free walfaser toy more than he does the cereal itself.";
  115.                         newChoon.happiness += 10;
  116.                         break;
  117.                     case 7:
  118.                         str = "You fed " + newChoon.name + " a bowl of Alice's Dolls. He thinks it's okay, but a bit crunchy.";
  119.                         newChoon.happiness += 5;
  120.                         break;
  121.                     case 6:
  122.                         str = "You fed " + newChoon.name + " a bowl of Cirnos. He enjoys the frosting.";
  123.                         newChoon.happiness += 10;
  124.                         break;
  125.                     case 5:
  126.                         str = "You fed " + newChoon.name + " a bowl of Hmm Flakes. He contemplates the flavor before rejecting it.";
  127.                         newChoon.happiness -= 5;
  128.                         break;
  129.                     case 4:
  130.                         str = "You fed " + newChoon.name + " a bowl of Junk-Os. He thinks it's junk.";
  131.                         newChoon.happiness -= 10;
  132.                         break;
  133.                     case 3:
  134.                         str = "You fed " + newChoon.name + " a bowl of I'm Bored. He gets bored of the taste.";
  135.                         newChoon.happiness -= 5;
  136.                         break;
  137.                     case 2:
  138.                         str = "You fed " + newChoon.name + " a bowl of Kagewoo Krunch. He howls out of enjoyment.";
  139.                         newChoon.happiness += 10;
  140.                         break;
  141.                     case 1:
  142.                         str = "You fed " + newChoon.name + " a bowl of Ran Flakes. He calculates the amount of nutrients in it.";
  143.                         newChoon.happiness += 5;
  144.                         break;
  145.                     case 0:
  146.                         if (newChoon.reisenCount === 2) {
  147.                             str = "You gave " + newChoon.name + " a bowl of Reisen Bran. He shares it with the others, who also appear to like it.";
  148.                             newChoon.happiness += 20;
  149.                         } else if (newChoon.reisenCount === 1) {
  150.                             str = "You gave " + newChoon.name + " a bowl of Reisen Bran. He shares it with Reisen, who also appears to like it.";
  151.                             newChoon.happiness += 20;
  152.                         } else {
  153.                             str = "You gave " + newChoon.name + " a bowl of Reisen Bran. After making sure that the raisins aren't actually Reisen, he seemed to like it.";
  154.                             newChoon.happiness += 10;
  155.                         }
  156.                         break;
  157.                     default:
  158.                         str = "You gave " + newChoon.name + " a bowl of ???????????. Wait that isn't supposed to happen!";
  159.                     }
  160.                 } else {
  161.                     str = newChoon.name + " wants to be sure that he knows what that is before he eats it.";
  162.                 }
  163.             }
  164.         } else {
  165.             str = "I'm pretty sure that's an invalid command.";
  166.         }
  167.         console.log(str);
  168.         main();
  169.     });
  170. }
  171. main();
Advertisement
Add Comment
Please, Sign In to add comment