Ejemplo n.º 1
0
        private void btnSurr_Click(object sender, RoutedEventArgs e)
        {
            //textBox.Text = GetNumber();
            targetNumber = GetNumber();
            resultType   = "SURR";
            var game = new EndGame(moves, resultType, targetNumber);

            this.Frame.Navigate(typeof(VictoryPage), game);
        }
Ejemplo n.º 2
0
        //find bulls and cows
        private void GetBullsAndCows()
        {
            string playerInput = textBox.Text;

            int[] playerDigits = playerInput.ToCharArray().Select(d => Convert.ToInt32(d) - 48).ToArray();

            int bulls = 0;
            int cows  = 0;

            for (int i = 0; i < playerDigits.Length; i++)
            {
                if (numbers.Contains(playerDigits[i]))
                {
                    if (numbers[i] == playerDigits[i])
                    {
                        bulls++;
                    }
                    else
                    {
                        cows++;
                    }
                }
            }
            moves++;

            ShowResult(moves, playerInput, bulls, cows);

            if (bulls == 4)
            {
                targetNumber = GetNumber();
                resultType   = "WIN";
                var game = new EndGame(moves, resultType, targetNumber);
                this.Frame.Navigate(typeof(VictoryPage), game);
            }
            if (moves == 10)
            {
                targetNumber = GetNumber();
                resultType   = "LOSE";
                var game = new EndGame(moves, resultType, targetNumber);
                this.Frame.Navigate(typeof(VictoryPage), game);
            }
        }