public ChessboardUserControl(ChessboardType chessboardType, UserType userType, string hostname = null) { InitializeComponent(); InitializeChessboard(chessboardType); InitializeAiPlayer(chessboardType, userType); InitializeNetworkManager(userType, hostname); InitializeUsernames(userType); InitializeTurns(userType); InitializeChessboardBoxesArea(); InitializeCapturedPiecesArea(); soundManager = new SoundManager(); NewGame(); }
private void InitializeChessboard(ChessboardType chessboardType, UserType userType) { if (userType == UserType.Client) { var hostname = PromptIpAddress.ShowDialog(); chessboardUserControl = new ChessboardUserControl(chessboardType, userType, hostname); } else { chessboardUserControl = new ChessboardUserControl(chessboardType, userType); } panelChessboard.Controls.Add(chessboardUserControl); chessboardUserControl.OnMadeMove += (origin, destination) => historyEntries.AddEntry(origin, destination); chessboardUserControl.OnNotification += notificationMessage => notifications.AddNotification(notificationMessage); chessboardUserControl.OnReceivedChatMessage += (username, message) => chatBox.AddChatMessage(username, message); }
public static IChessboard GetChessboard(ChessboardType chessboardType) { switch (chessboardType) { case ChessboardType.Classic: { return(new ChessboardClassic()); } case ChessboardType.Shatranj: { throw new NotImplementedException(); } default: { throw new InvalidOperationException(); } } }
public static IAIPlayer GetAiPlayer(ChessboardType chessboardType, UserType userType) { if (userType != UserType.SinglePlayerVersusAI) { return(null); } switch (chessboardType) { // TODO: Maybe do a provider for each chessboard type case ChessboardType.Classic: { return(new RandomMovesAIPlayer()); } default: { return(null); } } }
private void InitializeAiPlayer(ChessboardType chessboardType, UserType userType) { aiPlayer = AiPlayerProvider.GetAiPlayer(chessboardType, userType); }
private void InitializeChessboard(ChessboardType chessboardType) { chessboard = ChessboardProvider.GetChessboard(chessboardType); }