now able to print out the current state of the chess board
This commit is contained in:
parent
c280b179c4
commit
af2d8d7c4e
|
|
@ -86,9 +86,29 @@ public class Board {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
//TODO
|
StringBuilder sb = new StringBuilder();
|
||||||
return "";
|
|
||||||
}
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void userTouch(int x, int y) {
|
public void userTouch(int x, int y) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue