-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEventPhase.java
66 lines (56 loc) · 1.85 KB
/
EventPhase.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
public class EventPhase {
private Choice [] EpChoices; // Array to hold the current phase choices
private int numChoices; // Number of choices
private String phaseText; // Text for the current phase
private String baseText; // Original text for phase
// Constructor
public EventPhase (String phaseText, Choice [] choices){
this.phaseText = phaseText;
numChoices = choices.length;
EpChoices = new Choice[numChoices];
for (int i = 0; i < numChoices; i++){
EpChoices[i] = choices[i];
}
baseText = phaseText;
}
// Plays (or prints rather) the text for the current choice (or phase of the event)
public void playPhase(){
System.out.println(phaseText);
for (int i = 0; i < numChoices; i++){
System.out.println(i + ": " + EpChoices[i].getChoiceText());
}
System.out.println();
}
// Accessors and mutators
public int getNumChoices(){
return EpChoices.length;
}
// Simply a function to add text to pre-existing text
public void appendText(String text){
phaseText = text + phaseText;
}
public String getPhaseText(){
return phaseText;
}
public String getChoiceChangeToStory(int choiceNum){
return EpChoices[choiceNum].getChangeToStory();
}
public void setChangeToStory(int choiceNum, String s){
EpChoices[choiceNum].setChangeToStory(s);
}
public String getBaseText(){
return baseText;
}
// Changes the phase text back to its original
public void resetPhaseText(){
phaseText = baseText;
}
public String toString(){
String s = "";
for (int i = 0; i < numChoices; i++){
s += i + ": " + EpChoices[i].toString() + "\n";
}
s+= "\n";
return s;
}
}