diff options
Diffstat (limited to 'go/game/pos.go')
| -rw-r--r-- | go/game/pos.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/go/game/pos.go b/go/game/pos.go index 133f599b..bf35ca3b 100644 --- a/go/game/pos.go +++ b/go/game/pos.go @@ -4,6 +4,12 @@ import ( "fmt" ) +// Position represents a zero-based position on the map. +// TODO: Change to a 1-based coordinate system. +// +// This allows to use the zero value as invalid Position. +// +// The origin is the upper left corner of the map. type Position struct { X int Y int @@ -22,3 +28,8 @@ func (p Position) String() string { func INVALID_POSITION() Position { return Position{-1, -1} } + +// Valid reports if a coordinate is smaller than 0. +func (p Position) Valid() bool { + return p.X >= 0 && p.Y >= 0 +} |
