diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/esieequest/model/Game.java | 4 | ||||
-rw-r--r-- | src/esieequest/model/Player.java | 11 | ||||
-rw-r--r-- | src/esieequest/model/Text.java | 3 | ||||
-rw-r--r-- | src/esieequest/model/events/Quest.java | 31 | ||||
-rw-r--r-- | src/esieequest/view/Viewable.java | 20 | ||||
-rw-r--r-- | src/esieequest/view/app/UserInterface.java | 66 | ||||
-rw-r--r-- | src/esieequest/view/text/TextInterface.java | 9 | ||||
-rw-r--r-- | src/esieequest/view/web/WebInterface.java | 10 |
8 files changed, 87 insertions, 67 deletions
diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index 9b572e7..94f0a59 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java | |||
@@ -14,6 +14,7 @@ import esieequest.model.doors.HiddenDoor; | |||
14 | import esieequest.model.doors.LockedDoor; | 14 | import esieequest.model.doors.LockedDoor; |
15 | import esieequest.model.doors.TransporterDoor; | 15 | import esieequest.model.doors.TransporterDoor; |
16 | import esieequest.model.doors.TrapDoor; | 16 | import esieequest.model.doors.TrapDoor; |
17 | import esieequest.model.events.Quest; | ||
17 | import esieequest.model.items.Item; | 18 | import esieequest.model.items.Item; |
18 | import esieequest.model.map.Direction; | 19 | import esieequest.model.map.Direction; |
19 | import esieequest.model.map.Room; | 20 | import esieequest.model.map.Room; |
@@ -30,6 +31,7 @@ public class Game implements SerialisableObject { | |||
30 | public static final int CHALLENGE_STEPS_LIMIT = 50; | 31 | public static final int CHALLENGE_STEPS_LIMIT = 50; |
31 | public static final Direction DEFAULT_DIRECTION = Direction.NORTH; | 32 | public static final Direction DEFAULT_DIRECTION = Direction.NORTH; |
32 | public static final Room DEFAULT_ROOM = Room.AMPHITHEATER_SEAT; | 33 | public static final Room DEFAULT_ROOM = Room.AMPHITHEATER_SEAT; |
34 | public static final Quest DEFAULT_QUEST = Quest.WHAT_HAPPENED; | ||
33 | 35 | ||
34 | private static final String CHALLENGE_LABEL = "L"; | 36 | private static final String CHALLENGE_LABEL = "L"; |
35 | private final boolean challenge; | 37 | private final boolean challenge; |
@@ -67,7 +69,7 @@ public class Game implements SerialisableObject { | |||
67 | Room.createAllSides(); | 69 | Room.createAllSides(); |
68 | this.connectRooms(); | 70 | this.connectRooms(); |
69 | 71 | ||
70 | this.setPlayer(new Player(Game.DEFAULT_ROOM, Game.DEFAULT_DIRECTION, Game.DEFAULT_INVENTORY_LIMIT, challengeMode ? Game.CHALLENGE_STEPS_LIMIT : Game.DEFAULT_STEPS_LIMIT)); | 72 | this.setPlayer(new Player(Game.DEFAULT_QUEST, Game.DEFAULT_ROOM, Game.DEFAULT_DIRECTION, Game.DEFAULT_INVENTORY_LIMIT, challengeMode ? Game.CHALLENGE_STEPS_LIMIT : Game.DEFAULT_STEPS_LIMIT)); |
71 | 73 | ||
72 | if (populate) { | 74 | if (populate) { |
73 | this.addItems(); | 75 | this.addItems(); |
diff --git a/src/esieequest/model/Player.java b/src/esieequest/model/Player.java index a0066dc..ea8af35 100644 --- a/src/esieequest/model/Player.java +++ b/src/esieequest/model/Player.java | |||
@@ -11,6 +11,7 @@ import org.json.simple.JSONObject; | |||
11 | 11 | ||
12 | import esieequest.controller.utils.EnumUtils; | 12 | import esieequest.controller.utils.EnumUtils; |
13 | import esieequest.controller.utils.SerialisableObject; | 13 | import esieequest.controller.utils.SerialisableObject; |
14 | import esieequest.model.events.Quest; | ||
14 | import esieequest.model.items.Inventory; | 15 | import esieequest.model.items.Inventory; |
15 | import esieequest.model.map.Direction; | 16 | import esieequest.model.map.Direction; |
16 | import esieequest.model.map.Room; | 17 | import esieequest.model.map.Room; |
@@ -24,6 +25,11 @@ import esieequest.model.map.Side; | |||
24 | */ | 25 | */ |
25 | public class Player implements SerialisableObject { | 26 | public class Player implements SerialisableObject { |
26 | 27 | ||
28 | private static final String CURRENT_QUEST_LABEL = "Q"; | ||
29 | @Getter | ||
30 | @Setter | ||
31 | private Quest currentQuest; | ||
32 | |||
27 | private static final String CURRENT_ROOM_LABEL = "R"; | 33 | private static final String CURRENT_ROOM_LABEL = "R"; |
28 | @Getter | 34 | @Getter |
29 | @Setter | 35 | @Setter |
@@ -64,7 +70,8 @@ public class Player implements SerialisableObject { | |||
64 | * @param nbStepsLimit | 70 | * @param nbStepsLimit |
65 | * the maximum number of steps | 71 | * the maximum number of steps |
66 | */ | 72 | */ |
67 | public Player(final Room currentRoom, final Direction currentDirection, final int carryWeightLimit, final int nbStepsLimit) { | 73 | public Player(final Quest currentQuest, final Room currentRoom, final Direction currentDirection, final int carryWeightLimit, final int nbStepsLimit) { |
74 | this.currentQuest = currentQuest; | ||
68 | this.currentRoom = currentRoom; | 75 | this.currentRoom = currentRoom; |
69 | this.previousRooms = new Stack<>(); | 76 | this.previousRooms = new Stack<>(); |
70 | this.currentDirection = currentDirection; | 77 | this.currentDirection = currentDirection; |
@@ -122,6 +129,7 @@ public class Player implements SerialisableObject { | |||
122 | public JSONObject serialise() { | 129 | public JSONObject serialise() { |
123 | final CleanJSONObject o = new CleanJSONObject(); | 130 | final CleanJSONObject o = new CleanJSONObject(); |
124 | 131 | ||
132 | o.put(Player.CURRENT_QUEST_LABEL, this.currentQuest.name()); | ||
125 | o.put(Player.CURRENT_ROOM_LABEL, this.currentRoom.name()); | 133 | o.put(Player.CURRENT_ROOM_LABEL, this.currentRoom.name()); |
126 | o.put(Player.PREVIOUS_ROOMS_LABEL, EnumUtils.nameAll(this.previousRooms.toArray(new Room[0]))); | 134 | o.put(Player.PREVIOUS_ROOMS_LABEL, EnumUtils.nameAll(this.previousRooms.toArray(new Room[0]))); |
127 | 135 | ||
@@ -139,6 +147,7 @@ public class Player implements SerialisableObject { | |||
139 | @Override | 147 | @Override |
140 | public void deserialise(final JSONObject o) { | 148 | public void deserialise(final JSONObject o) { |
141 | 149 | ||
150 | this.currentQuest = Quest.valueOf((String) o.get(Player.CURRENT_QUEST_LABEL)); | ||
142 | this.currentRoom = Room.valueOf((String) o.get(Player.CURRENT_ROOM_LABEL)); | 151 | this.currentRoom = Room.valueOf((String) o.get(Player.CURRENT_ROOM_LABEL)); |
143 | 152 | ||
144 | this.previousRooms.clear(); | 153 | this.previousRooms.clear(); |
diff --git a/src/esieequest/model/Text.java b/src/esieequest/model/Text.java index 84253b3..a72ff4a 100644 --- a/src/esieequest/model/Text.java +++ b/src/esieequest/model/Text.java | |||
@@ -25,6 +25,8 @@ public enum Text { | |||
25 | BEAMER_ROOM_MEMORISED("The coordinates of the current location have been memorised: "), | 25 | BEAMER_ROOM_MEMORISED("The coordinates of the current location have been memorised: "), |
26 | BEAMER_TELEPORTED("Zap! You have reached your destination. The device's memory has been cleared."), | 26 | BEAMER_TELEPORTED("Zap! You have reached your destination. The device's memory has been cleared."), |
27 | 27 | ||
28 | CURRENT_QUEST_PREFIX("Current quest: "), | ||
29 | |||
28 | // objects | 30 | // objects |
29 | NOTE_PREFIX("It is written: "), | 31 | NOTE_PREFIX("It is written: "), |
30 | NOTE_ATHANASE("In case of logical trouble: find Athanase, office #3254."), | 32 | NOTE_ATHANASE("In case of logical trouble: find Athanase, office #3254."), |
@@ -59,6 +61,7 @@ public enum Text { | |||
59 | 61 | ||
60 | // formatting | 62 | // formatting |
61 | LIST_SEPARATOR(", "), | 63 | LIST_SEPARATOR(", "), |
64 | FILENAME_SEPARATOR("_"), | ||
62 | NEW_LINE("\n"), | 65 | NEW_LINE("\n"), |
63 | SPACE(" "), | 66 | SPACE(" "), |
64 | 67 | ||
diff --git a/src/esieequest/model/events/Quest.java b/src/esieequest/model/events/Quest.java index 30c4aa0..54cbb4a 100644 --- a/src/esieequest/model/events/Quest.java +++ b/src/esieequest/model/events/Quest.java | |||
@@ -1,26 +1,31 @@ | |||
1 | package esieequest.model.events; | 1 | package esieequest.model.events; |
2 | 2 | ||
3 | import lombok.Getter; | ||
4 | |||
3 | /** | 5 | /** |
4 | * A quest that can be completed in the game. | 6 | * A quest that can be completed in the game. |
5 | * | 7 | * |
6 | * @author Pacien TRAN-GIRARD | 8 | * @author Pacien TRAN-GIRARD |
7 | */ | 9 | */ |
8 | public class Quest { | 10 | public enum Quest { |
9 | 11 | ||
10 | private String title; | 12 | // @formatter:off |
13 | |||
14 | WHAT_HAPPENED("What happened?!?!"), | ||
15 | FIND_ATHANASE("Find Athanase"), | ||
16 | FEED_ATHAnASE("Feed Athanase"), | ||
17 | FIND_DISK("Find the Disk"), | ||
18 | FIND_TRANSPONDER("Find the Transponder"), | ||
19 | ACTIVATE_TRANSPONDER("Activate the Transponder"), | ||
20 | |||
21 | ; | ||
22 | |||
23 | // @formatter:on | ||
11 | 24 | ||
12 | /** | 25 | @Getter |
13 | * @return the title | 26 | private String title; |
14 | */ | ||
15 | public String getTitle() { | ||
16 | return this.title; | ||
17 | } | ||
18 | 27 | ||
19 | /** | 28 | Quest(final String title) { |
20 | * @param title | ||
21 | * the title to set | ||
22 | */ | ||
23 | public void setTitle(final String title) { | ||
24 | this.title = title; | 29 | this.title = title; |
25 | } | 30 | } |
26 | 31 | ||
diff --git a/src/esieequest/view/Viewable.java b/src/esieequest/view/Viewable.java index 0b23b8c..d4da79b 100644 --- a/src/esieequest/view/Viewable.java +++ b/src/esieequest/view/Viewable.java | |||
@@ -33,6 +33,11 @@ public interface Viewable { | |||
33 | public void enable(); | 33 | public void enable(); |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Disables the user interface. | ||
37 | */ | ||
38 | public void disable(); | ||
39 | |||
40 | /** | ||
36 | * Displays a message. | 41 | * Displays a message. |
37 | * | 42 | * |
38 | * @param message | 43 | * @param message |
@@ -41,9 +46,12 @@ public interface Viewable { | |||
41 | public void echo(final String message); | 46 | public void echo(final String message); |
42 | 47 | ||
43 | /** | 48 | /** |
44 | * Disables the user interface. | 49 | * Updates the view to match the current quest. |
50 | * | ||
51 | * @param quest | ||
52 | * the current quest to display | ||
45 | */ | 53 | */ |
46 | public void disable(); | 54 | public void updateQuest(final Quest quest); |
47 | 55 | ||
48 | /** | 56 | /** |
49 | * Updates the view to match the current location. | 57 | * Updates the view to match the current location. |
@@ -58,14 +66,6 @@ public interface Viewable { | |||
58 | public void updateLocation(final Room room, final Direction direction, final Side side); | 66 | public void updateLocation(final Room room, final Direction direction, final Side side); |
59 | 67 | ||
60 | /** | 68 | /** |
61 | * Updates the view to match the current quest. | ||
62 | * | ||
63 | * @param quest | ||
64 | * the current quest to display | ||
65 | */ | ||
66 | public void updateQuest(final Quest quest); | ||
67 | |||
68 | /** | ||
69 | * Updates the view to display the items contained in the inventory | 69 | * Updates the view to display the items contained in the inventory |
70 | * | 70 | * |
71 | * @param items | 71 | * @param items |