-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitems.js
More file actions
47 lines (41 loc) · 1.03 KB
/
items.js
File metadata and controls
47 lines (41 loc) · 1.03 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
'use strict';
function Item(name, effect) {
this.name = name;
this.effect = effect;
}
function Weapon(name, damage, extraEffect) {
Item.call(this,name,extraEffect);
this.effect = extraEffect || new Effect({});
this.damage = damage;
this.effect.hp = -damage;
}
Weapon.prototype = Object.create(Item.prototype);
Weapon.prototype.constructor = Weapon;
function Scroll(name, cost, effect) {
Item.call(this, name, effect);
this.cost = cost;
}
Scroll.prototype = Object.create(Item.prototype);
Scroll.prototype.constructor = Scroll;
Scroll.prototype.canBeUsed = function (mp) {
if(mp >= this.cost){
return true;
}else {
return false;
}
};
function Effect(variations) {
variations = variations || {};
this.initiative = variations.initiative || 0;
this.defense = variations.defense || 0;
this.hp = variations.hp || 0;
this.maxHp = variations.maxHp || 0;
this.mp = variations.mp || 0;
this.maxMp = variations.maxMp || 0;
}
module.exports = {
Item: Item,
Weapon: Weapon,
Scroll: Scroll,
Effect: Effect
};