Esempio n. 1
0
 private void GoNext(CellPosition pt)
 {
     _record += pt.ToString();
     Place(pt.Row, pt.Column, _currentPlayer);
     var other = _currentPlayer.GetOtherPlayer();
     if (HasPlaceableCell(other)) { _currentPlayer = other; }
     else { _isGameOver = !HasPlaceableCell(_currentPlayer); }
 }
Esempio n. 2
0
        /// <summary>
        /// Gets the day for a given cell position.
        /// </summary>
        /// <returns>
        /// The day for cell position.
        /// </returns>
        /// <param name='pos'>
        /// Position.
        /// </param>
        public int GetDayForCellPosition(CellPosition pos)
        {
            // Check for sanity
            if ( pos.Row < 0
              || pos.Col < 0 )
            {
                throw new ArgumentOutOfRangeException( "invalid cell: " + pos.ToString() );
            }

            // Do it
            string strDay = (string) this.grdDayGrid.Rows[ pos.Row ].Cells[ pos.Col ].Value;
            int toret = 1;

            if ( strDay != null ) {
                strDay = strDay.Trim();
                if (!( Int32.TryParse( strDay, out toret ) )) {
                    toret = 1;
                }
            } else {
                throw new ArgumentOutOfRangeException( "invalid cell: " + pos.ToString() );
            }

            return toret;
        }