-
Notifications
You must be signed in to change notification settings - Fork 248
Expand file tree
/
Copy pathLine.java
More file actions
76 lines (65 loc) · 2.16 KB
/
Line.java
File metadata and controls
76 lines (65 loc) · 2.16 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
package com.jadventure.game.conversation;
import com.jadventure.game.entities.NPC;
import com.jadventure.game.entities.Player;
import com.jadventure.game.menus.Menus;
import com.jadventure.game.menus.MenuItem;
import java.util.ArrayList;
import java.util.List;
public class Line {
private int id;
private String playerPrompt;
private String text;
private ConditionType condition;
private String conditionParameter;
private List<Integer> responses;
private ActionType action;
public Line(int id, String playerPrompt, String text, ConditionType condition,
String conditionParameter, List<Integer> responses, ActionType action) {
this.id = id;
this.playerPrompt = playerPrompt;
this.text = text;
this.condition = condition;
this.conditionParameter = conditionParameter;
this.responses = responses;
this.action = action;
}
public int getId() {
return id;
}
public String getText() {
return text;
}
public String getPlayerPrompt() {
return playerPrompt;
}
public ConditionType getCondition() {
return condition;
}
public String getConditionParameter() {
return conditionParameter;
}
public ActionType getAction() {
return action;
}
public Line display(NPC npc, Player player, List<Line> lines) {
if (responses.size() == 0) {
return null;
}
List<MenuItem> responseList = new ArrayList<>();
for (Integer responseNum : responses) {
Line response = lines.get(responseNum);
if (ConversationManager.matchesConditions(npc, player, response)) {
responseList.add(new MenuItem(response.getPlayerPrompt(), null));
}
}
Menus responseMenu = new Menus();
MenuItem response = responseMenu.displayMenu(responseList);
for (int responseNum : responses) {
Line possibleResponse = lines.get(responseNum);
if (possibleResponse.getPlayerPrompt().equals(response.getCommand())) {
return possibleResponse;
}
}
return null;
}
}