RuneHive-Game
Loading...
Searching...
No Matches
OptionDialogue.java
Go to the documentation of this file.
1package com.runehive.content.dialogue;
2
3import java.util.ArrayList;
4import java.util.List;
5
6/**
7 * The {@link Chainable} implementation that represents a dialogue in which options are given to the player.
8 *
9 * @author Michael | Chex
10 */
11public final class OptionDialogue implements Chainable {
12
13 /** The text for this dialogue. */
14 private final String[] lines;
15
16 /** The list of actions for this dialogue. */
17 private final List<Runnable> actions = new ArrayList<>();
18
19 /**
20 * Creates a new {@link OptionDialogue}.
21 *
22 * @param option1 The text for the first option.
23 * @param action1 The action for the first action.
24 * @param option2 The text for the second option.
25 * @param action2 The action for the second action.
26 */
27 public OptionDialogue(String option1, Runnable action1, String option2, Runnable action2) {
28 lines = new String[]{option1, option2};
29 actions.add(action1);
30 actions.add(action2);
31 }
32
33 /**
34 * Creates a new {@link OptionDialogue}.
35 *
36 * @param option1 The text for the first option.
37 * @param action1 The action for the first action.
38 * @param option2 The text for the second option.
39 * @param action2 The action for the second action.
40 * @param option3 The text for the third option.
41 * @param action3 The action for the third action.
42 */
43 public OptionDialogue(String option1, Runnable action1, String option2, Runnable action2, String option3, Runnable action3) {
44 lines = new String[]{option1, option2, option3};
45 actions.add(action1);
46 actions.add(action2);
47 actions.add(action3);
48 }
49
50 /**
51 * Creates a new {@link OptionDialogue}.
52 *
53 * @param option1 The text for the first option.
54 * @param action1 The action for the first action.
55 * @param option2 The text for the second option.
56 * @param action2 The action for the second action.
57 * @param option3 The text for the third option.
58 * @param action3 The action for the third action.
59 * @param option4 The text for the four option.
60 * @param action4 The action for the four action.
61 */
62 public OptionDialogue(String option1, Runnable action1, String option2, Runnable action2, String option3, Runnable action3, String option4, Runnable action4) {
63 lines = new String[]{option1, option2, option3, option4};
64 actions.add(action1);
65 actions.add(action2);
66 actions.add(action3);
67 actions.add(action4);
68 }
69
70 /**
71 * Creates a new {@link OptionDialogue}.
72 *
73 * @param option1 The text for the first option.
74 * @param action1 The action for the first action.
75 * @param option2 The text for the second option.
76 * @param action2 The action for the second action.
77 * @param option3 The text for the third option.
78 * @param action3 The action for the third action.
79 * @param option4 The text for the four option.
80 * @param action4 The action for the four action.
81 * @param option5 The text for the fifth option.
82 * @param action5 The action for the fifth action.
83 */
84 public OptionDialogue(String option1, Runnable action1, String option2, Runnable action2, String option3, Runnable action3, String option4, Runnable action4, String option5, Runnable action5) {
85 lines = new String[]{option1, option2, option3, option4, option5};
86 actions.add(action1);
87 actions.add(action2);
88 actions.add(action3);
89 actions.add(action4);
90 actions.add(action5);
91 }
92
93 @Override
94 public void accept(DialogueFactory factory) {
95 factory.sendOption(this);
96 }
97
98 /**
99 * Gets the text for this dialogue.
100 *
101 * @return The text.
102 */
103 public String[] getLines() {
104 return lines;
105 }
106
107 /**
108 * Gets the list of actions for this dialogue.
109 *
110 * @return The list of actions.
111 */
112 public List<Runnable> getActions() {
113 return actions;
114 }
115}
Represents a factory class that contains important functions for building dialogues.
final DialogueFactory sendOption(String option1, Runnable action1, String option2, Runnable action2)
Appends the OptionDialogue onto the current dialogue chain.
List< Runnable > getActions()
Gets the list of actions for this dialogue.
OptionDialogue(String option1, Runnable action1, String option2, Runnable action2, String option3, Runnable action3)
Creates a new OptionDialogue.
final List< Runnable > actions
The list of actions for this dialogue.
OptionDialogue(String option1, Runnable action1, String option2, Runnable action2, String option3, Runnable action3, String option4, Runnable action4, String option5, Runnable action5)
Creates a new OptionDialogue.
OptionDialogue(String option1, Runnable action1, String option2, Runnable action2)
Creates a new OptionDialogue.
final String[] lines
The text for this dialogue.
String[] getLines()
Gets the text for this dialogue.
OptionDialogue(String option1, Runnable action1, String option2, Runnable action2, String option3, Runnable action3, String option4, Runnable action4)
Creates a new OptionDialogue.
The chain-able itemcontainer that allows implementing dialogue factories the ability to chain togethe...