|
@@ -58,6 +58,7 @@ func (b *Board) String() string {
|
|
|
|
|
|
|
|
func (b *Board) WriteJSON(w io.Writer, startCol, startRow, cols, rows int) {
|
|
func (b *Board) WriteJSON(w io.Writer, startCol, startRow, cols, rows int) {
|
|
|
sc, sr, cols, rows := sanitizeViewPort(b, startCol, startRow, cols, rows)
|
|
sc, sr, cols, rows := sanitizeViewPort(b, startCol, startRow, cols, rows)
|
|
|
|
|
+ fmt.Fprintf(w, "{x=\"%v\",y=\"%v\",rows=\"%v\",columns=\"%v\",tiles=[", sc, sr, cols, rows)
|
|
|
|
|
|
|
|
for y := startRow; y < sr+rows; y++ {
|
|
for y := startRow; y < sr+rows; y++ {
|
|
|
for x := startCol; x < sc+cols; x++ {
|
|
for x := startCol; x < sc+cols; x++ {
|
|
@@ -70,7 +71,7 @@ func (b *Board) WriteJSON(w io.Writer, startCol, startRow, cols, rows int) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- fmt.Fprintf(w, "}}")
|
|
|
|
|
|
|
+ fmt.Fprintf(w, "]}")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func sanitizeViewPort(b *Board, startCol, startRow, cols, rows int) (int, int, int, int) {
|
|
func sanitizeViewPort(b *Board, startCol, startRow, cols, rows int) (int, int, int, int) {
|