Ver código fonte

Final ? cleanup

Ondřej Schlaichert 8 meses atrás
pai
commit
b3992827c7

+ 2 - 1
README.md

@@ -14,4 +14,5 @@ The game tells a story of Schmorn, a weak, inept and power-hungry prince, who ge
 - All gameplay is handled by pressing appropriate buttons. Press buttons to explore, fight enemies, etc.
 - The inventory is also interactable: click on a collected item to use it.
 - Press **Ctrl+R** to restart the game at any time.
-- Press **F1** to show this help screens available, which lists all commands and their descriptions.
+- Press **F1** to show this help screens available, which lists all commands and their descriptions.
+- Run the game with the `--cli` argument to play in the command line interface.

+ 5 - 0
src/main/java/eu/oschl/gui/ActionProcessor.java

@@ -7,6 +7,11 @@ import eu.oschl.textadventure.Game;
 import java.util.ArrayList;
 import java.util.List;
 
+/**
+ * Processes and manages actions within the game.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class ActionProcessor extends Observable {
     private ArrayList<Action> actions;
 

+ 5 - 0
src/main/java/eu/oschl/gui/ButtonData.java

@@ -1,5 +1,10 @@
 package eu.oschl.gui;
 
+/**
+ * Data class representing a button action with its associated ID and arguments.
+ *
+ * @author Ondřej Schlaichert
+ */
 public record ButtonData(
         String actionId,
         String... arguments

+ 5 - 0
src/main/java/eu/oschl/gui/GameController.java

@@ -13,6 +13,11 @@ import javafx.scene.text.TextFlow;
 import java.util.ArrayList;
 import java.util.Objects;
 
+/**
+ * Controller class for managing the game UI and interactions.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class GameController implements Observer {
     @FXML
     private TextFlow output;

+ 5 - 0
src/main/java/eu/oschl/gui/Observable.java

@@ -3,6 +3,11 @@ package eu.oschl.gui;
 import java.util.HashSet;
 import java.util.Set;
 
+/**
+ * Observable class for implementing the Observer design pattern.
+ *
+ * @author Ondřej Schlaichert
+ */
 public abstract class Observable {
     protected Set<Observer> observers = new HashSet<>();
 

+ 5 - 0
src/main/java/eu/oschl/gui/Observer.java

@@ -1,5 +1,10 @@
 package eu.oschl.gui;
 
+/**
+ * Observer interface for implementing the Observer design pattern.
+ *
+ * @author Ondřej Schlaichert
+ */
 public interface Observer {
     void update();
 }

+ 5 - 0
src/main/java/eu/oschl/gui/Output.java

@@ -4,6 +4,11 @@ import javafx.scene.paint.Color;
 import javafx.scene.text.Text;
 import javafx.scene.text.TextFlow;
 
+/**
+ * Utility class for managing output display in the GUI and printing messages with colours.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class Output {
     private static TextFlow outputElement;
 

+ 5 - 0
src/main/java/eu/oschl/gui/Session.java

@@ -21,6 +21,11 @@ import java.io.InputStream;
 import java.util.Objects;
 import java.util.Optional;
 
+/**
+ * Main session class for managing the game state and launching the GUI.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class Session extends Application {
     private static Game game;
     private static ActionProcessor actionProcessor;

+ 1 - 1
src/main/java/eu/oschl/gui/actions/Action.java

@@ -1,7 +1,7 @@
 package eu.oschl.gui.actions;
 
 /***
- * This interface defines the structure for commands in the console application.
+ * This interface defines the structure for actions in the GUI application.
  *
  * @author Ondřej Schlaichert
  */

+ 6 - 0
src/main/java/eu/oschl/gui/actions/Enter.java

@@ -6,6 +6,11 @@ import eu.oschl.textadventure.exceptions.InvalidGameState;
 import eu.oschl.textadventure.map.Passage;
 import javafx.scene.paint.Color;
 
+/**
+ * Action for entering a passage to another room.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class Enter implements Action {
     private final Game game;
 
@@ -42,6 +47,7 @@ public class Enter implements Action {
             }
         }
 
+        assert passage != null;
         var printEnterText = !passage.getOtherRoom(game.getCurrentRoom()).wasEntered();
 
         var result = passage.passThrough(false);

+ 5 - 0
src/main/java/eu/oschl/gui/actions/Explore.java

@@ -5,6 +5,11 @@ import eu.oschl.textadventure.Game;
 import eu.oschl.textadventure.map.Passage;
 import javafx.scene.paint.Color;
 
+/**
+ * Action for exploring the current room and displaying its details.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class Explore implements Action {
     private final Game game;
 

+ 5 - 0
src/main/java/eu/oschl/gui/actions/PressButton.java

@@ -5,6 +5,11 @@ import eu.oschl.textadventure.Game;
 import eu.oschl.textadventure.objects.Button;
 import javafx.scene.paint.Color;
 
+/**
+ * Action for pressing a button in the current room.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class PressButton implements Action {
     private final Game game;
 

+ 5 - 0
src/main/java/eu/oschl/gui/actions/Quit.java

@@ -2,6 +2,11 @@ package eu.oschl.gui.actions;
 
 import javafx.application.Platform;
 
+/**
+ * This action quits the game application.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class Quit implements Action {
     @Override
     public String getId() {

+ 5 - 0
src/main/java/eu/oschl/gui/actions/Slay.java

@@ -4,6 +4,11 @@ import eu.oschl.gui.Output;
 import eu.oschl.textadventure.Game;
 import javafx.scene.paint.Color;
 
+/**
+ * Action for slaying an enemy in the current room.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class Slay implements Action {
     private final Game game;
 

+ 5 - 0
src/main/java/eu/oschl/gui/actions/TakeItem.java

@@ -6,6 +6,11 @@ import eu.oschl.textadventure.objects.PickableObject;
 import eu.oschl.textadventure.objects.Weapon;
 import javafx.scene.paint.Color;
 
+/**
+ * Action for taking an item from the current room.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class TakeItem implements Action {
     private final Game game;
 

+ 5 - 0
src/main/java/eu/oschl/gui/actions/UseItem.java

@@ -4,6 +4,11 @@ import eu.oschl.gui.Output;
 import eu.oschl.textadventure.Game;
 import javafx.scene.paint.Color;
 
+/**
+ * Action for taking an item from the current room.
+ *
+ * @author Ondřej Schlaichert
+ */
 public class UseItem implements Action {
     private final Game game;
 

+ 1 - 1
src/main/java/eu/oschl/schmorn/Main.java

@@ -1,7 +1,7 @@
 package eu.oschl.schmorn;
 
 /**
- * Serves as an entry point.
+ * Serves as an entry point, passes args to Launcher and starts the game.
  *
  * @author Ondřej Schlaichert
  */

+ 1 - 6
src/main/resources/eu/oschl/gui/game.fxml

@@ -2,7 +2,6 @@
 
 <?import javafx.geometry.Insets?>
 <?import javafx.scene.control.ScrollPane?>
-<?import javafx.scene.image.Image?>
 <?import javafx.scene.image.ImageView?>
 <?import javafx.scene.layout.ColumnConstraints?>
 <?import javafx.scene.layout.GridPane?>
@@ -12,13 +11,10 @@
 
 <?import javafx.scene.layout.StackPane?>
 <?import javafx.scene.shape.Rectangle?>
-<GridPane xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1"
-          fx:controller="eu.oschl.gui.GameController">
-
+<GridPane xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="eu.oschl.gui.GameController">
     <columnConstraints>
         <ColumnConstraints hgrow="ALWAYS"/>
     </columnConstraints>
-
     <rowConstraints>
         <RowConstraints minHeight="10.0" percentHeight="75.0" vgrow="ALWAYS"/>
         <RowConstraints minHeight="10.0" percentHeight="25.0" vgrow="ALWAYS"/>
@@ -56,7 +52,6 @@
                     <Rectangle width="${cell.width}" height="${cell.height}"/>
                 </clip>
                 <ImageView fx:id="mapContainer" preserveRatio="true" fitWidth="${cell.width}">
-                    <Image url="@images/map/royal_well.png"/>
                 </ImageView>
             </StackPane>
             <ScrollPane fitToWidth="true" fitToHeight="true" GridPane.rowIndex="1">

+ 1 - 3
src/main/resources/eu/oschl/gui/help.html

@@ -4,9 +4,6 @@
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Schmorn Help & Information</title>
-    <link rel="preconnect" href="https://fonts.googleapis.com">
-    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
-    <link href="https://fonts.googleapis.com/css2?family=Iosevka+Slab:wght@400;700&display=swap" rel="stylesheet">
     <style>
 		body {
 			font-family: 'Iosevka Slab', monospace;
@@ -80,6 +77,7 @@
     <li>The inventory is also interactable: click on a collected item to use it.</li>
     <li>Press <strong>Ctrl+R</strong> to restart the game at any time.</li>
     <li>Press <strong>F1</strong> to show this help screen.</li>
+    <li>Run the game with the <code>--cli</code> argument to play in the command line interface.</li>
 </ul>
 
 <hr>