Esempio n. 1
0
        public void SetCellOwner(byte number, Cell.EOwner owner)
        {
            int row, col;

            convertNumToRowCol(number, out row, out col);

            setCellOwner(row, col, owner);
        }
Esempio n. 2
0
        private void setCellOwner(int row, int col, Cell.EOwner owner)
        {
            if (false == isValid(row))
            {
                return;
            }

            if (false == isValid(col))
            {
                return;
            }

            _board[row, col].Owner = owner;
        }
Esempio n. 3
0
        public int GetBingoCount(Cell.EOwner whose)
        {
            if (Cell.EOwner.Empty == whose)
            {
                return(0);
            }

            int count = 0;

            // rows
            for (int row = 0; row < SIZE; ++row)
            {
                if ((whose == _board[row, 0].Owner) && (whose == _board[row, 1].Owner) && (whose == _board[row, 2].Owner))
                {
                    _board[row, 0].IsBingo = _board[row, 1].IsBingo = _board[row, 2].IsBingo = true;
                    ++count;
                    break;
                }
            }

            // cols
            for (int col = 0; col < SIZE; ++col)
            {
                if ((whose == _board[0, col].Owner) && (whose == _board[1, col].Owner) && (whose == _board[2, col].Owner))
                {
                    _board[0, col].IsBingo = _board[1, col].IsBingo = _board[2, col].IsBingo = true;
                    ++count;
                    break;
                }
            }

            // back slash
            if ((whose == _board[0, 0].Owner) && (whose == _board[1, 1].Owner) && (whose == _board[2, 2].Owner))
            {
                _board[0, 0].IsBingo = _board[1, 1].IsBingo = _board[2, 2].IsBingo = true;
                ++count;
            }

            // slash
            if ((whose == _board[0, 2].Owner) && (whose == _board[1, 1].Owner) && (whose == _board[2, 0].Owner))
            {
                _board[0, 2].IsBingo = _board[1, 1].IsBingo = _board[2, 0].IsBingo = true;
                ++count;
            }

            return(count);
        }
Esempio n. 4
0
 // constructor
 protected Player(BoardGameMode mode, Cell.EOwner owner)
 {
     _mode = mode;
     _owner = owner;
 }
Esempio n. 5
0
 public void Invoke(int row, int col, Cell.EOwner owner)
 {
     _event.Invoke(row, col, owner);
 }
Esempio n. 6
0
 // default handler
 private void onCellOwnerChanged(int row, int col, Cell.EOwner owner)
 {
     Log.Debug(string.Format("onCellOwnerChanged; (row, col) = ({0}, {1}), owner({2})", row, col, owner));
 }