From 60c9f6cd188d8623922dab4913fedf84bc699b5d Mon Sep 17 00:00:00 2001 From: LapisBerry Date: Wed, 22 May 2024 18:41:56 +0700 Subject: [PATCH] feat: start implementing controller --- src/main/java/com/lapisberry/Main.java | 1 - .../com/lapisberry/game/controllers/GameController.java | 6 ++++++ .../com/lapisberry/game/controllers/LobbyController.java | 6 ++++++ src/main/java/com/lapisberry/gui/scenes/JoinScene.java | 1 + src/main/java/com/lapisberry/net/Client.java | 6 ++++++ src/main/java/com/lapisberry/net/Server.java | 6 ++++++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/lapisberry/game/controllers/GameController.java create mode 100644 src/main/java/com/lapisberry/game/controllers/LobbyController.java diff --git a/src/main/java/com/lapisberry/Main.java b/src/main/java/com/lapisberry/Main.java index e765d23..e664e34 100644 --- a/src/main/java/com/lapisberry/Main.java +++ b/src/main/java/com/lapisberry/Main.java @@ -4,7 +4,6 @@ import com.lapisberry.gui.scenes.LobbyScene; import com.lapisberry.net.Client; import com.lapisberry.net.Server; -import com.lapisberry.utils.exceptions.ConnectionRefusedException; import javafx.application.Application; import javafx.scene.image.Image; import javafx.stage.Stage; diff --git a/src/main/java/com/lapisberry/game/controllers/GameController.java b/src/main/java/com/lapisberry/game/controllers/GameController.java new file mode 100644 index 0000000..e945202 --- /dev/null +++ b/src/main/java/com/lapisberry/game/controllers/GameController.java @@ -0,0 +1,6 @@ +package com.lapisberry.game.controllers; + +import java.io.Serializable; + +public class GameController implements Serializable { +} diff --git a/src/main/java/com/lapisberry/game/controllers/LobbyController.java b/src/main/java/com/lapisberry/game/controllers/LobbyController.java new file mode 100644 index 0000000..eaf45d9 --- /dev/null +++ b/src/main/java/com/lapisberry/game/controllers/LobbyController.java @@ -0,0 +1,6 @@ +package com.lapisberry.game.controllers; + +import java.io.Serializable; + +public class LobbyController implements Serializable { +} diff --git a/src/main/java/com/lapisberry/gui/scenes/JoinScene.java b/src/main/java/com/lapisberry/gui/scenes/JoinScene.java index 97569c5..78bd145 100644 --- a/src/main/java/com/lapisberry/gui/scenes/JoinScene.java +++ b/src/main/java/com/lapisberry/gui/scenes/JoinScene.java @@ -150,6 +150,7 @@ private CreateServerButton() { pressedBackground.set(redPressedBackground); } isServerCreated.set(!isServerCreated.get()); + setBackground(regularBackground.get()); }); } } diff --git a/src/main/java/com/lapisberry/net/Client.java b/src/main/java/com/lapisberry/net/Client.java index f2165d9..a415fbc 100644 --- a/src/main/java/com/lapisberry/net/Client.java +++ b/src/main/java/com/lapisberry/net/Client.java @@ -1,5 +1,7 @@ package com.lapisberry.net; +import com.lapisberry.game.controllers.GameController; +import com.lapisberry.game.controllers.LobbyController; import com.lapisberry.net.packets.ClientPacket; import com.lapisberry.net.packets.JoinRequestPacket; import com.lapisberry.net.packets.ServerPacket; @@ -16,6 +18,8 @@ public class Client implements Runnable { private final Socket socket; private final ObjectInputStream inputStream; private final ObjectOutputStream outputStream; + private final LobbyController clientLobby; + private final GameController clientGame; // Constructors public Client(final String host) { @@ -27,6 +31,8 @@ public Client(final String host) { System.out.println("Client cannot be created."); throw new ConnectionRefusedException("Connection refused."); } + clientLobby = new LobbyController(); + clientGame = new GameController(); } // Methods diff --git a/src/main/java/com/lapisberry/net/Server.java b/src/main/java/com/lapisberry/net/Server.java index f2ac69c..6323455 100644 --- a/src/main/java/com/lapisberry/net/Server.java +++ b/src/main/java/com/lapisberry/net/Server.java @@ -1,5 +1,7 @@ package com.lapisberry.net; +import com.lapisberry.game.controllers.GameController; +import com.lapisberry.game.controllers.LobbyController; import com.lapisberry.net.packets.ClientPacket; import com.lapisberry.net.packets.ServerPacket; import com.lapisberry.utils.Config; @@ -13,6 +15,8 @@ public class Server implements Runnable { // Fields private final ServerSocket serverSocket; private final ArrayList clientHandlers; + private final LobbyController serverLobby; + private final GameController serverGame; // Constructors public Server() { @@ -22,6 +26,8 @@ public Server() { throw new RuntimeException("Server cannot be created."); } clientHandlers = new ArrayList<>(); + serverLobby = new LobbyController(); + serverGame = new GameController(); } // Methods