Add: Slot toStringTUI
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user