-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototype.js
More file actions
58 lines (52 loc) · 1.13 KB
/
prototype.js
File metadata and controls
58 lines (52 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class GameObject {
constructor(options) {
this.createdAt = options.createdAt;
this.dimensions = {
length: options.dimensions.length,
height: options.dimensions.height,
width: options.dimensions.width,
};
}
}
GameObject.prototype.destroy = () => 'Game object was removed from the game.';
class NPC extends GameObject {
constructor(options) {
super(options);
this.hp = options.hp;
this.name = options.name;
}
takeDamage() {
return `${this.name} took damage.`;
}
}
class Humanoid extends NPC {
constructor(options) {
super(options);
this.faction = options.faction;
this.weapons = options.weapons;
this.language = options.language;
}
greet() {
return `${this.name} offers a greeting in ${this.language}.`;
}
}
const hamsterHuey = new Humanoid({
createdAt: new Date(),
dimensions: {
length: 2,
width: 1,
height: 1,
},
hp: 5,
name: 'Hamster Huey',
faction: 'Gooey Kablooie',
weapons: ['bubblegum'],
language: 'Hamsterish',
});
// console.log(hamsterHuey);
/* eslint-disable no-undef */
module.exports = {
GameObject,
NPC,
Humanoid,
};