public void highlightThreatened(Piece piece, int row, int col, List<int[]> threatened, List<int[]> enPassant, Piece[,] board, bool filtered = true) { switch (piece.PieceType) { case (Piece.Type.Pawn): pawnThreatenHighlight(piece, row, col, threatened, board, enPassant); break; case (Piece.Type.Rook): rookThreatenHighlight(piece.PieceColour, row, col, threatened, board); break; case (Piece.Type.Knight): knightThreatenHighlight(piece.PieceColour, row, col, threatened); break; case (Piece.Type.Bishop): bishopThreatenHighlight(piece.PieceColour, row, col, threatened, board); break; case (Piece.Type.Queen): queenThreatenHighlight(piece.PieceColour, row, col, threatened, board); break; case (Piece.Type.King): kingThreatenedHighlight(piece, row, col, threatened); break; default: throw new NotImplementedException("Attempted to move a non existent piece type"); } //filtered list only squares that can be moved to, ie. not pieces of the same colour, (need to add) or threatened pieces of the other colour for kings if (filtered) { List<int[]> toRemove = new List<int[]>(); foreach (int[] pair in threatened) if (board[row, col].PieceColour == board[pair[0], pair[1]].PieceColour) toRemove.Add(pair); //if (piece.Type == king) // foreach (int[] pair in threatened) // if (isThreatened(pair[0], pair[1], uf.OtherColour(piece.Colour), Playfield)) // toRemove.Add(pair); foreach (int[] pair in toRemove) threatened.Remove(pair); } }