-
Notifications
You must be signed in to change notification settings - Fork 0
/
pieces.go
44 lines (41 loc) · 923 Bytes
/
pieces.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
39
40
41
42
43
44
//go:generate fyne bundle -o bundled-pieces.go pieces
package main
import (
"fyne.io/fyne/v2"
"github.com/notnil/chess"
)
func resourceForPiece(p chess.Piece) fyne.Resource {
switch p.Color() {
case chess.Black:
switch p.Type() {
case chess.Pawn:
return resourceBlackPawnSvg
case chess.Bishop:
return resourceBlackBishopSvg
case chess.King:
return resourceBlackKingSvg
case chess.Knight:
return resourceBlackKnightSvg
case chess.Queen:
return resourceBlackQueenSvg
case chess.Rook:
return resourceBlackRookSvg
}
case chess.White:
switch p.Type() {
case chess.Pawn:
return resourceWhitePawnSvg
case chess.Bishop:
return resourceWhiteBishopSvg
case chess.King:
return resourceWhiteKingSvg
case chess.Knight:
return resourceWhiteKnightSvg
case chess.Queen:
return resourceWhiteQueenSvg
case chess.Rook:
return resourceWhiteRookSvg
}
}
return nil
}