Add: Slot toStringTUI

This commit is contained in:
rubenpirreram
2026-04-26 17:51:52 +02:00
parent 7da3b1f0d9
commit 0acf76dcb9
4 changed files with 91 additions and 11 deletions
@@ -18,6 +18,9 @@ import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;
import it.polimi.ingsw.gc14.Network.Observer;
import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
/**
* Represents the main game model.
* A Game object stores the players, the current state of the match,
@@ -36,6 +39,15 @@ public class Game implements Serializable {
o.update(this);
}
}
/**
* Returns the list of players participating in the game.
* @return
*/
public List<Player> getPlayers() {
return playersList;
}
/**
* The current number of players.
*/
@@ -691,4 +703,22 @@ public class Game implements Serializable {
return true;
}
@Override
public String toString() {
var table = new AsciiTable(BorderStyle.UNICODE, slotMap.size());
List<String> stringUp=new ArrayList<>();
List<String> stringDown=new ArrayList<>();
for(Map.Entry<Slot,Player> entry:slotMap.entrySet())
{
stringDown.add(entry.getKey().toStringTUI());
if(entry.getValue()!=null)
stringUp.add(entry.getValue().getUserName());
else
stringUp.add(" ");
}
table.addRow(stringUp);
table.addRow(stringDown);
return orderLogicCard.toString()+"\nOFFER TRACK\n"+ table.build();
}
}