private void updateAttacksButton_Click(object sender, EventArgs e)
        {
            MoveLogic logic = new MoveLogic();

            logic.ClearChessBoardColors(board);
            logic.HighlightAttackedSquares(board);
        }
예제 #2
0
        public LobbyForm(User user)
        {
            me = user;

            InitializeComponent();
            SetupSettings();
            client    = new TcpClient(ChessUtils.IPAddress, ChessUtils.Port + 1);
            stream    = client.GetStream();
            moveLogic = new MoveLogic();

            join.Enabled = remove.Enabled = false;

            RefreshTable();

            // Prevent first row from being deletable by non-owners
            if (lobbyTable.Rows.Count > 0)
            {
                if ((string)lobbyTable.Rows[0].Cells[2].Value != me.Username)
                {
                    remove.Enabled = false;
                }
            }
            //tcpClientWorker.RunWorkerAsync();
            stream.ReadTimeout = 1000; // ms
        }
예제 #3
0
 public AddCustomGameForm(User user, LobbyForm form, NetworkStream stream, MoveLogic ml)
 {
     moveLogic   = ml;
     me          = user;
     lobby       = form;
     this.stream = stream;
     InitializeComponent();
     GetGames();
 }
        private void clearBoard_Click(object sender, EventArgs e)
        {
            MoveLogic logic = new MoveLogic();

            logic.ClearChessBoardColors(board);

            foreach (Button square in board)
            {
                square.Image = null;
                square.Tag   = TagStrings[(int)PieceEnum.None];
            }
        }
예제 #5
0
        public ViewGameDetailsForm()
        {
            InitializeComponent();
            moveLogic = new MoveLogic();
            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 customizations of the board
            ChessUtils.Settings.Image.UpdateBoardImages(board);
            ChessUtils.Settings.Color.UpdateChessBoardColors(board);
        }
예제 #6
0
        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();
        }
        private void hideAttackButton_Click(object sender, EventArgs e)
        {
            MoveLogic logic = new MoveLogic();

            logic.ClearChessBoardColors(board);
        }