Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="game"></param>
        /// <param name="cell"></param>
        /// <returns></returns>
        public static bool AutoMarkAt(this IClearMine game, MineCell cell)
        {
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }

            if (cell == null)
            {
                throw new ArgumentNullException("cell");
            }

            if (game.GameState == GameState.Initialized || game.GameState == GameState.Started)
            {
                if (cell.State == CellState.Normal)
                {
                    game.TryMarkAt(cell, CellState.MarkAsMine);
                }
                else if (cell.State == CellState.MarkAsMine)
                {
                    if (Settings.Default.ShowQuestionMark)
                    {
                        game.TryMarkAt(cell, CellState.Question);
                    }
                    else
                    {
                        game.TryMarkAt(cell, CellState.Normal);
                    }
                }
                else if (cell.State == CellState.Question)
                {
                    game.TryMarkAt(cell, CellState.Normal);
                }
                else
                {
                    // Do nothing.
                }

                return(true);
            }

            return(false);
        }