diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/esieequest/engine/GameEngine.java | 8 | ||||
-rw-r--r-- | src/esieequest/engine/commands/NewCommand.java | 6 | ||||
-rw-r--r-- | src/esieequest/game/characters/Sumobot.java | 8 | ||||
-rw-r--r-- | src/esieequest/game/items/Disk.java | 9 | ||||
-rw-r--r-- | src/esieequest/game/states/Callback.java (renamed from src/esieequest/engine/Callback.java) | 2 | ||||
-rw-r--r-- | src/esieequest/game/states/Scene.java | 12 | ||||
-rw-r--r-- | src/esieequest/ui/Viewable.java | 5 | ||||
-rw-r--r-- | src/esieequest/ui/rich/UserInterface.java | 9 | ||||
-rw-r--r-- | src/esieequest/ui/text/TextInterface.java | 5 | ||||
-rw-r--r-- | src/esieequest/ui/web/WebInterface.java | 19 |
10 files changed, 46 insertions, 37 deletions
diff --git a/src/esieequest/engine/GameEngine.java b/src/esieequest/engine/GameEngine.java index 8c1ac95..573d3a8 100644 --- a/src/esieequest/engine/GameEngine.java +++ b/src/esieequest/engine/GameEngine.java | |||
@@ -7,6 +7,7 @@ import esieequest.game.characters.MovingCharacter; | |||
7 | import esieequest.game.items.Beamer; | 7 | import esieequest.game.items.Beamer; |
8 | import esieequest.game.items.Item; | 8 | import esieequest.game.items.Item; |
9 | import esieequest.game.map.Room; | 9 | import esieequest.game.map.Room; |
10 | import esieequest.game.states.Callback; | ||
10 | import esieequest.game.states.Scene; | 11 | import esieequest.game.states.Scene; |
11 | import esieequest.ui.Viewable; | 12 | import esieequest.ui.Viewable; |
12 | 13 | ||
@@ -104,7 +105,12 @@ public class GameEngine { | |||
104 | final boolean trapped = inDeadEnd && !canGoBack && !canTeleport; | 105 | final boolean trapped = inDeadEnd && !canGoBack && !canTeleport; |
105 | 106 | ||
106 | if (trapped) { | 107 | if (trapped) { |
107 | this.view.playScene(Scene.GAME_LOST); | 108 | this.view.playScene(Scene.GAME_LOST, new Callback() { |
109 | @Override | ||
110 | public void call() { | ||
111 | return; | ||
112 | } | ||
113 | }); | ||
108 | this.view.echo("You are trapped. You losed."); | 114 | this.view.echo("You are trapped. You losed."); |
109 | } | 115 | } |
110 | 116 | ||
diff --git a/src/esieequest/engine/commands/NewCommand.java b/src/esieequest/engine/commands/NewCommand.java index 49c0225..dea279a 100644 --- a/src/esieequest/engine/commands/NewCommand.java +++ b/src/esieequest/engine/commands/NewCommand.java | |||
@@ -1,8 +1,8 @@ | |||
1 | package esieequest.engine.commands; | 1 | package esieequest.engine.commands; |
2 | 2 | ||
3 | import esieequest.engine.Callback; | ||
4 | import esieequest.game.Game; | 3 | import esieequest.game.Game; |
5 | import esieequest.game.Text; | 4 | import esieequest.game.Text; |
5 | import esieequest.game.states.Callback; | ||
6 | import esieequest.game.states.Scene; | 6 | import esieequest.game.states.Scene; |
7 | import esieequest.ui.Viewable; | 7 | import esieequest.ui.Viewable; |
8 | 8 | ||
@@ -22,7 +22,7 @@ public class NewCommand implements Executable { | |||
22 | 22 | ||
23 | view.echo(Text.WELCOME.toString()); | 23 | view.echo(Text.WELCOME.toString()); |
24 | 24 | ||
25 | Scene.INTRO.setCallback(new Callback() { | 25 | view.playScene(Scene.INTRO, new Callback() { |
26 | @Override | 26 | @Override |
27 | public void call() { | 27 | public void call() { |
28 | view.updateQuest(game.getPlayer().getCurrentQuest()); | 28 | view.updateQuest(game.getPlayer().getCurrentQuest()); |
@@ -35,7 +35,5 @@ public class NewCommand implements Executable { | |||
35 | } | 35 | } |
36 | }); | 36 | }); |
37 | 37 | ||
38 | view.playScene(Scene.INTRO); | ||
39 | |||
40 | } | 38 | } |
41 | } | 39 | } |
diff --git a/src/esieequest/game/characters/Sumobot.java b/src/esieequest/game/characters/Sumobot.java index f650c32..5f38e67 100644 --- a/src/esieequest/game/characters/Sumobot.java +++ b/src/esieequest/game/characters/Sumobot.java | |||
@@ -6,6 +6,7 @@ import esieequest.game.Game; | |||
6 | import esieequest.game.Text; | 6 | import esieequest.game.Text; |
7 | import esieequest.game.map.Direction; | 7 | import esieequest.game.map.Direction; |
8 | import esieequest.game.map.Room; | 8 | import esieequest.game.map.Room; |
9 | import esieequest.game.states.Callback; | ||
9 | import esieequest.game.states.Scene; | 10 | import esieequest.game.states.Scene; |
10 | import esieequest.ui.Viewable; | 11 | import esieequest.ui.Viewable; |
11 | 12 | ||
@@ -50,7 +51,12 @@ public class Sumobot extends FollowingCharacter { | |||
50 | return; | 51 | return; |
51 | } | 52 | } |
52 | 53 | ||
53 | view.playScene(Scene.GAME_LOST); | 54 | view.playScene(Scene.GAME_LOST, new Callback() { |
55 | @Override | ||
56 | public void call() { | ||
57 | return; | ||
58 | } | ||
59 | }); | ||
54 | view.echo(this.getRandomMessage() + Text.NEW_LINE + Sumobot.KILLED_MESSAGE); | 60 | view.echo(this.getRandomMessage() + Text.NEW_LINE + Sumobot.KILLED_MESSAGE); |
55 | 61 | ||
56 | } | 62 | } |
diff --git a/src/esieequest/game/items/Disk.java b/src/esieequest/game/items/Disk.java index f558956..096aa48 100644 --- a/src/esieequest/game/items/Disk.java +++ b/src/esieequest/game/items/Disk.java | |||
@@ -1,9 +1,9 @@ | |||
1 | package esieequest.game.items; | 1 | package esieequest.game.items; |
2 | 2 | ||
3 | import esieequest.engine.Callback; | ||
4 | import esieequest.game.Game; | 3 | import esieequest.game.Game; |
5 | import esieequest.game.map.Direction; | 4 | import esieequest.game.map.Direction; |
6 | import esieequest.game.map.Room; | 5 | import esieequest.game.map.Room; |
6 | import esieequest.game.states.Callback; | ||
7 | import esieequest.game.states.Scene; | 7 | import esieequest.game.states.Scene; |
8 | import esieequest.ui.Viewable; | 8 | import esieequest.ui.Viewable; |
9 | 9 | ||
@@ -33,20 +33,17 @@ public class Disk extends SimpleItem { | |||
33 | 33 | ||
34 | view.disableInput(); | 34 | view.disableInput(); |
35 | 35 | ||
36 | Scene.RUN_CONSOLE.setCallback(new Callback() { | 36 | view.playScene(Scene.RUN_CONSOLE, new Callback() { |
37 | @Override | 37 | @Override |
38 | public void call() { | 38 | public void call() { |
39 | Scene.END.setCallback(new Callback() { | 39 | view.playScene(Scene.END, new Callback() { |
40 | @Override | 40 | @Override |
41 | public void call() { | 41 | public void call() { |
42 | view.echo("Congratulations. The simple fact that you are standing here reading this sentence means you made a glorious contribution to science!"); | 42 | view.echo("Congratulations. The simple fact that you are standing here reading this sentence means you made a glorious contribution to science!"); |
43 | } | 43 | } |
44 | }); | 44 | }); |
45 | view.playScene(Scene.END); | ||
46 | } | 45 | } |
47 | }); | 46 | }); |
48 | |||
49 | view.playScene(Scene.RUN_CONSOLE); | ||
50 | } else { | 47 | } else { |
51 | view.echo("Can't use this item here."); | 48 | view.echo("Can't use this item here."); |
52 | } | 49 | } |
diff --git a/src/esieequest/engine/Callback.java b/src/esieequest/game/states/Callback.java index 91d8451..1fc0ebb 100644 --- a/src/esieequest/engine/Callback.java +++ b/src/esieequest/game/states/Callback.java | |||
@@ -1,4 +1,4 @@ | |||
1 | package esieequest.engine; | 1 | package esieequest.game.states; |
2 | 2 | ||
3 | /** | 3 | /** |
4 | * The Callback interface. | 4 | * The Callback interface. |
diff --git a/src/esieequest/game/states/Scene.java b/src/esieequest/game/states/Scene.java index 46d6884..b802e5e 100644 --- a/src/esieequest/game/states/Scene.java +++ b/src/esieequest/game/states/Scene.java | |||
@@ -1,8 +1,6 @@ | |||
1 | package esieequest.game.states; | 1 | package esieequest.game.states; |
2 | 2 | ||
3 | import lombok.Getter; | 3 | import lombok.Getter; |
4 | import lombok.Setter; | ||
5 | import esieequest.engine.Callback; | ||
6 | 4 | ||
7 | /** | 5 | /** |
8 | * Represents an animated Scene that can be played. | 6 | * Represents an animated Scene that can be played. |
@@ -31,20 +29,10 @@ public enum Scene { | |||
31 | @Getter | 29 | @Getter |
32 | private final int duration; | 30 | private final int duration; |
33 | 31 | ||
34 | @Getter | ||
35 | @Setter | ||
36 | private Callback callback; | ||
37 | |||
38 | Scene(final String title, final String text, final int duration) { | 32 | Scene(final String title, final String text, final int duration) { |
39 | this.title = title; | 33 | this.title = title; |
40 | this.text = text; | 34 | this.text = text; |
41 | this.duration = duration; | 35 | this.duration = duration; |
42 | this.callback = new Callback() { | ||
43 | @Override | ||
44 | public void call() { | ||
45 | return; | ||
46 | } | ||
47 | }; | ||
48 | } | 36 | } |
49 | 37 | ||
50 | } | 38 | } |
diff --git a/src/esieequest/ui/Viewable.java b/src/esieequest/ui/Viewable.java index cc6e091..f45f1aa 100644 --- a/src/esieequest/ui/Viewable.java +++ b/src/esieequest/ui/Viewable.java | |||
@@ -5,6 +5,7 @@ import esieequest.game.items.Inventory; | |||
5 | import esieequest.game.map.Direction; | 5 | import esieequest.game.map.Direction; |
6 | import esieequest.game.map.Room; | 6 | import esieequest.game.map.Room; |
7 | import esieequest.game.map.Side; | 7 | import esieequest.game.map.Side; |
8 | import esieequest.game.states.Callback; | ||
8 | import esieequest.game.states.Quest; | 9 | import esieequest.game.states.Quest; |
9 | import esieequest.game.states.Scene; | 10 | import esieequest.game.states.Scene; |
10 | 11 | ||
@@ -80,8 +81,10 @@ public interface Viewable { | |||
80 | * | 81 | * |
81 | * @param scene | 82 | * @param scene |
82 | * the Scene to play | 83 | * the Scene to play |
84 | * @param callback | ||
85 | * the Callback to call once the scene finished playing | ||
83 | */ | 86 | */ |
84 | public void playScene(final Scene scene); | 87 | public void playScene(final Scene scene, final Callback callback); |