Added: Game To String
This commit is contained in:
@@ -707,10 +707,11 @@ public class Game implements Serializable {
|
||||
public String toString() {
|
||||
var table = new AsciiTable(BorderStyle.UNICODE, slotMap.size());
|
||||
List<String> stringUp=new ArrayList<>();
|
||||
List<String> stringEmpty=new ArrayList<>();
|
||||
List<String> stringDown=new ArrayList<>();
|
||||
for(Map.Entry<Slot,Player> entry:slotMap.entrySet())
|
||||
{
|
||||
|
||||
stringEmpty.add(" ");
|
||||
stringDown.add(entry.getKey().toStringTUI());
|
||||
if(entry.getValue()!=null)
|
||||
stringUp.add(entry.getValue().getUserName());
|
||||
@@ -718,7 +719,23 @@ public class Game implements Serializable {
|
||||
stringUp.add(" ");
|
||||
}
|
||||
table.addRow(stringUp);
|
||||
table.addRow(stringEmpty);
|
||||
table.addRow(stringDown);
|
||||
return orderLogicCard.toString()+"\nOFFER TRACK\n"+ table.build();
|
||||
StringBuilder s=new StringBuilder();
|
||||
List<String>tempLines=new ArrayList<>();
|
||||
List<List<String>> playersString=new ArrayList<>();
|
||||
for(Player p:playersList)
|
||||
{
|
||||
tempLines=List.of(p.toString().split("\n"));
|
||||
playersString.add(tempLines);
|
||||
}
|
||||
|
||||
|
||||
List<String>lines=List.of(orderLogicCard.toString().split("\n"));
|
||||
List<String> lines2=new ArrayList<>();
|
||||
lines2.add("OFFER TRACK");
|
||||
lines2.addAll(List.of(table.build().split("\n")));
|
||||
return AsciiTable.sideBySide(lines,lines2,1)+AsciiTable.sideBySide(playersString.get(0),playersString.get(1),1);
|
||||
//return s.toString()+"\n"++"\nOFFER TRACK\n"+ table.build()+"\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class GameTest {
|
||||
assertTrue(game.SlotChoiceByIndex(game.getCurrentState().getCurrentPlayer(), i));
|
||||
}
|
||||
Player temp_player;
|
||||
|
||||
System.out.println(game);
|
||||
temp_player=players.poll();
|
||||
assertEquals(temp_player,game.getCurrentState().getCurrentPlayer());
|
||||
|
||||
@@ -156,6 +156,7 @@ class GameTest {
|
||||
index=cards.indexOf(cards.stream().filter(x->!x.IsEventCard()).findFirst().get());
|
||||
assertFalse(game.DrawUpperTribeCardByIndex(temp_player,index));
|
||||
|
||||
System.out.println(game);
|
||||
|
||||
}
|
||||
private void drawTribeTest(HashMap<CharacterType,Integer>nCardsByType,int nCards,int countCards,TribeCard temp_card,Player temp_player,Game game) {
|
||||
@@ -201,24 +202,20 @@ class GameTest {
|
||||
@Test
|
||||
void toStringModel()
|
||||
{
|
||||
Game game=new Game(5);
|
||||
Game game=new Game(3);
|
||||
Player p1=new Player("p1");
|
||||
Player p2=new Player("p2");
|
||||
Player p3=new Player("p3");
|
||||
Player p4=new Player("p4");
|
||||
Player p5=new Player("p5");
|
||||
|
||||
assertTrue(game.addPlayer(p1));
|
||||
assertTrue(game.addPlayer(p2));
|
||||
assertTrue(game.addPlayer(p3));
|
||||
assertTrue(game.addPlayer(p4));
|
||||
assertTrue(game.addPlayer(p5));
|
||||
|
||||
Queue<Player>players=new LinkedList<>();
|
||||
for(int i=0;i<5;i++) {
|
||||
for(int i=0;i<3;i++) {
|
||||
players.add( game.getCurrentState().getCurrentPlayer());
|
||||
assertTrue(game.SlotChoiceByIndex(game.getCurrentState().getCurrentPlayer(), i));
|
||||
}
|
||||
System.out.println(game);
|
||||
//System.out.println(game);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user