Пример #1
0
        public void Move(object sender, MoveArgs e)
        {
            if (e.playerId != Turn)
            {
                return;                         // not players turn Return
            }
            int col      = e.col;
            int playerId = e.playerId;
            int row;

            //check a place is available in Coloum
            if (!Move_Available(col))
            {
                return;                       // Move Not Avaliable Return
            }
            //annoyouns Move to network if it was made by local player
            if (e.playerId == Properties.Settings.Default.userId)
            {
                OnMoveMade?.Invoke(this, new MoveArgs(col, Properties.Settings.Default.userId));
            }
            row = GetRow(col, playerId);
            lock (board)                                 // Lock Board while in use
            {
                board.boardState[col, row] = e.playerId; //update Boardstate With move
                OnUpdate(this, board);
            }
            Turn *= -1;   // use
                          // use  reference types that point to player / players peices ------------------------------------------------------
                          // dont repeat your selfs

            // Ai Takes over moves

            if (win(e.playerId, col, row))
            {
                gameActive = false;
                OnWin?.Invoke(this, e.playerId.ToString()); // Publish Win Event
            }
            if (Ai && gameActive && Turn == Properties.Settings.Default.userId)
            {
                AiPlayer();
            }
        }
Пример #2
0
        internal void localMoveMade(object sender, MoveArgs e)
        {
            string cmd = "Move|" + e.playerId + paramDelimiter + e.col;

            Add_send(cmd);
        }