/// <summary> /// GetLocationCalculator /// </summary> /// <param name="chessPieceType"></param> /// <param name="aChessPlayer"></param> /// <returns>ChessLocationCalculator</returns> internal ChessLocationCalculator GetLocationCalculator(EnumPieceType chessPieceType, ChessPlayer aChessPlayer) { switch(chessPieceType) { case EnumPieceType.Pawn: { if (pawnCalculator == null) pawnCalculator = new ChessLocationCalculatorPawn(chessBoard); pawnCalculator.SetCurrentPlayer(aChessPlayer); return pawnCalculator; } case EnumPieceType.Rook: { if (rookCalculator == null) rookCalculator = new ChessLocationCalculatorRook(chessBoard); return rookCalculator; } case EnumPieceType.Knight: { if (knightCalculator == null) knightCalculator = new ChessLocationCalculatorKnight(chessBoard); return knightCalculator; } case EnumPieceType.Bishop: { if (bishopCalculator == null) bishopCalculator = new ChessLocationCalculatorBishop(chessBoard); return bishopCalculator; } case EnumPieceType.Queen: { if (queenCalculator == null) queenCalculator = new ChessLocationCalculatorQueen(chessBoard); return queenCalculator; } case EnumPieceType.King: { if (kingCalculator == null) kingCalculator = new ChessLocationCalculatorKing(chessBoard); return kingCalculator; } } throw (new Exception("LocationCalculatorFactory.GetLocationCalculator : Invalid Chess Piece Type")); }
/// <summary> /// InitializeImageGenerator /// </summary> public void InitializeImageGenerator() { try { if (null == (chessBoardPictureBox = (PictureBox)FindControl("pictureBoxCenter"))) { string errorMsg = "Null PictureBox Control:"; throw new Exception(errorMsg); } } catch (Exception E) { string errorMsg = E.ToString(); throw new Exception(errorMsg); } try { if (null == (whitePlayerButton = (Button)FindControl("buttonWhitePlayer"))) { string errorMsg = "Null Bottom Button Control:"; throw new Exception(errorMsg); } } catch (Exception E) { string errorMsg = E.ToString(); throw new Exception(errorMsg); } try { if (null == (blackPlayerButton = (Button)FindControl("buttonBlackPlayer"))) { string errorMsg = "Null Top Button Control:"; throw new Exception(errorMsg); } } catch (Exception E) { string errorMsg = E.ToString(); throw new Exception(errorMsg); } try { if (WhitePlayerName == null) { chessWhitePlayerName = WhitePlayerName; } else { chessWhitePlayerName = whitePlayerButton.Text; } if (BlackPlayerName == null) { chessBlackPlayerName = BlackPlayerName; } else { chessBlackPlayerName = blackPlayerButton.Text; } chessBoard = new ChessBoard(this, chessBoardPictureBox); chessWhitePlayer = new ChessPlayer(EnumPlayerType.WhitePlayer, chessWhitePlayerName, EnumPieceColor.White); chessBlackPlayer = new ChessPlayer(EnumPlayerType.BlackPlayer, chessBlackPlayerName, EnumPieceColor.Black); chessBoard.InitializeChessBoard(); SetChessBoardPlayerButtonText(); chessWhitePlayer.SetPieceList(chessBoard.GetWhitePieceList()); chessBlackPlayer.SetPieceList(chessBoard.GetBlackPieceList()); } catch (Exception E) { string errorMsg = E.ToString(); throw new Exception(errorMsg); } }
/// <summary> /// SetCurrentPlayer /// </summary> /// <param name="aChessPlayer"></param> internal void SetCurrentPlayer(ChessPlayer aChessPlayer) { chessPlayer = aChessPlayer; }