Блэкджек Выигрышное состояние - PullRequest
0 голосов
/ 16 апреля 2020

Мне нужна помощь с небольшой проблемой. Когда я выигрываю или проигрываю, выполняются два условия, и дважды появляется окно сообщения. Делать одну победу или поражение засчитывается как две победы или поражения в моем табло. Это иногда случается, а иногда работает правильно. Я пытался вставить конечную точку, я пытался использовать if для всех из них, и я пытался использовать else if, есть ли другой способ для игры проверить только одно условие?

public void Scoring(int playerscore, int dealerscore) //scores the dealer and  player scores
    {
        //string winGame = "verloor";

        //while (winGame != "Wenner")
        //{ 
            if (dealerscore > 16) //check if dealer score is greater than 16
            {
                if (dealerscore < playerscore && playerscore > 21) //win lose conditions
                {
                    L++; //add one lost to scoreboard
                    tLose.Text = L.ToString();

                    MessageBox.Show("Dealer Wins!!", "Lost!", MessageBoxButtons.OK);
           //         winGame = "Wenner";
                    goto Einde; //if condition is met go to end marker
                }

                else if (dealerscore > playerscore && dealerscore < 22) //win lose condition
                {
                    L++;
                    tLose.Text = L.ToString();

                    MessageBox.Show("Dealer Wins!!", "Lost!", MessageBoxButtons.OK);
             //       winGame = "Wenner";
                    goto Einde;
                }

                else if (dealerscore == playerscore && playerscore < 22) // draw condition
                {
                    D++; //add one draw to scoreboard
                    tDraw.Text = D.ToString();

                    MessageBox.Show("It's a tie!!", "Draw!", MessageBoxButtons.OK);
               //     winGame = "Wenner";
                    goto Einde;
                }

                else if (dealerscore > 21 && playerscore > 21) //win lose condition
                {
                    L++;
                    tLose.Text = L.ToString();

                    MessageBox.Show("Dealer Wins!!", "Lost!", MessageBoxButtons.OK);
                 //   winGame = "Wenner"; 
                    goto Einde;
                }

                else if (playerscore > 21) //lose condition
                {
                    L++;
                    tLose.Text = L.ToString();

                    MessageBox.Show("Dealer Wins!!", "Lost!", MessageBoxButtons.OK);
                   // winGame = "Wenner"; 
                    goto Einde;
                }

                else if (dealerscore < playerscore && playerscore < 22) //win lose condition
                {
                    W++; //add win to scoreboard
                    tWin.Text = W.ToString();

                    MessageBox.Show("You Win!!", "Winner!", MessageBoxButtons.OK);
                    //winGame = "Wenner"; 
                    goto Einde;
                }

                else if (dealerscore == playerscore && dealerscore > 21) //win los condition
                {
                    L++;
                    tLose.Text = L.ToString();

                    MessageBox.Show("Dealer Wins!!", "Lost!", MessageBoxButtons.OK);
                    //winGame = "Wenner"; 
                    goto Einde;
                }

                else if (dealerscore > 21 && playerscore < 22) //win lose condition
                {
                    W++;
                    tWin.Text = W.ToString();

                    MessageBox.Show("You Win!!", "Winner!", MessageBoxButtons.OK);
                    //winGame = "Wenner"; 
                    goto Einde;
                }
                else
                {
                    MessageBox.Show("Error", "Error", MessageBoxButtons.OK);
                }

            }
        Einde:; //end marker
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...