public AddCustomGameForm(User user, LobbyForm form, NetworkStream stream, MoveLogic ml) { moveLogic = ml; me = user; lobby = form; this.stream = stream; InitializeComponent(); GetGames(); }
private void logInButton_Click(object sender, EventArgs e) { // Empty username and/or password if (usernameText.Text == "" || passwordText.Text == "") { // Empty username error if (usernameText.Text == "") { error1.Show(); } else { error1.Hide(); } // Empty password error if (passwordText.Text == "") { error2.Show(); } else { error2.Hide(); } } else { error1.Hide(); error2.Hide(); // TODO: Send a request to the server to log in // TODO: Show error3 if invalid username or password // TODO: show the interface for the lobby if correct combination /// MessageBox.Show("You just entered the password: "******"Message123"); if (Verify_Login(usernameText.Text, passwordText.Text)) { Hide(); ChessUtils.IPAddress = hostText.Text; ChessUtils.Port = Convert.ToInt32(portText.Text); ChessUtils.IPAddressWithPort = "http://" + hostText.Text + ":" + portText.Text + "/"; LobbyForm lobby = new LobbyForm(new User(usernameText.Text, passwordText.Text)); lobby.ShowDialog(); Show(); } else { error3.Show(); } } }
public GameSession(User Me, User Them, NetworkStream networkStream, Session session, LobbyForm Lobby, MoveLogic ml, CustomGame game = null) { me = Me; int squareSize = 65; int offset = 50; InitializeComponent(); lobby = Lobby; moveLogic = ml; // Create timers timer = new System.Timers.Timer(1000); timer.Elapsed += async(sender, e) => await Timer_Elapsed(); stream = networkStream; sessionInfo = session; originalTotalTimeRemaining = eTotalTimeRemaining = totalTimeRemaining = sessionInfo.GameTimerSeconds; originalTimeRemaining = eTotalTimeRemaining = turnTimeRemaining = sessionInfo.MoveTimerSeconds; myTotalTimeRemaining.Text = ChessUtils.ConvertSecondsToTimeString(totalTimeRemaining); myTimeRemaining.Text = ChessUtils.ConvertSecondsToTimeString(turnTimeRemaining); enemyTotalTimeRemaining.Text = ChessUtils.ConvertSecondsToTimeString(totalTimeRemaining); enemyTimeRemaining.Text = ChessUtils.ConvertSecondsToTimeString(turnTimeRemaining); myName = myUsername.Text = me.Username; opponentName = enemyUsername.Text = Them.Username; customGame = game; // set up the array of buttons (chess grid) into an array board = new Button[, ] { { square00, square01, square02, square03, square04, square05, square06, square07 }, { square10, square11, square12, square13, square14, square15, square16, square17 }, { square20, square21, square22, square23, square24, square25, square26, square27 }, { square30, square31, square32, square33, square34, square35, square36, square37 }, { square40, square41, square42, square43, square44, square45, square46, square47 }, { square50, square51, square52, square53, square54, square55, square56, square57 }, { square60, square61, square62, square63, square64, square65, square66, square67 }, { square70, square71, square72, square73, square74, square75, square76, square77 } }; // Set up the board to look pretty for (int i = 0; i < 8; ++i) { for (int j = 0; j < 8; ++j) { Point p = new Point(j * squareSize + offset, i * squareSize + (offset * 2)); Size s = new Size(squareSize, squareSize); Coordinates c = ChessUtils.Settings.GetCoordinatesOfButton(board[i, j]); board[i, j].Size = s; board[i, j].Location = p; } } ChessUtils.Settings.Image.UpdateBoardImages(board); ChessUtils.Settings.Color.UpdateChessBoardColors(board); UpdatePlayerPieces(whitePieces, blackPieces); moveLogic.UpdateAttackedSquares(board); SetUpButtons(); moveLogic.ClearChessBoardColors(board); // I am the guest, both people are in the game, now set the game to started if (Me.Username != "" && Them.Username != "") { moveLogic.gameStarted = true; } checkLabel.Hide(); gameWorker.RunWorkerAsync(); }