-
Notifications
You must be signed in to change notification settings - Fork 19
/
keywords-creatures.js
67 lines (55 loc) · 2.24 KB
/
keywords-creatures.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
keywords.cards.name = function (entity, obj, value) {
com.cardshifter.modapi.attributes.ECSAttributeMap.createOrGetFor(entity).set(com.cardshifter.modapi.attributes.Attributes.NAME, value);
}
keywords.cards.flavor = function (entity, obj, value) {
com.cardshifter.modapi.attributes.ECSAttributeMap.createOrGetFor(entity).set(com.cardshifter.modapi.attributes.Attributes.FLAVOR, value);
}
keywords.cards.creature = function (entity, obj, value) {
var actions = new com.cardshifter.modapi.actions.ActionComponent();
entity.addComponent(actions);
var playAction = new ECSAction(entity, PLAY_ACTION, function (act) { return true; }, function (act) {});
var attackAction = new ECSAction(entity, ATTACK_ACTION, function (act) { return true; }, function (act) {}).addTargetSet(1, 1);
var scrapAction = new ECSAction(entity, SCRAP_ACTION, function (act) { return true; }, function (act) {});
actions.addAction(playAction);
actions.addAction(attackAction);
actions.addAction(scrapAction);
entity.addComponent(new com.cardshifter.modapi.base.CreatureTypeComponent(value));
var map = com.cardshifter.modapi.resources.ECSResourceMap.createOrGetFor(entity);
map.set(SICKNESS, 1);
map.set(TAUNT, 1);
map.set(ATTACK_AVAILABLE, 1);
}
keywords.cards.manaCost = function (entity, obj, value) {
MANA_COST.retriever.set(entity, value);
}
keywords.cards.health = function (entity, obj, value) {
if (!obj.creature) {
throw new Error("expected creature");
}
HEALTH.retriever.set(entity, value);
MAX_HEALTH.retriever.set(entity, value);
}
keywords.cards.attack = function (entity, obj, value) {
if (!obj.creature) {
throw new Error("expected creature");
}
ATTACK.retriever.set(entity, value);
}
keywords.cards.scrap = function (entity, obj, value) {
if (!obj.creature) {
throw new Error("expected creature");
}
SCRAP.retriever.set(entity, value);
}
keywords.cards.sickness = function (entity, obj, value) {
if (!obj.creature) {
throw new Error("expected creature");
}
SICKNESS.retriever.set(entity, value);
}
keywords.cards.denyCounterAttack = function (entity, obj, value) {
if (!obj.creature) {
throw new Error("expected creature");
}
DENY_COUNTERATTACK.retriever.set(entity, value);
}