Fix king moves and fix formatting.
This commit is contained in:
parent
2d5eacb351
commit
63e973a3be
@ -200,12 +200,11 @@ func (b *Board) handleSpecialMove(move types.Move) bool {
|
||||
var was bool
|
||||
var pieceAtStartSquare = b.getPieceAt(move.StartSquare)
|
||||
|
||||
switch pieceAtStartSquare.(type) {
|
||||
switch piece := pieceAtStartSquare.(type) {
|
||||
case Pawn:
|
||||
pawn := pieceAtStartSquare.(Pawn)
|
||||
was = pawn.HandlePossiblePromotion(b, move)
|
||||
was = piece.HandlePossiblePromotion(b, move)
|
||||
if !was {
|
||||
was = pawn.HandleEnPassant(b, move, b.getLastMove())
|
||||
was = piece.HandleEnPassant(b, move, b.getLastMove())
|
||||
}
|
||||
}
|
||||
return was
|
||||
|
@ -31,14 +31,15 @@ func (b *Board) GetNonBlockedDiagonals(fromSquare types.Coordinate) []types.Coor
|
||||
}
|
||||
|
||||
func (b *Board) GetNonBlockedKingMoves(fromSquare types.Coordinate) []types.Coordinate {
|
||||
return b.getNonBlockedConsecutive(fromSquare.GetAllKingMoves(), fromSquare)
|
||||
return b.getNonBlockedRaw(fromSquare.GetAllKingMoves(), fromSquare)
|
||||
}
|
||||
|
||||
func (b *Board) GetNonBlockedKnightMoves(fromSquare types.Coordinate) []types.Coordinate {
|
||||
allKnightMoves := fromSquare.GetAllKnightMoves()
|
||||
return b.getNonBlockedForKnights(allKnightMoves, fromSquare)
|
||||
return b.getNonBlockedRaw(fromSquare.GetAllKnightMoves(), fromSquare)
|
||||
}
|
||||
|
||||
// returns only those squares in a straight/diagonal that are not blocked
|
||||
// until it hits a blocking piece (excluding same color, including diff color)
|
||||
func (b *Board) getNonBlockedConsecutive(
|
||||
squaresToCheck []types.Coordinate,
|
||||
sourceSquare types.Coordinate,
|
||||
@ -64,7 +65,8 @@ func (b *Board) getNonBlockedConsecutive(
|
||||
return nonBlocked
|
||||
}
|
||||
|
||||
func (b *Board) getNonBlockedForKnights(
|
||||
// returns any square in squaresToCheck that are not blocked
|
||||
func (b *Board) getNonBlockedRaw(
|
||||
squaresToCheck []types.Coordinate,
|
||||
sourceSquare types.Coordinate,
|
||||
) []types.Coordinate {
|
||||
|
Loading…
Reference in New Issue
Block a user