freego/piece.go

41 lines
552 B
Go
Raw Normal View History

2022-02-18 18:36:18 -05:00
package main
//Rank represents the rank of a piece
2022-02-20 17:10:50 -05:00
//go:generate enumer -type=Rank
2022-02-18 18:36:18 -05:00
type Rank int
2022-02-20 17:10:50 -05:00
//Rank rank pieces
const (
Flag Rank = iota
Spy
Scout
Miner
Captain
General
Marshal
)
2022-02-18 18:36:18 -05:00
//Piece :game piece
type Piece struct {
Rank Rank
Owner Colour
Hidden bool
}
//NewPiece creates a new piece
func NewPiece(r int, o Colour) *Piece {
return &Piece{
Rank: Rank(r),
Owner: o,
Hidden: false,
}
}
//NewHiddenPiece creates a new hidden piece
func NewHiddenPiece(o Colour) *Piece {
return &Piece{
Owner: o,
Hidden: true,
}
}