Esempio n. 1
0
 //I've made this indexer only for easier _gameBoard access inside the class
 private Xo this[Cell cell]
 {
     get
     {
         return _gameBoard[cell.X, cell.Y];
     }
     set
     {
         _gameBoard[cell.X, cell.Y] = value;
     }
 }
Esempio n. 2
0
        public string DisplayBoard()
        {
            var borad = new StringBuilder().Append(Environment.NewLine);

            for (var i = 0; i < 3; i++)
            {
                for (var j = 0; j < 3; j++)
                {
                    var cell = new Cell(i,j);
                    var xo = (this[cell]) == 0 ? "?" : this[cell].ToString();
                    borad.AppendFormat("{0,2}", xo);
                }
                borad.Append(Environment.NewLine);
            }
            return borad.ToString();
        }
Esempio n. 3
0
        public bool Move(Cell cell)
        {
            if (IsMoveIlegal(cell)) return false;

            this[cell] = CurrentTurn;
            _countMoves++;
            _lastMove = cell;
            ChangeTurn();

            return true;
        }
Esempio n. 4
0
        private bool IsMoveIlegal(Cell cell)
        {
            if (!cell.IsValidCell())
                return true;

            return this[cell] != 0;
        }