java.lang.Object
app.chess.utils.Utils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
(package private) static class
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
fieldIsUnderAttack
(int byWho, Field field, ChessPiece[][] board) static boolean
fieldIsValid
(Field toValidate) static ChessPiece
findPawnThatCanBePromoted
(int player, ChessPiece[][] board) static Field
getKingsPosition
(int player, ChessPiece[][] board) static List<ChessPiece>
getMatchingPieces
(boolean checkPlayer, int player, ChessPiece[][] board) static ChessPiece
getPieceByField
(Field field, ChessPiece[][] board) static Field
static Field
static boolean
kingIsSafe
(int whose, ChessPiece[][] board) static ChessPiece
putPieceOnBoard
(ChessPiece who, Field field, ChessPiece[][] board) Puts the piece on a given piece on board, WITHOUT changing any data about piece location (inside the piece).static boolean
roadNotObstructed
(Field currentPosition, Field newPosition, ChessPiece[][] board)
-
Method Details
-
roadNotObstructed
public static boolean roadNotObstructed(Field currentPosition, Field newPosition, ChessPiece[][] board) -
getRookPositionBasedOnCastling
- Returns:
- Assuming that castling is possible, returns the position on which the rook should be located. Makes
ABSOLUTELY NO GUARANTEE that castling is legal.
TODO: Placement of this function is bad. Find a class where it makes more sense.
-
fieldIsValid
-
getPieceByField
-
putPieceOnBoard
Puts the piece on a given piece on board, WITHOUT changing any data about piece location (inside the piece). Should be used with caution.- Returns:
- Piece that was already on a given field
-
getMatchingPieces
public static List<ChessPiece> getMatchingPieces(boolean checkPlayer, int player, ChessPiece[][] board) - Parameters:
checkPlayer
- Whether to return pieces of only one playerplayer
- Player whose pieces should be returned- Returns:
- All pieces on board that satisfact the given criteria
-
fieldIsUnderAttack
-
getKingsPosition
-
kingIsSafe
-
findPawnThatCanBePromoted
-
inferNewRookPositionAfterCastling
-