-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcolour.go
38 lines (32 loc) · 843 Bytes
/
colour.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package sgf
type Colour int8
const (
EMPTY = Colour(iota)
BLACK
WHITE
)
// Opposite returns the opposite colour (if called on BLACK or WHITE) otherwise
// it returns EMPTY.
func (c Colour) Opposite() Colour {
if c == BLACK { return WHITE }
if c == WHITE { return BLACK }
return EMPTY
}
// Upper returns a single byte string, "B" or "W" or "?", for the colour.
func (c Colour) Upper() string {
if c == BLACK { return "B" }
if c == WHITE { return "W" }
return "?"
}
// Lower returns a single byte string, "b" or "w" or "?", for the colour.
func (c Colour) Lower() string {
if c == BLACK { return "b" }
if c == WHITE { return "w" }
return "?"
}
// Word returns a word, "Black" or "White" or "??", for the colour.
func (c Colour) Word() string {
if c == BLACK { return "Black" }
if c == WHITE { return "White" }
return "??"
}