Advertisement
AlexandrP

Untitled

Jan 26th, 2023
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //SW constructor
  2. function SnowWhite() {
  3.   this.name = "Snow White👶";
  4.   this.age = 0;
  5.   this.fairness = 0;
  6.   this.colorOfSkin = "white";
  7.   this.goodState = "good";
  8.   this.location = "castle";
  9.   this.alive = true;
  10.   this.cleans = function (place) {
  11.     console.log(`${this.name} making all homework in ${place}.`);
  12. };
  13.  
  14.   this.grow = function () {
  15.     this.age++;
  16.     this.fairness++;
  17.   };
  18.  
  19.   this.eat = function (what) {
  20.     console.log(`${this.name} eats ${what.name} and falls on ground!`);
  21.     this.alive = false;
  22.     what.location = `${this.name}'s throat!`
  23.    console.log(`${what.name} is now in ${what.location}`);
  24.  };
  25.  
  26.  this.fallsInLove = function (who){
  27.    console.log(`${this.name} falls in love with ${who.name}`);
  28.  }
  29.  
  30.  this.marry = function (who){
  31.    console.log(`${this.name} marry ${who.name}`);
  32.  }
  33. }
  34. //Queen constructor
  35. function EvilQueen() {
  36.  this.name = "Queen👸";
  37.  this.oldLadyMood = false;
  38.  this.age = 22;
  39.  this.fairness = 9;
  40.  this.mood = "good";
  41.  this.location = "castle";
  42.  this.fosterDaugther = sw;
  43.  this.TimeOfLife = "Once upon a time";
  44.  this.changeSkinColor = function (color) {
  45.    this.colorOfSkin = color;
  46.  };
  47.  
  48.  this.askMirror = function (mirror) {
  49.    console.log(
  50.      `${eq.name}: Mirror on the wall, who is the fairest of them all?`
  51.    );
  52.    console.log(`${mir.name} answers: ${mirror.whoIsTheFairest().name}`);
  53.  };
  54.  this.grow = function () {
  55.    this.age++;
  56.  };
  57.  
  58.  this.askHunter = function () {
  59.    if (hunt.lieToQueen) {
  60.      console.log(`${eq.name} asked ${hunt.name} about ${sw.name}`);
  61.      console.log(`${eq.name}: Did you, ${hunt.name} killed ${sw.name}?`);
  62.      console.log(`${hunt.name}: Yes, my ${eq.name}!`);
  63.    }
  64.  };
  65.  
  66.  this.becomeUgly = function (){
  67.    this.fairness = 0
  68.    
  69.    if (this.fairness < 5){
  70.      console.log(`${this.name} became ugly!`);
  71.    }
  72.  }
  73. }
  74. //Mirror constructor
  75. function Mirror() {
  76.  this.name = "magic✨mirror";
  77.  this.abilityToSpeak = true;
  78.  
  79.  if (this.abilityToSpeak) {
  80.    this.alwaysTellTheTruth = true;
  81.  }
  82.  
  83.  this.owner = eq;
  84.  this.chicks = [];
  85.  
  86.  this.whoIsTheFairest = function () {
  87.    return this.chicks.sort((a, b) => b.fairness - a.fairness)[0];
  88.  };
  89. }
  90.  
  91. //Hunter constructor
  92. function Hunter() {
  93.  this.name = "Hunter🧔";
  94.  this.location = "castle";
  95.  this.goodState = "good";
  96.  lieToQueen = false;
  97.  this.tryToKill = function (who) {
  98.    this.functionName = "kill";
  99.    this.location = "forest📍";
  100.    who.location = "forest📍";
  101.    console.log(`${this.name} went to ${this.location}`);
  102.    console.log(`${who.name} went to ${who.location}`);
  103.  
  104.    console.log(`${this.name} tried to ${this.functionName} ${who.name}`);
  105.  
  106.    console.log(
  107.      `But ${this.name} was too ${this.goodState} and couldn't ${this.functionName} ${who.name}`
  108.     );
  109.     this.lieToQueen = true;
  110.   };
  111. }
  112.  
  113. //Dwarfs constructor
  114. function Dwarf(name) {
  115.   this.name = name;
  116. }
  117. let dwarfs = [
  118.   { name: "Doc " },
  119.   { name: "Grumpy" },
  120.   { name: "Happy " },
  121.   { name: "Sleepy " },
  122.   { name: "Bashful " },
  123.   { name: "Sneezy" },
  124. ];
  125.  
  126. let dwarfsObjects = dwarfs.map((item) => new Dwarf(item.name));
  127.  
  128. let firstDwarf = dwarfsObjects[0];
  129.  
  130. Dwarf.prototype.location = "Dwarf's House";
  131.  
  132. //Apple constructor
  133. function Apple() {
  134.   this.name = "Apple🍎";
  135.   this.poisonous = false;
  136. this.location = "nowhere"
  137.   this.posion = function () {
  138.     this.poisonous = true;
  139.     this.location = "Queen's pocket"
  140.     console.log(`${this.name} is in ${this.location} now!`);
  141.     console.log(`Apple became poisonous now! ${eq.name} made it!`);
  142.   };
  143. }
  144.  
  145. //Prince constructor
  146. function Prince() {
  147.   this.name = "Prince🤴";
  148.   this.handsome = true;
  149.   this.location = "nowhere";
  150.  
  151.   this.necroman = true;
  152.  
  153.   this.sawAnybody = function (who) {
  154.     console.log(`${this.name} saw ${who.name}`);
  155.   };
  156.  
  157.   this.inLove = function (who) {
  158.     console.log(`${this.name} falled in love with ${who.name}`);
  159.   };
  160.  
  161.   this.checkSomebody = function (who) {
  162.     if (who.alive == false) {
  163.       console.log(`${this.name} checked ${who.name} and it's dead!`);
  164.    } else {
  165.      console.log(`${this.name} checked ${who.name} and it's alive!`);
  166.     }
  167.   };
  168.   this.kiss = function (who) {
  169.     if (!who.alive && this.necroman)
  170.       console.log(`${this.name} kissed ${who.name}!`);
  171.       appl.location = "stomach"
  172.       console.log(`Apple is in ${who.name}'s ${appl.location} now!`);
  173.    who.alive = true;
  174.  };
  175. }
  176. let sw = new SnowWhite();
  177. let eq = new EvilQueen();
  178. let mir = new Mirror();
  179. let hunt = new Hunter();
  180. let appl = new Apple();
  181. let princ = new Prince();
  182.  
  183. mir.chicks = [sw, eq];
  184.  
  185. console.log(`${eq.TimeOfLife} lived a ${eq.name}.`);
  186.  
  187. function changeLocation(who, where) {
  188.  who.location = who.location + "📍";
  189.  console.log(`So, ${who.name} came from ${who.location}`);
  190.  who.location = where + "📍";
  191.  console.log(`to ${who.location}`);
  192. }
  193.  
  194. if (eq.fairness > 5) {
  195.  console.log("She was unbelievably beautiful💅🏻.");
  196. }
  197.  
  198. if (mir.owner == eq) {
  199.  console.log(`${eq.name} had a ${mir.name},`);
  200.  console.log(
  201.    mir.abilityToSpeak ? "which could speak 🗣️, and" : "which couldn't speak..."
  202.  );
  203.  console.log(
  204.    mir.alwaysTellTheTruth
  205.      ? `${mir.name} always tell the truth!`
  206.      : `${mir.name} wasn't speaking truth all the time...`
  207.  );
  208.  
  209.  console.log(`${eq.name} had a foster daugther ${eq.fosterDaugther.name}`);
  210.  
  211.  console.log(
  212.    `${eq.name} was asking the mirror several times a day the same question:`
  213.  );
  214.  console.log("\n");
  215.  for (let i = 1; i < 10; i++) {
  216.    sw.grow();
  217.    eq.grow();
  218.  
  219.    console.log(`Year ${i}:`);
  220.    eq.askMirror(mir);
  221.  }
  222. }
  223.  
  224. console.log(`${sw.name} was growing a ${sw.goodState} person.`);
  225.  
  226. console.log(`${eq.name} was in a ${eq.mood} mood!`);
  227. sw.grow();
  228. eq.grow();
  229.  
  230. console.log(
  231.  `One day ${sw.name} had ${sw.fairness} points of beauty and ${eq.name} had ${eq.fairness} points of beauty only!`
  232. );
  233.  
  234. eq.askMirror(mir);
  235.  
  236. console.log(`So, ${sw.name} `);
  237. sw.name = "Snow White👸";
  238. console.log(`became ${sw.name}!`);
  239.  
  240. console.log(`But ${eq.name}`);
  241. eq.name = "Queen👵";
  242.  
  243. console.log(`became ${eq.name}!`);
  244.  
  245. eq.mood = "bad";
  246.  
  247. console.log(`${eq.name} is in a ${eq.mood} mood now!`);
  248.  
  249. console.log(`${eq.name} asked ${hunt.name} to kill ${sw.name}`);
  250.  
  251. hunt.tryToKill(sw);
  252.  
  253. changeLocation(hunt, "castle");
  254.  
  255. eq.askHunter();
  256.  
  257. changeLocation(sw, firstDwarf.location);
  258. sw.cleans(sw.location)
  259.  
  260. eq.askMirror(mir);
  261. console.log(`${eq.name}: Where is she?`);
  262. console.log(`${mir.name}: In the ${sw.location}`);
  263.  
  264. changeLocation(sw, "forest");
  265.  
  266. eq.changeSkinColor("green");
  267. console.log(`${eq.name} became ${eq.colorOfSkin}`);
  268.  
  269. if (eq.colorOfSkin == "green") {
  270.  eq.oldLadyMood = true;
  271.  
  272.  appl.posion();
  273. }
  274.  
  275. if (eq.oldLadyMood) {
  276.  console.log(`${eq.name} changed clothes and looks like Old Lady!`);
  277. }
  278. changeLocation(eq, sw.location);
  279.  
  280. sw.eat(appl);
  281.  
  282. changeLocation(eq, "castle");
  283.  
  284. changeLocation(princ, sw.location);
  285.  
  286. princ.sawAnybody(sw);
  287. princ.checkSomebody(sw);
  288. princ.kiss(sw);
  289. princ.checkSomebody(sw);
  290. princ.inLove(sw);
  291.  
  292. sw.fallsInLove(princ)
  293. sw.marry(princ)
  294.  
  295. eq.becomeUgly()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement