Fix: Tui adapted to new input case

This commit is contained in:
rubenpirreram
2026-05-01 17:40:36 +02:00
parent 50a3012cf1
commit 44388ee1e4
9 changed files with 56 additions and 58 deletions
@@ -2,6 +2,8 @@ package it.polimi.ingsw.gc14.View.TUI;
import it.polimi.ingsw.gc14.Model.Game;
import it.polimi.ingsw.gc14.View.IView;
import java.util.List;
public class TUI implements IView {
// ── dati di stato ───────────────────────────────────────────
@@ -23,6 +25,10 @@ public class TUI implements IView {
// ── punto di ingresso ───────────────────────────────────────
public void render()
{
renderBoard();
}
public void fullRender()
{
try{
String os = System.getProperty("os.name").toLowerCase();
@@ -36,7 +42,10 @@ public class TUI implements IView {
}
catch(Exception e){
}
System.out.println(model.toString());
List<String>lines=List.of(model.BoardStamp().split("\n"));
List<String> lines2=List.of((PrintMenuOptions()+"\n"+model.getPlayerByUsername(username)).split("\n"));
System.out.println(model.PlayersStamp()+"\n"+ AsciiTable.sideBySide(lines,lines2,3));
}
public void renderBoard()
@@ -53,7 +62,9 @@ public class TUI implements IView {
}
catch(Exception e){
}
System.out.println(model.BoardStamp());
List<String>lines=List.of(model.BoardStamp().split("\n"));
List<String> lines2=List.of((PrintMenuOptions()+"\nYOUR HAND\n"+model.getPlayerByUsername(username)).split("\n"));
System.out.println(AsciiTable.sideBySide(lines,lines2,3));
}
public void renderPlayer()
{
@@ -69,25 +80,10 @@ public class TUI implements IView {
}
catch(Exception e){
}
System.out.println(model.BoardStamp());
List<String>lines=List.of(model.PlayersStamp().split("\n"));
List<String> lines2=List.of(PrintMenuOptions().split("\n"));
System.out.println(AsciiTable.sideBySide(lines,lines2,3));
}
public void renderMyHand()
{
try{
String os = System.getProperty("os.name").toLowerCase();
ProcessBuilder pb;
if (os.contains("win")) {
pb = new ProcessBuilder("cmd", "/c", "cls");
} else {
pb = new ProcessBuilder("clear");
}
pb.inheritIO().start().waitFor();
}
catch(Exception e){
}
System.out.println(model.getPlayerByUsername(username));
}
public void showMessage(String message)
{
@@ -100,4 +96,19 @@ public class TUI implements IView {
System.out.println(message);
}
private String PrintMenuOptions()
{
var table=new AsciiTable(BorderStyle.ROUNDED,2);
table.addHeader( "Menu Options","Render Options");
table.addRow( List.of("1-SlotChoice(pos)","A-Full Render"));
table.addRow(List.of("2-DrawUpperTribe(pos)","B-Board Render"));
table.addRow(List.of("3-DrawUpperBuilding(pos)","C-Players Render"));
table.addRow(List.of("4-DrawLowerTribe(pos)",""));
table.addRow(List.of("5-DrawLowerBuilding(pos)",""));
table.addRow(List.of("6-PickOptionalTribe(pos)",""));
table.addRow(List.of("7-PickOptionalBuilding(pos)",""));
table.addRow(List.of("8-NoOptional",""));
return table.build();
}
}