예제 #1
0
        //clear()
        public static void EndOfTheGameInitialization(string word)
        {
            Console.WriteLine("You won with {0} mistakes.", num2);
            RevealGuessedLetters(word);
            Console.WriteLine();
            int positionOfTheFirstFreePositionInTheScoereboard = 4;

            for (int i = 0; i < 4; i++)
            {
                if (CommandExecuter.scoreboard[i] == null)
                {
                    positionOfTheFirstFreePositionInTheScoereboard = i;
                    break;
                }
            }

            if ((CommandExecuter.scoreboard[positionOfTheFirstFreePositionInTheScoereboard] == null || //for free position
                 num2 <= CommandExecuter.scoreboard[positionOfTheFirstFreePositionInTheScoereboard].NumberOfMistakes) && //when the 4th pos is not free)
                flag == false)
            {
                Console.WriteLine("Please enter your name for the top scoreboard:");
                string playerName = Console.ReadLine();
                CommandExecuter.PlayerMistakes newResult = new CommandExecuter.PlayerMistakes(playerName, num2);
                CommandExecuter.scoreboard[positionOfTheFirstFreePositionInTheScoereboard] = newResult;
                for (int i = positionOfTheFirstFreePositionInTheScoereboard; i > 0; i--)
                {
                    if (CommandExecuter.scoreboard[i].Compare(CommandExecuter.scoreboard[i - 1]) < 0)
                    {
                        //swap
                        CommandExecuter.PlayerMistakes temp = CommandExecuter.scoreboard[i];
                        CommandExecuter.scoreboard[i]     = CommandExecuter.scoreboard[i - 1];
                        CommandExecuter.scoreboard[i - 1] = temp;
                    }
                }
            }
            num1 = 0;
            num2 = 0;



            flag = false;
        }
        //clear()
        public static void EndOfTheGameInitialization(string word)
        {
            Console.WriteLine("You won with {0} mistakes.", num2);
            RevealGuessedLetters(word);
            Console.WriteLine();
            int positionOfTheFirstFreePositionInTheScoereboard = 4;
            for (int i = 0; i < 4; i++)
                if (CommandExecuter.scoreboard[i] == null)
                {
                    positionOfTheFirstFreePositionInTheScoereboard = i;
                    break;
                }

            if ((CommandExecuter.scoreboard[positionOfTheFirstFreePositionInTheScoereboard] == null //for free position
                  || num2 <= CommandExecuter.scoreboard[positionOfTheFirstFreePositionInTheScoereboard].NumberOfMistakes)//when the 4th pos is not free)
                  && flag == false)
                {

                    Console.WriteLine("Please enter your name for the top scoreboard:");
                    string playerName = Console.ReadLine();
                    CommandExecuter.PlayerMistakes newResult = new CommandExecuter.PlayerMistakes(playerName, num2);
                    CommandExecuter.scoreboard[positionOfTheFirstFreePositionInTheScoereboard] = newResult;
                    for (int i = positionOfTheFirstFreePositionInTheScoereboard; i > 0; i--)
                        if (CommandExecuter.scoreboard[i].Compare(CommandExecuter.scoreboard[i-1]) < 0)
                        {
                            //swap
                            CommandExecuter.PlayerMistakes temp = CommandExecuter.scoreboard[i];
                            CommandExecuter.scoreboard[i] =  CommandExecuter.scoreboard[i-1];
                            CommandExecuter.scoreboard[i-1] = temp;
                        }
                }
            num1 = 0;
            num2 = 0;

            flag = false;
        }