public void AssignCellOwner(int CellRow, int CellCol, CellOwners CellOwner)
        {
            if (_ticTacToeCells.Count == 0)
            {
                return;
            }

            var targetCell = _ticTacToeCells.FirstOrDefault(tttc => tttc.RowID == CellRow && tttc.ColID == CellCol);

            if (targetCell == null)
            {
                return;
            }

            targetCell.CellOwner = CellOwner;

            System.Diagnostics.Debug.Print($"AssignCellOwner: {CellRow},{CellCol} = {CellOwner.ToString()}");

            // unit #9
            // these will be the arguments used when the event is fired
            var eventArgs = new CellOwnerChangedArgs(CellRow, CellCol, CellOwner);

            //bubble the event up to the parent ( ONLY if the parent is listening )
            CellOwnerChanged?.Invoke(this, eventArgs);
        }
Пример #2
0
        public void AssignCellOwner(int CellRow, int CellCol, CellOwners CellOwner)
        {
            if (_ticTacToeCells.Count == 0)
            {
                return;
            }

            if (Winner == CellOwners.Computer || Winner == CellOwners.Human)
            {
                return;
            }

            var targetCell = _ticTacToeCells
                             .FirstOrDefault(tttc => tttc.RowID == CellRow && tttc.ColID == CellCol);

            if (targetCell == null)
            {
                return;
            }

            targetCell.CellOwner = CellOwner;

            Debug.WriteLine($"Method: AssignCellOwner {CellRow}-{CellCol} {CellOwner}");

            // unit #9
            // these will be the arguments used when the event is fired
            var eventArgs = new CellOwnerChangedArgs(CellRow, CellCol, CellOwner);

            //bubble the event up to the parent ( ONLY if the parent is listening )
            CellOwnerChanged?.Invoke(this, eventArgs);
        }
Пример #3
0
        public void AssignCellOwner(int CellRow, int CellCol, CellOwners CellOwner)
        {
            if (_ticTacToeCells.Count == 0)
            {
                return;
            }

            var targetCell = _ticTacToeCells
                             .FirstOrDefault(tttc => tttc.RowID == CellRow & tttc.ColID == CellCol);

            if (targetCell == null)
            {
                return;
            }

            targetCell.CellOwner = CellOwner;
            Debug.WriteLine($"Method: AssignCellOwner {CellRow}-{CellCol} --> {CellOwner}");

            var eventArgs = new CellOwnerChangedArgs(CellRow, CellCol, CellOwner);

            CellOwnerChanged?.Invoke(this, eventArgs);
        }