Merge pull request #66 from rubenpirreram/Launcher

Launcher
This commit is contained in:
rubenpirreram
2026-05-02 17:07:19 +02:00
committed by GitHub
3 changed files with 11 additions and 4 deletions
@@ -85,10 +85,10 @@ public class ClientLauncherTUI {
} }
switch(action) { switch(action) {
case "0" -> controller.slotChoice(username, pos); case "0" -> controller.slotChoice(username, pos);
case "1" -> controller.drawUpperBuildingCard(username, pos); case "1" -> controller.drawUpperTribeCard(username, pos);
case "2" -> controller.drawUpperTribeCard(username, pos); case "2" -> controller.drawUpperBuildingCard(username, pos);
case "3" -> controller.drawLowerBuildingCard(username, pos); case "3" -> controller.drawLowerTribeCard(username, pos);
case "4" -> controller.drawLowerTribeCard(username, pos); case "4" -> controller.drawLowerBuildingCard(username, pos);
case "5" -> controller.pickOptionalTribeCard(username, pos); case "5" -> controller.pickOptionalTribeCard(username, pos);
case "6" -> controller.pickOptionalBuildingCard(username, pos); case "6" -> controller.pickOptionalBuildingCard(username, pos);
case "7" -> controller.noOptionalCard(username); case "7" -> controller.noOptionalCard(username);
@@ -90,6 +90,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
if (controller.addPlayer(username)) { if (controller.addPlayer(username)) {
clients.put(username, callback); clients.put(username, callback);
playerList.add(username); playerList.add(username);
System.out.println("Accepted player: " + username);
return true; return true;
} }
return false; return false;
@@ -7,6 +7,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.Network.NetworkEvents.AddPlayer; import it.polimi.ingsw.gc14.Network.NetworkEvents.AddPlayer;
import it.polimi.ingsw.gc14.Network.RMI.Server.RMIServer; import it.polimi.ingsw.gc14.Network.RMI.Server.RMIServer;
import it.polimi.ingsw.gc14.Network.TCP.Server.TCPServer; import it.polimi.ingsw.gc14.Network.TCP.Server.TCPServer;
import it.polimi.ingsw.gc14.View.TUI.TUI;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
@@ -56,6 +57,8 @@ public class ServerLauncher {
*/ */
static LimitedList<String> playerList; static LimitedList<String> playerList;
TUI view;
/** /**
* Class constructor that initializes the attributes. * Class constructor that initializes the attributes.
@@ -137,11 +140,14 @@ public class ServerLauncher {
System.out.println("\n\nNotifying model"); System.out.println("\n\nNotifying model");
serverRMI.notifyAll(gameController.getModel()); serverRMI.notifyAll(gameController.getModel());
serverTCP.notifyAll(gameController.getModel()); serverTCP.notifyAll(gameController.getModel());
this.view = new TUI(gameController.getModel());
this.view.fullRender();
// Game execution // Game execution
while (true) { while (true) {
try { try {
this.doFirstEvent(); this.doFirstEvent();
this.view.fullRender();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
break; break;