Add: ClientLauncherTUI. Connection and model sending works.

Note: ClientController.view is commented out since class TUI is still missing
This commit is contained in:
2026-04-29 17:14:45 +02:00
parent a699826137
commit 73b5b6eba5
10 changed files with 91 additions and 47 deletions
@@ -0,0 +1,54 @@
package it.polimi.ingsw.gc14;
import it.polimi.ingsw.gc14.Controller.ClientController;
import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
import it.polimi.ingsw.gc14.View.IView;
import java.util.Scanner;
public class ClientLauncherTUI {
public void main() throws InterruptedException {
ClientController controller = new ClientController();
Scanner scanner = new Scanner(System.in);
System.out.println("Selezionare nome utente: ");
String username = scanner.next();
System.out.println(username);
System.out.println("Selezionare numero di giocatori desiderato: ");
int proposedNumPlayers = scanner.nextInt();
System.out.println(proposedNumPlayers);
System.out.println("Selezionare RMI[0] o TCP[1]: ");
int networkType = scanner.nextInt();
System.out.println(networkType);
scanner.close();
if (networkType == 0) {
RMIClient client = new RMIClient("localhost", 1099);
if (client.connect(username, proposedNumPlayers, controller)) {
System.out.println("CLIENT CONNESSO DAJE");
} else {
System.out.println("NON CONNESSO D:");
}
while(true) {
System.out.flush();
if (controller.localModel!=null) {
System.out.println("MODEL SETTATO");
}
Thread.sleep(500);
}
} else if (networkType == 1) {
return;
}
}
}