Beispiel #1
0
        //Method to compile user and computer number combinations. Unlock Button directs to this class.
        public async Task SetCombNums(List <int> inputNums)
        {
            //sets user combination input
            List <string> apiNums  = new List <string>();
            List <int>    userNums = inputNums;

            //Initiates Number Model to call API for random combination
            //NumberModel nm = new NumberModel();
            apiNums = NumberModel.LoadNumber();

            await CombCheck.RunCheck(apiNums, userNums);
        }
        //Unlock Button - Player to submit combination guess---------------
        private async void Unlock_Btn(object sender, RoutedEventArgs e)
        {
            List <int>    inputNums = new List <int>();
            List <string> inputText = new List <string>();
            int           error     = 0;

            //Creates a list of user combination input
            inputText.Add(num1Input1.Text);
            inputText.Add(num2Input2.Text);
            inputText.Add(num3Input3.Text);
            inputText.Add(num4Input4.Text);

            foreach (string item in inputText)
            {
                if (!string.IsNullOrWhiteSpace(item))
                {
                    inputNums.Add(int.Parse(item));
                }
                else
                {
                    //If player leaves an input blank or does not comply with rules,
                    //will flag to notify player try re-entering values
                    error++;
                }
            }

            if (error == 0)
            {
                //Pass inputs to combination check class
                CombCheck eval = new CombCheck();
                await eval.SetCombNums(inputNums);

                this.Hide();
            }
            else
            {
                MessageBox.Show("There are " + error + " input errors.  Make sure to input a number from 0 to 7 in all placeholders.");
            }
        }