Пример #1
0
 public Score(int score, string difficulty)
 {
     InitializeComponent();
     playerScore          = new PlayerScore(score);
     this.difficulty      = difficulty;
     topLabel.Content     = topLabel.Content + difficulty;
     backButton.IsEnabled = false;
 }
Пример #2
0
        public static void Main(string[] args)
        {
            string command;

            char[,] gameField  = CreateGameField();
            char[,] minesField = PlaceMines();
            int  pointsCounter = 0;
            bool gameIsOver    = true;
            List <PlayerScore> topPlayerScores = new List <PlayerScore>(6);
            int       gameFieldRow             = 0;
            int       gameFieldCol             = 0;
            const int maxPoints    = 35;
            bool      hasMaxPoints = false;

            do
            {
                if (gameIsOver)
                {
                    Console.WriteLine(
                        "Hajde da igraem na “Mini4KI”. Probvaj si kasmeta da otkriesh poleteta bez mini4ki."
                        + " Komanda 'top' pokazva klasiraneto, 'restart' po4va nova igra, 'exit' izliza i hajde 4ao!");
                    DrawGameField(gameField);
                    gameIsOver = false;
                }

                Console.Write("Daj red i kolona : ");
                command = Console.ReadLine().Trim();
                if (command.Length >= 3)
                {
                    if (int.TryParse(command[0].ToString(), out gameFieldRow) &&
                        int.TryParse(command[2].ToString(), out gameFieldCol) &&
                        gameFieldRow <= gameField.GetLength(0) &&
                        gameFieldCol <= gameField.GetLength(1))
                    {
                        command = "turn";
                    }
                }

                switch (command)
                {
                case "top":
                    PrintTopPlayers(topPlayerScores);
                    break;

                case "restart":
                    gameField  = CreateGameField();
                    minesField = PlaceMines();
                    DrawGameField(gameField);
                    break;

                case "exit":
                    Console.WriteLine("4a0, 4a0, 4a0!");
                    break;

                case "turn":
                    if (minesField[gameFieldRow, gameFieldCol] != '*')
                    {
                        if (minesField[gameFieldRow, gameFieldCol] == '-')
                        {
                            RevealPosition(gameField, minesField, gameFieldRow, gameFieldCol);
                            pointsCounter++;
                        }

                        if (maxPoints == pointsCounter)
                        {
                            hasMaxPoints = true;
                        }
                        else
                        {
                            DrawGameField(gameField);
                        }
                    }
                    else
                    {
                        gameIsOver = true;
                    }

                    break;

                default:
                    Console.WriteLine("\nGreshka! nevalidna Komanda\n");
                    break;
                }

                if (gameIsOver)
                {
                    DrawGameField(minesField);
                    Console.Write("\nHrrrrrr! Umria gerojski s {0} to4ki. " + "Daj si niknejm: ", pointsCounter);
                    string      nickName           = Console.ReadLine();
                    PlayerScore currentPlayerScore = new PlayerScore(nickName, pointsCounter);
                    if (topPlayerScores.Count < 5)
                    {
                        topPlayerScores.Add(currentPlayerScore);
                    }
                    else
                    {
                        for (int i = 0; i < topPlayerScores.Count; i++)
                        {
                            if (topPlayerScores[i].Points < currentPlayerScore.Points)
                            {
                                topPlayerScores.Insert(i, currentPlayerScore);
                                topPlayerScores.RemoveAt(topPlayerScores.Count - 1);
                                break;
                            }
                        }
                    }

                    topPlayerScores.Sort((p1, p2) => p2.PlayerName.CompareTo(p1.PlayerName));
                    topPlayerScores.Sort((p1, p2) => p2.Points.CompareTo(p1.Points));
                    PrintTopPlayers(topPlayerScores);

                    gameField     = CreateGameField();
                    minesField    = PlaceMines();
                    pointsCounter = 0;
                    gameIsOver    = false;
                }

                if (hasMaxPoints)
                {
                    Console.WriteLine("\nBRAVOOOS! Otvri 35 kletki bez kapka kryv.");
                    DrawGameField(minesField);
                    Console.WriteLine("Daj si imeto, batka: ");
                    string      name   = Console.ReadLine();
                    PlayerScore points = new PlayerScore(name, pointsCounter);
                    topPlayerScores.Add(points);
                    PrintTopPlayers(topPlayerScores);
                    gameField     = CreateGameField();
                    minesField    = PlaceMines();
                    pointsCounter = 0;
                    hasMaxPoints  = false;
                    gameIsOver    = true;
                }
            }while (command != "exit");
            Console.WriteLine("Made in Bulgaria - Uauahahahahaha!");
            Console.WriteLine("AREEEEEEeeeeeee.");
            Console.Read();
        }