Add: TUI javadoc
This commit is contained in:
@@ -6,33 +6,52 @@ import java.util.List;
|
||||
|
||||
public class TUI implements IView {
|
||||
|
||||
/**
|
||||
* The style of the table
|
||||
*/
|
||||
private BorderStyle style = BorderStyle.UNICODE;
|
||||
/**
|
||||
* The {@link it.polimi.ingsw.gc14.Model.Game } model stored for the game status render
|
||||
*/
|
||||
private Game model;
|
||||
|
||||
/**
|
||||
* The {@link it.polimi.ingsw.gc14.Model.Player } username stored for the player hand render
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* Constructor for the class {@code TUI}
|
||||
* @param model The model that will be display
|
||||
*/
|
||||
public TUI(Game model) {
|
||||
this.model = model;
|
||||
this.username="";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@code Username} of the player, used for the hand player display
|
||||
* @param username
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update {@link it.polimi.ingsw.gc14.Model.Game } model stored for the game status render
|
||||
*/
|
||||
@Override
|
||||
public void update(Game model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
// ── punto di ingresso ───────────────────────────────────────
|
||||
/**
|
||||
* Default method called to display homepage , implements {@link IView}
|
||||
*/
|
||||
public void render()
|
||||
{
|
||||
renderBoard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to display players status and board status
|
||||
*/
|
||||
public void fullRender()
|
||||
{
|
||||
try{
|
||||
@@ -53,6 +72,9 @@ public class TUI implements IView {
|
||||
System.out.println(model.PlayersStamp()+"\n"+ AsciiTable.sideBySide(lines,lines2,3));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to display board status
|
||||
*/
|
||||
public void renderBoard()
|
||||
{
|
||||
try{
|
||||
@@ -71,6 +93,9 @@ public class TUI implements IView {
|
||||
List<String> lines2=List.of((PrintMenuOptions()+"\nYOUR HAND\n"+model.getPlayerByUsername(username)).split("\n"));
|
||||
System.out.println(AsciiTable.sideBySide(lines,lines2,3));
|
||||
}
|
||||
/**
|
||||
* Method called to display player status
|
||||
*/
|
||||
public void renderPlayer()
|
||||
{
|
||||
try{
|
||||
@@ -90,17 +115,26 @@ public class TUI implements IView {
|
||||
System.out.println(AsciiTable.sideBySide(lines,lines2,3));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to display a message on the terminal
|
||||
*/
|
||||
public void showMessage(String message)
|
||||
{
|
||||
System.out.println(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method called to display a error on the terminal
|
||||
*/
|
||||
public void showError(String message)
|
||||
{
|
||||
System.out.println(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to set up menu options
|
||||
* @return the string format of the menu options
|
||||
*/
|
||||
private String PrintMenuOptions()
|
||||
{
|
||||
var table=new AsciiTable(BorderStyle.ROUNDED,2);
|
||||
|
||||
Reference in New Issue
Block a user