Add: Added Javadoc For "toString" Method In Player.java.
Fix: "addSeparator" Method In AsciiTable.java Now Correctly Positons Separators.
This commit is contained in:
@@ -8,7 +8,6 @@ import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static it.polimi.ingsw.gc14.View.TUI.BorderStyle.*;
|
||||
|
||||
@@ -228,17 +227,34 @@ public class Player implements Serializable {
|
||||
// endregion constructors
|
||||
|
||||
// region Functions
|
||||
/**
|
||||
* Prints the {@code Player}'s attributes for the {@code Board}'s representation.
|
||||
* Uses the {@code UNICODE} border style.
|
||||
* <p><b>Includes:</b>
|
||||
* <li>{@link #FoodValue Food}
|
||||
* <li>{@link #PrestigeValue Prestige}
|
||||
* <li>{@link #artists Artists}
|
||||
* <li>{@link #builders Builders}
|
||||
* <li>{@link #gatherers Gatherers}
|
||||
* <li>{@link #shamans Shamans}
|
||||
* <li>{@link #inventors Inventors}
|
||||
* <li>{@link #hunters Hunters}
|
||||
* <li>{@link #buildingCards Buildings}
|
||||
* </p>
|
||||
* @return {@code String} - A string representation of the {@code Player}'s attributes.
|
||||
* @see it.polimi.ingsw.gc14.View.TUI.BorderStyle BorderStyle
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
int Last = 6;
|
||||
int Last = -1;
|
||||
|
||||
var table = new AsciiTable(UNICODE, 1);
|
||||
|
||||
table.addHeader(this.getUserName());
|
||||
table.addRow("RESOURCES:");
|
||||
table.addRow("Food: " + this.getFoodValue());
|
||||
table.addSeparator();
|
||||
table.addRow("Prestige: " + this.getPrestigeValue());
|
||||
table.addSeparator();
|
||||
|
||||
if(!this.hunters.isEmpty()){
|
||||
Last = 6;
|
||||
@@ -267,44 +283,44 @@ public class Player implements Serializable {
|
||||
}
|
||||
table.addRow("CHARACTERS:");
|
||||
if(!this.artists.isEmpty()){
|
||||
table.addRow("Artists: " + this.artists.toString());
|
||||
if(Last == 1){
|
||||
table.addSeparator();
|
||||
}
|
||||
table.addRow("Artists: " + this.artists.toString());
|
||||
}
|
||||
|
||||
if(!this.builders.isEmpty()){
|
||||
table.addRow("Builders: " + this.builders.toString());
|
||||
if(Last == 2){
|
||||
table.addSeparator();
|
||||
}
|
||||
table.addRow("Builders: " + this.builders.toString());
|
||||
}
|
||||
|
||||
if(!this.gatherers.isEmpty()){
|
||||
table.addRow("Gatherers: " + this.gatherers.toString());
|
||||
if(Last == 3){
|
||||
table.addSeparator();
|
||||
}
|
||||
table.addRow("Gatherers: " + this.gatherers.toString());
|
||||
}
|
||||
|
||||
if(!this.shamans.isEmpty()){
|
||||
table.addRow("Shamans: " + this.shamans.toString());
|
||||
if(Last == 4){
|
||||
table.addSeparator();
|
||||
}
|
||||
table.addRow("Shamans: " + this.shamans.toString());
|
||||
}
|
||||
|
||||
if(!this.inventors.isEmpty()){
|
||||
table.addRow("Inventors: " + this.inventors.toString());
|
||||
if(Last == 5){
|
||||
table.addSeparator();
|
||||
}
|
||||
table.addRow("Inventors: " + this.inventors.toString());
|
||||
}
|
||||
|
||||
|
||||
if(!this.hunters.isEmpty()){
|
||||
table.addSeparator();
|
||||
table.addRow("Hunters: " + this.hunters.toString());
|
||||
table.addSeparator();
|
||||
}
|
||||
|
||||
table.addRow("BUILDING CARDS:");
|
||||
|
||||
@@ -15,7 +15,7 @@ public class AsciiTable {
|
||||
public void addRow(String... cells) { rows.add(Arrays.asList(cells)); }
|
||||
public void addRow(List<String> cells) { rows.add(cells); }
|
||||
public void addHeader(String... cells) { rows.add(0, Arrays.asList(cells)); separators.add(0); }
|
||||
public void addSeparator() { separators.add(rows.size()); }
|
||||
public void addSeparator() { separators.add(rows.size()-1); }
|
||||
|
||||
public String build() {
|
||||
var sb = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user