2022-02-21 19:07:28 -05:00
|
|
|
package freego
|
2022-02-18 18:36:18 -05:00
|
|
|
|
|
|
|
//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-20 18:36:52 -05:00
|
|
|
Bomb
|
2022-03-07 16:09:42 -05:00
|
|
|
Unknown
|
2022-02-20 17:10:50 -05:00
|
|
|
)
|
2022-02-18 18:36:18 -05:00
|
|
|
|
|
|
|
//Piece :game piece
|
|
|
|
type Piece struct {
|
|
|
|
Rank Rank
|
|
|
|
Owner Colour
|
|
|
|
Hidden bool
|
|
|
|
}
|
|
|
|
|
2022-02-20 18:36:52 -05:00
|
|
|
//NewPieceFromInt creates a new piece
|
|
|
|
func NewPieceFromInt(r int, o Colour) *Piece {
|
2022-02-18 18:36:18 -05:00
|
|
|
return &Piece{
|
|
|
|
Rank: Rank(r),
|
|
|
|
Owner: o,
|
|
|
|
Hidden: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-20 18:36:52 -05:00
|
|
|
//NewPiece generates a piece by rank
|
|
|
|
func NewPiece(r Rank, o Colour) *Piece {
|
|
|
|
return &Piece{
|
|
|
|
Rank: r,
|
|
|
|
Owner: o,
|
2022-03-07 16:09:42 -05:00
|
|
|
Hidden: true,
|
2022-02-20 18:36:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-07 16:09:42 -05:00
|
|
|
//NewUnknownPiece creates a new hidden piece
|
|
|
|
func NewUnknownPiece(o Colour) *Piece {
|
2022-02-18 18:36:18 -05:00
|
|
|
return &Piece{
|
|
|
|
Owner: o,
|
2022-03-07 16:09:42 -05:00
|
|
|
Rank: Unknown,
|
2022-02-18 18:36:18 -05:00
|
|
|
Hidden: true,
|
|
|
|
}
|
|
|
|
}
|