|
@@ -0,0 +1,101 @@
|
|
|
|
|
+package eu.oschl.gui.actions;
|
|
|
|
|
+
|
|
|
|
|
+import eu.oschl.gui.Output;
|
|
|
|
|
+import eu.oschl.textadventure.Game;
|
|
|
|
|
+import eu.oschl.textadventure.map.Passage;
|
|
|
|
|
+import javafx.scene.paint.Color;
|
|
|
|
|
+
|
|
|
|
|
+public class Explore implements Action {
|
|
|
|
|
+ private final Game game;
|
|
|
|
|
+
|
|
|
|
|
+ public Explore(Game game) {
|
|
|
|
|
+ this.game = game;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getId() {
|
|
|
|
|
+ return "explore";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getDescription() {
|
|
|
|
|
+ return "find out information about the current area";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void execute(String[] args) {
|
|
|
|
|
+ var room = this.game.getCurrentRoom();
|
|
|
|
|
+ var objects = room.getObjects();
|
|
|
|
|
+ var passages = room.getPassages();
|
|
|
|
|
+
|
|
|
|
|
+ Output.print(room.getName(), Color.BLUEVIOLET);
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.print(room.getDescription(), Color.BLUE);
|
|
|
|
|
+
|
|
|
|
|
+ if (room.getEnemy().isPresent()) {
|
|
|
|
|
+ if (room.getEnemy().get().isAlive()) {
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+
|
|
|
|
|
+ Output.print(room.getEnemy().get().getName(), Color.ORANGERED);
|
|
|
|
|
+ Output.print(" blocks the way.", Color.RED);
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.print(room.getEnemy().get().getDescription(), Color.RED);
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.print(room.getEnemy().get().getName(), Color.RED);
|
|
|
|
|
+ Output.print(" must be defeated to continue further.");
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.print("The corpse of ");
|
|
|
|
|
+ Output.print(room.getEnemy().get().getName(), Color.ORANGERED);
|
|
|
|
|
+ Output.print(" lies on the ground.");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!objects.isEmpty()) {
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+
|
|
|
|
|
+ if (objects.size() == 1) {
|
|
|
|
|
+ Output.print("there is something in this room: ", Color.MAGENTA);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Output.print("there are " + objects.size() + " things in this room: ", Color.MAGENTA);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (var object : objects) {
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.print(" * " + object.getName(), Color.MAGENTA);
|
|
|
|
|
+ Output.print(", " + object.getDescription(), Color.WHITE);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!passages.isEmpty()) {
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+
|
|
|
|
|
+ if (passages.size() == 1) {
|
|
|
|
|
+ Output.print("there is a passage leading out of here: ", Color.YELLOW);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Output.print("there are " + passages.size() + " passages leading out of here: ", Color.YELLOW);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (Passage passage : passages) {
|
|
|
|
|
+ Output.printLine();
|
|
|
|
|
+ Output.print(" * " + passage.getName(), Color.YELLOW);
|
|
|
|
|
+
|
|
|
|
|
+ if (passage.getDescription().isPresent()) {
|
|
|
|
|
+ Output.print(", " + passage.getDescription().get(), Color.WHITE);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (passage.isSeeThrough() || passage.getOtherRoom(room).wasEntered()) {
|
|
|
|
|
+ Output.print(" - leading to ");
|
|
|
|
|
+ Output.print(passage.getOtherRoom(room).getName(), Color.BLUE);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Output.print(" - it's impossible to see what's on the other side", Color.RED);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|