示例#1
0
        public void Visit(GameFinisher finisher)
        {
            if (finisher.IsGameFinishAccepted)
            {
                if (finisher.IsAnswerCorrect)
                {
                    Console.Clear();
                }
                else
                {
                    Console.Clear();
                    Console.SetCursorPosition(0, 0);
                    Console.Write("Do you want to play a new game?");

                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.SetCursorPosition(0, 2);
                    Console.Write(finisher.ErrorMessage);
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }
            else
            {
                Console.SetCursorPosition(5, 0);
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Write(finisher.QuitMessage);
                Console.ForegroundColor = ConsoleColor.White;
            }
        }
示例#2
0
        private void IsGameFinished()
        {
            int    flaggedMinescount    = 0;
            int    discoveredFieldcount = 0;
            string GameQuitMessage;

            foreach (Field field in gamehandler.Gameboard.Gamefields)
            {
                if (field.HasMine && field.ShowNumber)
                {
                    GameFinished = true;
                    this.gamehandler.IsGameFinished = true;
                    GameQuitMessage = "You lost because you tapped on a mine. Please press enter to continue.";
                    gameFinisher    = new GameFinisher(GameQuitMessage);
                    break;
                }

                if (field.HasMine && field.HasFlag)
                {
                    flaggedMinescount++;
                    if (flaggedMinescount >= gamehandler.Gameboard.MineCount)
                    {
                        GameFinished = true;
                        this.gamehandler.IsGameFinished = true;
                        GameQuitMessage = "Congratulations! You win. Please press enter to continue.";
                        gameFinisher    = new GameFinisher(GameQuitMessage);
                        break;
                    }
                }

                if (!field.HasMine && field.ShowNumber)
                {
                    discoveredFieldcount++;
                    if (discoveredFieldcount >= gamehandler.Gameboard.Gamefields.Count - gamehandler.Gameboard.MineCount)
                    {
                        GameFinished = true;
                        this.gamehandler.IsGameFinished = true;
                        GameQuitMessage = "Congratulations! You win. Please press enter to continue.";
                        gameFinisher    = new GameFinisher(GameQuitMessage);
                        break;
                    }
                }
            }
        }
 public void Visit(GameFinisher finisher)
 {
     throw new NotImplementedException();
 }