Skip to content

Commit

Permalink
feat: start implementing controller
Browse files Browse the repository at this point in the history
  • Loading branch information
LapisBerry committed May 22, 2024
1 parent 03f0e4d commit 60c9f6c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/main/java/com/lapisberry/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.lapisberry.game.controllers;

import java.io.Serializable;

public class GameController implements Serializable {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.lapisberry.game.controllers;

import java.io.Serializable;

public class LobbyController implements Serializable {
}
1 change: 1 addition & 0 deletions src/main/java/com/lapisberry/gui/scenes/JoinScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ private CreateServerButton() {
pressedBackground.set(redPressedBackground);
}
isServerCreated.set(!isServerCreated.get());
setBackground(regularBackground.get());
});
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/lapisberry/net/Client.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/lapisberry/net/Server.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -13,6 +15,8 @@ public class Server implements Runnable {
// Fields
private final ServerSocket serverSocket;
private final ArrayList<ClientHandler> clientHandlers;
private final LobbyController serverLobby;
private final GameController serverGame;

// Constructors
public Server() {
Expand All @@ -22,6 +26,8 @@ public Server() {
throw new RuntimeException("Server cannot be created.");
}
clientHandlers = new ArrayList<>();
serverLobby = new LobbyController();
serverGame = new GameController();
}

// Methods
Expand Down

0 comments on commit 60c9f6c

Please sign in to comment.