-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathimagesRules.drl
92 lines (76 loc) · 2.22 KB
/
imagesRules.drl
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package eu.trentorise.game.model
import eu.trentorise.game.notification.BadgeNotification;
import eu.trentorise.game.core.Utility;
import java.util.Map
import java.util.ArrayList
import java.util.List;
declare AlreadyLevelUp
end
rule "create-image-data"
when
Action(id=="CreateImage")
$customData : CustomData(this["myImages"] == null)
not AlreadyLevelUp()
then
List<String> list = new ArrayList<String>();
$customData.put("myImages", list);
update($customData);
insert(new AlreadyLevelUp());
end
rule "add-image-data"
when
Action(id=="AddImage")
InputData(
$solution:data['solution'];
)
$customData : CustomData(this["level"] >=0)
not AlreadyLevelUp()
then
Map solutionMap = ((Map)$solution);
String myData = ((String)solutionMap.get("imageName"));
System.out.println("is it working?");
ArrayList actualList = (ArrayList)$customData.get("myImages");
actualList.add(myData);
$customData.put("myImages", actualList);
update($customData);
insert(new AlreadyLevelUp());
end
rule "remove-image-data"
when
Action(id=="RemoveImage")
InputData(
$solution:data['solution'];
)
$customData : CustomData(this["level"] >=0)
not AlreadyLevelUp()
then
Map solutionMap = ((Map)$solution);
String myData = ((String)solutionMap.get("imageName"));
ArrayList actualList = (ArrayList)$customData.get("myImages");
actualList.remove(myData);
$customData.put("myImages", actualList);
update($customData);
insert(new AlreadyLevelUp());
end
rule "buy-image-data"
when
Action(id=="BuyImage")
InputData(
$solution:data['solution'];
)
$GoldCoinsScore : PointConcept(name == "GoldCoins")
$customData : CustomData(this["level"] >=0)
not AlreadyLevelUp()
then
Map solutionMap = ((Map)$solution);
String myData = ((String)solutionMap.get("imageName"));
String priceString = ((String)solutionMap.get("price"));
Integer price = Integer.parseInt(priceString);
ArrayList actualList = (ArrayList)$customData.get("myImages");
actualList.add(myData);
Integer moneySpent = Integer.parseInt(priceString);
modify($GoldCoinsScore){setScore($GoldCoinsScore.getScore() - moneySpent);}
$customData.put("myImages", actualList);
update($customData);
insert(new AlreadyLevelUp());
end