-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimaryCharacter.java
More file actions
80 lines (69 loc) · 2.23 KB
/
Copy pathPrimaryCharacter.java
File metadata and controls
80 lines (69 loc) · 2.23 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
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
package storyelements;
import java.util.ArrayList;
import storygenerator.WorldProperty;
/**
*
* @author etienne
*/
public class PrimaryCharacter extends StoryCharacter {
//The hero tries to make all of the properties in this list true:
ArrayList<WorldProperty> aGoalsTrue = new ArrayList<WorldProperty>();
//They also try to make all of the properties in this list false:
ArrayList<WorldProperty> aGoalsFalse = new ArrayList<WorldProperty>();
//If the character is an antagonist, then they try to make at least one of
//the following properties true, thus bringing the hero's quest to failure:
ArrayList<WorldProperty> aAntiGoals = new ArrayList<WorldProperty>();
public PrimaryCharacter(String pOcc) {
super(pOcc);
}
public void addGoalTrue(WorldProperty pGoal) {
aGoalsTrue.add(pGoal);
}
public void addGoalFalse(WorldProperty pGoal) {
aGoalsFalse.add(pGoal);
}
public void addAntiGoal(WorldProperty pGoal) {
aAntiGoals.add(pGoal);
}
public ArrayList<WorldProperty> getGoalsTrue() {
return aGoalsTrue;
}
public ArrayList<WorldProperty> getGoalsFalse() {
return aGoalsFalse;
}
public ArrayList<WorldProperty> getAntiGoals() {
return aAntiGoals;
}
/**
* Returns true if all the goals are in the world state; that is, all the
* goals of the character have been completed.
* @param pWorldState
* @return
*/
public boolean checkGoalCompletion(ArrayList<WorldProperty> pWorldState) {
for (WorldProperty t : aGoalsTrue) {
if (!pWorldState.contains(t)) {
return false;
}
}
for (WorldProperty f : aGoalsFalse) {
if (pWorldState.contains(f)) {
return false;
}
}
return true;
}
/**
* Returns true if at least one anti-goal is realized.
* @param pWorldState
* @return
*/
public boolean checkAntiGoalCompletion(ArrayList<WorldProperty> pWorldState) {
for (WorldProperty g : aAntiGoals) {
if (pWorldState.contains(g)) {
return true;
}
}
return false;
}
}