Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //SW constructor
- function SnowWhite() {
- this.name = "Snow White👶";
- this.age = 0;
- this.fairness = 0;
- this.colorOfSkin = "white";
- this.goodState = "good";
- this.location = "castle";
- this.alive = true;
- this.cleans = function (place) {
- console.log(`${this.name} making all homework in ${place}.`);
- };
- this.grow = function () {
- this.age++;
- this.fairness++;
- };
- this.eat = function (what) {
- console.log(`${this.name} eats ${what.name} and falls on ground!`);
- this.alive = false;
- what.location = `${this.name}'s throat!`
- console.log(`${what.name} is now in ${what.location}`);
- };
- this.fallsInLove = function (who){
- console.log(`${this.name} falls in love with ${who.name}`);
- }
- this.marry = function (who){
- console.log(`${this.name} marry ${who.name}`);
- }
- }
- //Queen constructor
- function EvilQueen() {
- this.name = "Queen👸";
- this.oldLadyMood = false;
- this.age = 22;
- this.fairness = 9;
- this.mood = "good";
- this.location = "castle";
- this.fosterDaugther = sw;
- this.TimeOfLife = "Once upon a time";
- this.changeSkinColor = function (color) {
- this.colorOfSkin = color;
- };
- this.askMirror = function (mirror) {
- console.log(
- `${eq.name}: Mirror on the wall, who is the fairest of them all?`
- );
- console.log(`${mir.name} answers: ${mirror.whoIsTheFairest().name}`);
- };
- this.grow = function () {
- this.age++;
- };
- this.askHunter = function () {
- if (hunt.lieToQueen) {
- console.log(`${eq.name} asked ${hunt.name} about ${sw.name}`);
- console.log(`${eq.name}: Did you, ${hunt.name} killed ${sw.name}?`);
- console.log(`${hunt.name}: Yes, my ${eq.name}!`);
- }
- };
- this.becomeUgly = function (){
- this.fairness = 0
- if (this.fairness < 5){
- console.log(`${this.name} became ugly!`);
- }
- }
- }
- //Mirror constructor
- function Mirror() {
- this.name = "magic✨mirror";
- this.abilityToSpeak = true;
- if (this.abilityToSpeak) {
- this.alwaysTellTheTruth = true;
- }
- this.owner = eq;
- this.chicks = [];
- this.whoIsTheFairest = function () {
- return this.chicks.sort((a, b) => b.fairness - a.fairness)[0];
- };
- }
- //Hunter constructor
- function Hunter() {
- this.name = "Hunter🧔";
- this.location = "castle";
- this.goodState = "good";
- lieToQueen = false;
- this.tryToKill = function (who) {
- this.functionName = "kill";
- this.location = "forest📍";
- who.location = "forest📍";
- console.log(`${this.name} went to ${this.location}`);
- console.log(`${who.name} went to ${who.location}`);
- console.log(`${this.name} tried to ${this.functionName} ${who.name}`);
- console.log(
- `But ${this.name} was too ${this.goodState} and couldn't ${this.functionName} ${who.name}`
- );
- this.lieToQueen = true;
- };
- }
- //Dwarfs constructor
- function Dwarf(name) {
- this.name = name;
- }
- let dwarfs = [
- { name: "Doc " },
- { name: "Grumpy" },
- { name: "Happy " },
- { name: "Sleepy " },
- { name: "Bashful " },
- { name: "Sneezy" },
- ];
- let dwarfsObjects = dwarfs.map((item) => new Dwarf(item.name));
- let firstDwarf = dwarfsObjects[0];
- Dwarf.prototype.location = "Dwarf's House";
- //Apple constructor
- function Apple() {
- this.name = "Apple🍎";
- this.poisonous = false;
- this.location = "nowhere"
- this.posion = function () {
- this.poisonous = true;
- this.location = "Queen's pocket"
- console.log(`${this.name} is in ${this.location} now!`);
- console.log(`Apple became poisonous now! ${eq.name} made it!`);
- };
- }
- //Prince constructor
- function Prince() {
- this.name = "Prince🤴";
- this.handsome = true;
- this.location = "nowhere";
- this.necroman = true;
- this.sawAnybody = function (who) {
- console.log(`${this.name} saw ${who.name}`);
- };
- this.inLove = function (who) {
- console.log(`${this.name} falled in love with ${who.name}`);
- };
- this.checkSomebody = function (who) {
- if (who.alive == false) {
- console.log(`${this.name} checked ${who.name} and it's dead!`);
- } else {
- console.log(`${this.name} checked ${who.name} and it's alive!`);
- }
- };
- this.kiss = function (who) {
- if (!who.alive && this.necroman)
- console.log(`${this.name} kissed ${who.name}!`);
- appl.location = "stomach"
- console.log(`Apple is in ${who.name}'s ${appl.location} now!`);
- who.alive = true;
- };
- }
- let sw = new SnowWhite();
- let eq = new EvilQueen();
- let mir = new Mirror();
- let hunt = new Hunter();
- let appl = new Apple();
- let princ = new Prince();
- mir.chicks = [sw, eq];
- console.log(`${eq.TimeOfLife} lived a ${eq.name}.`);
- function changeLocation(who, where) {
- who.location = who.location + "📍";
- console.log(`So, ${who.name} came from ${who.location}`);
- who.location = where + "📍";
- console.log(`to ${who.location}`);
- }
- if (eq.fairness > 5) {
- console.log("She was unbelievably beautiful💅🏻.");
- }
- if (mir.owner == eq) {
- console.log(`${eq.name} had a ${mir.name},`);
- console.log(
- mir.abilityToSpeak ? "which could speak 🗣️, and" : "which couldn't speak..."
- );
- console.log(
- mir.alwaysTellTheTruth
- ? `${mir.name} always tell the truth!`
- : `${mir.name} wasn't speaking truth all the time...`
- );
- console.log(`${eq.name} had a foster daugther ${eq.fosterDaugther.name}`);
- console.log(
- `${eq.name} was asking the mirror several times a day the same question:`
- );
- console.log("\n");
- for (let i = 1; i < 10; i++) {
- sw.grow();
- eq.grow();
- console.log(`Year ${i}:`);
- eq.askMirror(mir);
- }
- }
- console.log(`${sw.name} was growing a ${sw.goodState} person.`);
- console.log(`${eq.name} was in a ${eq.mood} mood!`);
- sw.grow();
- eq.grow();
- console.log(
- `One day ${sw.name} had ${sw.fairness} points of beauty and ${eq.name} had ${eq.fairness} points of beauty only!`
- );
- eq.askMirror(mir);
- console.log(`So, ${sw.name} `);
- sw.name = "Snow White👸";
- console.log(`became ${sw.name}!`);
- console.log(`But ${eq.name}`);
- eq.name = "Queen👵";
- console.log(`became ${eq.name}!`);
- eq.mood = "bad";
- console.log(`${eq.name} is in a ${eq.mood} mood now!`);
- console.log(`${eq.name} asked ${hunt.name} to kill ${sw.name}`);
- hunt.tryToKill(sw);
- changeLocation(hunt, "castle");
- eq.askHunter();
- changeLocation(sw, firstDwarf.location);
- sw.cleans(sw.location)
- eq.askMirror(mir);
- console.log(`${eq.name}: Where is she?`);
- console.log(`${mir.name}: In the ${sw.location}`);
- changeLocation(sw, "forest");
- eq.changeSkinColor("green");
- console.log(`${eq.name} became ${eq.colorOfSkin}`);
- if (eq.colorOfSkin == "green") {
- eq.oldLadyMood = true;
- appl.posion();
- }
- if (eq.oldLadyMood) {
- console.log(`${eq.name} changed clothes and looks like Old Lady!`);
- }
- changeLocation(eq, sw.location);
- sw.eat(appl);
- changeLocation(eq, "castle");
- changeLocation(princ, sw.location);
- princ.sawAnybody(sw);
- princ.checkSomebody(sw);
- princ.kiss(sw);
- princ.checkSomebody(sw);
- princ.inLove(sw);
- sw.fallsInLove(princ)
- sw.marry(princ)
- eq.becomeUgly()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement