You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e66b28e
Browse filesBrowse the repository at this point in the historyBrowse files
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.
133
133
134
134
// Stretch task:
135
135
// * Create Villain and Hero constructor functions that inherit from the Humanoid constructor function.
136
136
// * 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;
137
137
// * Create two new objects, one a villain and one a hero and fight it out with methods!
138
+
139
+
constHero=newHumanoid({
140
+
createdAt: newDate(),
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
+
constVillan=newHumanoid({
154
+
createdAt: newDate(),
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`);
0 commit comments