Merge branch 'main' into tests-fix
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.
|
||||
*/
|
||||
@@ -746,4 +758,90 @@ 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> 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());
|
||||
else
|
||||
stringUp.add(" ");
|
||||
}
|
||||
table.addRow(stringUp);
|
||||
table.addRow(stringEmpty);
|
||||
table.addRow(stringDown);
|
||||
|
||||
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")));
|
||||
|
||||
String boardToString=AsciiTable.sideBySide(lines,lines2,1);
|
||||
|
||||
|
||||
|
||||
var table2 = new AsciiTable(BorderStyle.UNICODE, Math.max(getUpperListTribeCards().size(),getLowerListTribeCards().size()));
|
||||
List<String> stringUp2=new ArrayList<>();
|
||||
List<String> stringDown2=new ArrayList<>();
|
||||
for(int i=0;i<Math.max(getUpperListTribeCards().size(),getLowerListTribeCards().size());i++)
|
||||
{
|
||||
if(i<getUpperListTribeCards().size())
|
||||
{
|
||||
stringUp2.add(getUpperListTribeCards().get(i).toStringBoard());
|
||||
}
|
||||
else
|
||||
{
|
||||
stringUp2.add("");
|
||||
}
|
||||
if(i<getLowerListTribeCards().size())
|
||||
{
|
||||
stringDown2.add(getLowerListTribeCards().get(i).toStringBoard());
|
||||
}
|
||||
else
|
||||
{
|
||||
stringDown2.add("");
|
||||
}
|
||||
}
|
||||
table2.addRow(stringUp2);
|
||||
table2.addRow(stringDown2);
|
||||
|
||||
var table3 = new AsciiTable(BorderStyle.UNICODE, Math.max(getUpperListBuilding().size(),getLowerListBuilding().size()));
|
||||
List<String> stringUp3=new ArrayList<>();
|
||||
List<String> stringDown3=new ArrayList<>();
|
||||
for(int i=0;i<Math.max(getUpperListBuilding().size(),getLowerListBuilding().size());i++)
|
||||
{
|
||||
if(i<getUpperListBuilding().size())
|
||||
{
|
||||
stringUp3.add(getUpperListBuilding().get(i).toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
stringUp3.add("-");
|
||||
}
|
||||
if(i<getLowerListBuilding().size())
|
||||
{
|
||||
stringDown3.add(getLowerListBuilding().get(i).toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
stringDown3.add("-");
|
||||
}
|
||||
}
|
||||
table3.addRow(stringUp3);
|
||||
table3.addRow(stringDown3);
|
||||
|
||||
String PlayerToString ="";
|
||||
for(Player p:playersList)
|
||||
{
|
||||
PlayerToString+=p.toString()+"\n";
|
||||
}
|
||||
return PlayerToString+"\n"+ boardToString +"UPPERList\\LOWERList\n"+table2.build() + "\nBUILDING\n"+table3.build() + "\n";
|
||||
//return s.toString()+"\n"++"\nOFFER TRACK\n"+ table.build()+"\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user