|
|
@@ -30,6 +30,14 @@ func New(cols, rows int) *Board {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ igloY := rand.Intn(rows-1) + 1
|
|
|
+
|
|
|
+ b.Set(cols-2, igloY, Iglo)
|
|
|
+ b.Finish.X = cols - 2
|
|
|
+ b.Finish.Y = igloY
|
|
|
+ b.Set(cols-2, igloY-1, Water)
|
|
|
+ b.Set(cols-2, igloY+1, Water)
|
|
|
+
|
|
|
return b
|
|
|
}
|
|
|
|
|
|
@@ -62,7 +70,7 @@ func (b *Board) WriteJSON(w io.Writer, startCol, startRow, cols, rows int) {
|
|
|
|
|
|
for y := startRow; y < sr+rows; y++ {
|
|
|
for x := startCol; x < sc+cols; x++ {
|
|
|
- if (!(x == startCol && y == startRow)) {
|
|
|
+ if !(x == startCol && y == startRow) {
|
|
|
w.Write([]byte{','})
|
|
|
}
|
|
|
t := &jsonTile{x, y, b.Get(x, y).Name(), ""}
|
|
|
@@ -107,10 +115,6 @@ func sanitizeViewPort(b *Board, startCol, startRow, cols, rows int) (int, int, i
|
|
|
func (b *Board) randomizeTile(x, y int) {
|
|
|
|
|
|
switch {
|
|
|
- case b.isIglo(x, y):
|
|
|
- b.Set(x, y, Iglo)
|
|
|
- b.Finish.X = x
|
|
|
- b.Finish.Y = y
|
|
|
case b.isRock(x, y):
|
|
|
b.Set(x, y, Rock)
|
|
|
case b.isIce(x, y):
|
|
|
@@ -121,10 +125,6 @@ func (b *Board) randomizeTile(x, y int) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-func (b *Board) isIglo(x, y int) bool {
|
|
|
- return x == (b.Cols-1) && y == (b.Rows-1)/2
|
|
|
-}
|
|
|
-
|
|
|
func (b *Board) isRock(x, y int) bool {
|
|
|
return rand.Intn(10) > 7
|
|
|
}
|