now able to print out the current state of the chess board
This commit is contained in:
parent
c280b179c4
commit
af2d8d7c4e
|
|
@ -86,8 +86,28 @@ public class Board {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
//TODO
|
||||
return "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
Piece found = null;
|
||||
for (Piece p : Pieces) {
|
||||
if (p.getX() == x && p.getY() == y) {
|
||||
found = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found != null) {
|
||||
String color = found.isWhite() ? "W" : "B";
|
||||
sb.append(color).append(found.getType().getSummary()).append(" ");
|
||||
} else {
|
||||
sb.append(".. ");
|
||||
}
|
||||
}
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue