-
Notifications
You must be signed in to change notification settings - Fork 0
/
TradeItemAction.java
46 lines (35 loc) · 1.93 KB
/
TradeItemAction.java
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
package actions;
import storyelements.Location;
import storyelements.Item;
import storyelements.StoryCharacter;
import storygenerator.WorldProperty;
import storygenerator.WorldProperty.PropertyKey;
/**
*
* @author etienne
*/
public class TradeItemAction extends Action {
public TradeItemAction(StoryCharacter pChar, StoryCharacter pTrader, Location pLoc, Item pGiven, Item pObtained) {
super();
//Text to be displayed when the action is performed in the story
aNarrativeForm = "The " + pChar + " traded " + pChar.getPossessivePronoun()
+ " " + pGiven + " for the " + pTrader + "'s " + pObtained + ".";
//Facts that need to be TRUE to fire the action
aPreTrue.add(new WorldProperty(pChar, PropertyKey.IS_AT_LOCATION, pLoc));
aPreTrue.add(new WorldProperty(pTrader, PropertyKey.IS_AT_LOCATION, pLoc, true));
aPreTrue.add(new WorldProperty(pChar, PropertyKey.OWNS, pGiven));
aPreTrue.add(new WorldProperty(pTrader, PropertyKey.OWNS, pObtained, true));
//Facts that need to be FALSE to fire the action
aPreFalse.add(new WorldProperty(pChar, PropertyKey.HAS_EQUIPPED, pGiven));
aPreFalse.add(new WorldProperty(pChar, PropertyKey.HATES, pTrader));
aPreFalse.add(new WorldProperty(pTrader, PropertyKey.HATES, pChar));
aPreFalse.add(new WorldProperty(pTrader, PropertyKey.IS_CAPTIVE));
aPreFalse.add(new WorldProperty(pTrader, PropertyKey.IS_DEAD, true));
//Facts that BECOME TRUE as a result
aPostTrue.add(new WorldProperty(pChar, PropertyKey.OWNS, pObtained));
aPostTrue.add(new WorldProperty(pTrader, PropertyKey.OWNS, pGiven));
//Facts that BECOME FALSE as a result
aPostFalse.add(new WorldProperty(pChar, PropertyKey.OWNS, pGiven));
aPostFalse.add(new WorldProperty(pTrader, PropertyKey.OWNS, pObtained));
}
}