-
Notifications
You must be signed in to change notification settings - Fork 0
/
sections.go
88 lines (66 loc) · 1.34 KB
/
sections.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package pgn
import "fmt"
type stmt interface {
Type() string
}
// Move
type Move struct {
MoveNumber int
MoveWhite string
MoveBlack string
WhiteAnnotations []string
BlackAnnotations []string
}
func (m Move) Number() int {
return m.MoveNumber
}
func (m Move) White() string {
return m.MoveWhite
}
func (m Move) Black() string {
return m.MoveBlack
}
func (m Move) Type() string {
return MOVE
}
func (m Move) GetAnnotations(color string) []string {
if color == "White" {
return m.WhiteAnnotations
}
if color == "Black" {
return m.BlackAnnotations
}
return []string{}
}
func (m Move) String() string {
return fmt.Sprintf("%d. %s %s", m.MoveNumber, m.MoveWhite, m.MoveBlack)
}
//Tag Pair
type TagPair struct {
LBracket token
TagName string
TagValue string
RBracket token
}
func (tp TagPair) Name() string {
return tp.TagName
}
func (tp TagPair) Value() string {
return tp.TagValue
}
func (tp TagPair) Stringify() string {
return fmt.Sprintf("%s%s %s%s", tp.LBracket.TokenLiteral(), tp.TagName, tp.TagValue, tp.RBracket.TokenLiteral())
}
func (tp TagPair) Type() string {
return TAG_PAIR
}
// Game Termination
type gameTermination struct {
TerminationValue string
}
func (gt gameTermination) Value() string {
return gt.TerminationValue
}
func (gt gameTermination) Type() string {
return TERMINATION
}