forked from mozilla/BrowserQuest
-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy pathitem.js
36 lines (28 loc) · 829 Bytes
/
item.js
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
define(['entity'], function(Entity) {
var Item = Entity.extend({
init: function(id, kind, type) {
this._super(id, kind);
this.itemKind = Types.getKindAsString(kind);
this.type = type;
this.wasDropped = false;
},
hasShadow: function() {
return true;
},
onLoot: function(player) {
if(this.type === "weapon") {
player.switchWeapon(this.itemKind);
}
else if(this.type === "armor") {
player.armorloot_callback(this.itemKind);
}
},
getSpriteName: function() {
return "item-"+ this.itemKind;
},
getLootMessage: function() {
return this.lootMessage;
}
});
return Item;
});