Documentation
¶
Overview ¶
Package engine is a generated GoMock package.
Package engine is a generated GoMock package.
Index ¶
- Constants
- type Board
- type Color
- type Coordinate
- type Game
- type MockBoard
- func (m *MockBoard) BlackPlayer() *Player
- func (m *MockBoard) EXPECT() *MockBoardMockRecorder
- func (m *MockBoard) EatPiece(loc SquareIdentifier) Piece
- func (m *MockBoard) FillSquare(arg0 SquareIdentifier, arg1 Piece)
- func (m *MockBoard) Squares() Squares
- func (m *MockBoard) String() string
- func (m *MockBoard) WhitePlayer() *Player
- type MockBoardMockRecorder
- func (mr *MockBoardMockRecorder) BlackPlayer() *gomock.Call
- func (mr *MockBoardMockRecorder) EatPiece(loc interface{}) *gomock.Call
- func (mr *MockBoardMockRecorder) FillSquare(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockBoardMockRecorder) Squares() *gomock.Call
- func (mr *MockBoardMockRecorder) String() *gomock.Call
- func (mr *MockBoardMockRecorder) WhitePlayer() *gomock.Call
- type MockPiece
- type MockPieceMockRecorder
- type Movement
- type Piece
- type PieceIdentifier
- type PiecesList
- type Player
- type Square
- type SquareIdentifier
- type Squares
Constants ¶
const MAXX = 7
MAXX maximum coordinate value
const MAXY = 7
MAXY maximum coordinate value
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Board ¶
type Board interface { Squares() Squares WhitePlayer() *Player BlackPlayer() *Player // EatPiece removes a piece from Board location return Piece EatPiece(loc SquareIdentifier) Piece // Fill a square with a piece FillSquare(SquareIdentifier, Piece) String() string }
Board chess playable board
type Color ¶
type Color uint8
Color type
const ( // BlackColor color identifier black BlackColor Color // WhiteColor color identifier white WhiteColor )
type Coordinate ¶
Coordinate a coordinate within the Board, starting at 0,0 = A1, 8,8 = H8
func SquareIdentifierToCoordinate ¶
func SquareIdentifierToCoordinate(i SquareIdentifier) Coordinate
SquareIdentifierToCoordinate returns Coordinate equals to SquareIdentifier
type Game ¶
type Game interface { // Move moves a piece in the Board, returns true if moved Move(player Player, from, to SquareIdentifier) (bool, error) // Turn returns player turn Turn() Player // IsCheckBy returns true if Player makes check IsCheckBy(Player) bool // IsCheckmateBy returns true if Player makes checkmate IsCheckmateBy(Player) bool // Board get board Board() Board // Movements get all historic movements Movements() []Movement // Rollback returns to a previous stage, weight means how many steps back Rollback(weight int) WhitePieces() PiecesList BlackPieces() PiecesList String() string }
Game playable game
type MockBoard ¶
type MockBoard struct {
// contains filtered or unexported fields
}
MockBoard is a mock of Board interface.
func NewMockBoard ¶
func NewMockBoard(ctrl *gomock.Controller) *MockBoard
NewMockBoard creates a new mock instance.
func (*MockBoard) BlackPlayer ¶
BlackPlayer mocks base method.
func (*MockBoard) EXPECT ¶
func (m *MockBoard) EXPECT() *MockBoardMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockBoard) EatPiece ¶
func (m *MockBoard) EatPiece(loc SquareIdentifier) Piece
EatPiece mocks base method.
func (*MockBoard) FillSquare ¶
func (m *MockBoard) FillSquare(arg0 SquareIdentifier, arg1 Piece)
FillSquare mocks base method.
func (*MockBoard) WhitePlayer ¶
WhitePlayer mocks base method.
type MockBoardMockRecorder ¶
type MockBoardMockRecorder struct {
// contains filtered or unexported fields
}
MockBoardMockRecorder is the mock recorder for MockBoard.
func (*MockBoardMockRecorder) BlackPlayer ¶
func (mr *MockBoardMockRecorder) BlackPlayer() *gomock.Call
BlackPlayer indicates an expected call of BlackPlayer.
func (*MockBoardMockRecorder) EatPiece ¶
func (mr *MockBoardMockRecorder) EatPiece(loc interface{}) *gomock.Call
EatPiece indicates an expected call of EatPiece.
func (*MockBoardMockRecorder) FillSquare ¶
func (mr *MockBoardMockRecorder) FillSquare(arg0, arg1 interface{}) *gomock.Call
FillSquare indicates an expected call of FillSquare.
func (*MockBoardMockRecorder) Squares ¶
func (mr *MockBoardMockRecorder) Squares() *gomock.Call
Squares indicates an expected call of Squares.
func (*MockBoardMockRecorder) String ¶
func (mr *MockBoardMockRecorder) String() *gomock.Call
String indicates an expected call of String.
func (*MockBoardMockRecorder) WhitePlayer ¶
func (mr *MockBoardMockRecorder) WhitePlayer() *gomock.Call
WhitePlayer indicates an expected call of WhitePlayer.
type MockPiece ¶
type MockPiece struct {
// contains filtered or unexported fields
}
MockPiece is a mock of Piece interface.
func NewMockPiece ¶
func NewMockPiece(ctrl *gomock.Controller) *MockPiece
NewMockPiece creates a new mock instance.
func (*MockPiece) EXPECT ¶
func (m *MockPiece) EXPECT() *MockPieceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPiece) Identifier ¶
func (m *MockPiece) Identifier() PieceIdentifier
Identifier mocks base method.
type MockPieceMockRecorder ¶
type MockPieceMockRecorder struct {
// contains filtered or unexported fields
}
MockPieceMockRecorder is the mock recorder for MockPiece.
func (*MockPieceMockRecorder) CanMove ¶
func (mr *MockPieceMockRecorder) CanMove(board, movements, from, to interface{}) *gomock.Call
CanMove indicates an expected call of CanMove.
func (*MockPieceMockRecorder) Color ¶
func (mr *MockPieceMockRecorder) Color() *gomock.Call
Color indicates an expected call of Color.
func (*MockPieceMockRecorder) Identifier ¶
func (mr *MockPieceMockRecorder) Identifier() *gomock.Call
Identifier indicates an expected call of Identifier.
func (*MockPieceMockRecorder) String ¶
func (mr *MockPieceMockRecorder) String() *gomock.Call
String indicates an expected call of String.
type Movement ¶
type Movement struct { Player Player PieceMoved Piece PieceEaten Piece From SquareIdentifier To SquareIdentifier }
Movement a movement made
type Piece ¶
type Piece interface { // Name Piece name Identifier() PieceIdentifier // Color piece color Color() Color // CanMove check if piece can be moved from, to Square, // returns true if it's possible, even if a piece can be eaten CanMove(board Board, movements []Movement, from, to Square) bool String() string }
Piece piece type
func PieceFromPieceIdentifier ¶
func PieceFromPieceIdentifier(i PieceIdentifier, color Color) Piece
PieceFromPieceIdentifier returns the corresponding Piece associated to PieceIdentifier
type PieceIdentifier ¶
type PieceIdentifier uint8
PieceIdentifier identifier id piece
const ( PawnIdentifier PieceIdentifier BishopIdentifier KnightIdentifier RookIdentifier QueenIdentifier KingIdentifier )
PIECES
type PiecesList ¶
type PiecesList map[PieceIdentifier]uint8
PiecesList is a map of pieces, each value contains number of pieces left in board
type Square ¶
type Square struct { Empty bool Piece Piece Coordinates Coordinate SquareIdentifier SquareIdentifier }
Square type val
type SquareIdentifier ¶
type SquareIdentifier uint8
SquareIdentifier square location identifier
const ( A1 SquareIdentifier B1 C1 D1 E1 F1 G1 H1 A2 B2 C2 D2 E2 F2 G2 H2 A3 B3 C3 D3 E3 F3 G3 H3 A4 B4 C4 D4 E4 F4 G4 H4 A5 B5 C5 D5 E5 F5 G5 H5 A6 B6 C6 D6 E6 F6 G6 H6 A7 B7 C7 D7 E7 F7 G7 H7 A8 B8 C8 D8 E8 F8 G8 H8 )
Square unique names
func CoordinateToSquareIdentifier ¶
func CoordinateToSquareIdentifier(c Coordinate) SquareIdentifier
CoordinateToSquareIdentifier returns equivalent value from Coordinate to Square Identifier
func StringToSquareIdentifier ¶
func StringToSquareIdentifier(str string) (SquareIdentifier, bool)
StringToSquareIdentifier returns SquareIdentifier from string. i.e. str = F("A1") = A1, true
type Squares ¶
type Squares map[SquareIdentifier]Square
Squares board squares, total of 8*8
func PristineSquares ¶
func PristineSquares() Squares
PristineSquares returns Squares at game initialization