aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/esieequest/engine/GameEngine.java8
-rw-r--r--src/esieequest/engine/commands/NewCommand.java6
-rw-r--r--src/esieequest/game/characters/Sumobot.java8
-rw-r--r--src/esieequest/game/items/Disk.java9
-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.java12
-rw-r--r--src/esieequest/ui/Viewable.java5
-rw-r--r--src/esieequest/ui/rich/UserInterface.java9
-rw-r--r--src/esieequest/ui/text/TextInterface.java5
-rw-r--r--src/esieequest/ui/web/WebInterface.java19
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;
7import esieequest.game.items.Beamer; 7import esieequest.game.items.Beamer;
8import esieequest.game.items.Item; 8import esieequest.game.items.Item;
9import esieequest.game.map.Room; 9import esieequest.game.map.Room;
10import esieequest.game.states.Callback;
10import esieequest.game.states.Scene; 11import esieequest.game.states.Scene;
11import esieequest.ui.Viewable; 12import 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 @@
1package esieequest.engine.commands; 1package esieequest.engine.commands;
2 2
3import esieequest.engine.Callback;
4import esieequest.game.Game; 3import esieequest.game.Game;
5import esieequest.game.Text; 4import esieequest.game.Text;
5import esieequest.game.states.Callback;
6import esieequest.game.states.Scene; 6import esieequest.game.states.Scene;
7import esieequest.ui.Viewable; 7import 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;
6import esieequest.game.Text; 6import esieequest.game.Text;
7import esieequest.game.map.Direction; 7import esieequest.game.map.Direction;
8import esieequest.game.map.Room; 8import esieequest.game.map.Room;
9import esieequest.game.states.Callback;
9import esieequest.game.states.Scene; 10import esieequest.game.states.Scene;
10import esieequest.ui.Viewable; 11import 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 @@
1package esieequest.game.items; 1package esieequest.game.items;
2 2
3import esieequest.engine.Callback;
4import esieequest.game.Game; 3import esieequest.game.Game;
5import esieequest.game.map.Direction; 4import esieequest.game.map.Direction;
6import esieequest.game.map.Room; 5import esieequest.game.map.Room;
6import esieequest.game.states.Callback;
7import esieequest.game.states.Scene; 7import esieequest.game.states.Scene;
8import esieequest.ui.Viewable; 8import 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 @@
1package esieequest.engine; 1package 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 @@
1package esieequest.game.states; 1package esieequest.game.states;
2 2
3import lombok.Getter; 3import lombok.Getter;
4import lombok.Setter;
5import 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;
5import esieequest.game.map.Direction; 5import esieequest.game.map.Direction;
6import esieequest.game.map.Room; 6import esieequest.game.map.Room;
7import esieequest.game.map.Side; 7import esieequest.game.map.Side;
8import esieequest.game.states.Callback;
8import esieequest.game.states.Quest; 9import esieequest.game.states.Quest;
9import esieequest.game.states.Scene; 10import 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);