Loading internal/pkg/board/board.go +35 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,19 @@ func ParsePiece(s string) Piece { } } func (p Piece) MarshalJSON() ([]byte, error) { return json.Marshal(p.String()) } func (p *Piece) UnmarshalJSON(b []byte) error { var s string if err := json.Unmarshal(b, &s); err != nil { return err } *p = ParsePiece(s) return nil } type Point uint const ( Loading Loading @@ -216,6 +229,20 @@ func ParsePoint(s string) Point { } } //func (p Point) MarshalJSON() ([]byte, error) { // s := p.String() // return json.Marshal(s) //} // //func (p *Point) UnmarshalJSON(b []byte) error { // var s string // if err := json.Unmarshal(b, &s); err != nil { // return err // } // *p = ParsePoint(s) // return nil //} func Points() []Point { return []Point{ PointA7, Loading Loading @@ -272,6 +299,14 @@ type Board struct { Points map[Point]Piece `json:"points,omitempty"` } //func (b *Board) MarshalJSON() ([]byte, error) { // //} // //func (b *Board) UnmarshalJSON([]byte) error { // //} func New() *Board { b := &Board{ Points: make(map[Point]Piece), Loading Loading
internal/pkg/board/board.go +35 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,19 @@ func ParsePiece(s string) Piece { } } func (p Piece) MarshalJSON() ([]byte, error) { return json.Marshal(p.String()) } func (p *Piece) UnmarshalJSON(b []byte) error { var s string if err := json.Unmarshal(b, &s); err != nil { return err } *p = ParsePiece(s) return nil } type Point uint const ( Loading Loading @@ -216,6 +229,20 @@ func ParsePoint(s string) Point { } } //func (p Point) MarshalJSON() ([]byte, error) { // s := p.String() // return json.Marshal(s) //} // //func (p *Point) UnmarshalJSON(b []byte) error { // var s string // if err := json.Unmarshal(b, &s); err != nil { // return err // } // *p = ParsePoint(s) // return nil //} func Points() []Point { return []Point{ PointA7, Loading Loading @@ -272,6 +299,14 @@ type Board struct { Points map[Point]Piece `json:"points,omitempty"` } //func (b *Board) MarshalJSON() ([]byte, error) { // //} // //func (b *Board) UnmarshalJSON([]byte) error { // //} func New() *Board { b := &Board{ Points: make(map[Point]Piece), Loading