Skip to content

Commit e66b28e

Browse files
author
littleknightgames
committed
finished stretch
1 parent 2a37faa commit e66b28e

1 file changed

Lines changed: 47 additions & 8 deletions

File tree

‎assignments/prototypes.js‎

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,55 @@ const archer = new Humanoid({
122122

123123
console.log(mage.createdAt); // Today's date
124124
console.log(archer.dimensions); // { length: 1, width: 2, height: 4 }
125-
console.log(swordsman.healthPoints); // 15
126-
console.log(mage.name); // Bruce
127-
console.log(swordsman.team); // The Round Table
128-
console.log(mage.weapons); // Staff of Shamalama
129-
console.log(archer.language); // Elvish
130-
console.log(archer.greet()); // Lilith offers a greeting in Elvish.
131-
console.log(mage.takeDamage()); // Bruce took damage.
132-
console.log(swordsman.destroy()); // Sir Mustachio was removed from the game.
125+
console.log("\n" + swordsman.healthPoints + "\n"); // 15
126+
console.log(mage.name + "\n"); // Bruce
127+
console.log(swordsman.team + "\n"); // The Round Table
128+
console.log(mage.weapons + "\n"); // Staff of Shamalama
129+
console.log(archer.language + "\n"); // Elvish
130+
console.log(archer.greet() + "\n"); // Lilith offers a greeting in Elvish.
131+
console.log(mage.takeDamage() + "\n"); // Bruce took damage.
132+
console.log(swordsman.destroy() + "\n" + "\n" + "\n" + "\n"); // Sir Mustachio was removed from the game.
133133

134134
// Stretch task:
135135
// * Create Villain and Hero constructor functions that inherit from the Humanoid constructor function.
136136
// * Give the Hero and Villains different methods that could be used to remove health points from objects which could result in destruction if health gets to 0 or drops below 0;
137137
// * Create two new objects, one a villain and one a hero and fight it out with methods!
138+
139+
const Hero = new Humanoid({
140+
createdAt: new Date(),
141+
dimensions: {
142+
length: 1,
143+
width: 2,
144+
height: 4
145+
},
146+
healthPoints: 10,
147+
name: "Hero",
148+
team: "Good guy",
149+
weapons: ["Bow", "Dagger"],
150+
language: "Elvish"
151+
});
152+
153+
const Villan = new Humanoid({
154+
createdAt: new Date(),
155+
dimensions: {
156+
length: 1,
157+
width: 2,
158+
height: 4
159+
},
160+
healthPoints: 1000,
161+
name: "Villan",
162+
team: "bad guy",
163+
weapons: ["Dagger"],
164+
language: "common"
165+
});
166+
167+
console.log(Hero.greet() + "\n");
168+
console.log(Villan.greet() + "\n");
169+
170+
while (Hero.healthPoints > 0) {
171+
console.log(Villan.takeDamage());
172+
console.log(`Villan's health is ${(Villan.healthPoints -= 15)}\n`);
173+
console.log(Hero.takeDamage());
174+
console.log(`Hero's health is ${(Hero.healthPoints -= 1)}\n`);
175+
}
176+
console.log(Hero.destroy());

0 commit comments

Comments
 (0)