Skip to content
Browse files

Add GetCell cell-getter to board

  • Loading branch information...
1 parent 0b78bfb commit 9c0e49ddcf7d2407a269c860ce9e4f7d3092eb8b @trevorsummerssmith committed Sep 29, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/pkg/game/game.go
View
9 src/pkg/game/game.go
@@ -57,6 +57,15 @@ func New(rows uint, cols uint) *Board {
}
}
+func (b *Board) GetCell(idx Idx) (cell Cell, err os.Error) {
+ if !b.ValidIdx(idx) {
+ err = os.NewError("Index out of bounds")
+ return
+ }
+ cell = b.cells[idx.Row][idx.Col]
+ return
+}
+
func (b *Board) ValidIdx(idx Idx) bool {
return idx.Row < b.rows && idx.Col < b.cols
}

0 comments on commit 9c0e49d

Please sign in to comment.
Something went wrong with that request. Please try again.