Exemplo n.º 1
0
        public void WhoIsTheWinner()
        {
            UserHand winnerHand = new UserHand();

            winnerHand.Cards.Add(new Card(Color.CLUBS, Name.TWO));



            foreach (var playerItem in MyUser.UserHands)
            {
                if (playerItem.GetValue() <= 21)
                {
                    if (playerItem.GetValue() > winnerHand.GetValue())
                    {
                        MyGame.Winner = MyUser;
                        winnerHand    = playerItem;
                    }
                    else if (playerItem.GetValue() == winnerHand.GetValue())
                    {
                        MyGame.Winner = MyUser;
                        winnerHand    = playerItem;
                    }
                }
            }

            if (Bank.UserHands[0].GetValue() <= 21)
            {
                if (Bank.UserHands[0].GetValue() > winnerHand.GetValue())
                {
                    MyGame.Winner = Bank;
                    winnerHand    = Bank.UserHands[0];
                }
            }
            EndGame(winnerHand);
        }
Exemplo n.º 2
0
 public void EndGame(UserHand winnerHand)
 {
     //player win
     if (MyGame.Winner == MyUser)
     {
         UpdateStack(winnerHand.Bet * 2.5);
         foreach (var item in MyUser.UserHands)
         {
             if (item != winnerHand)
             {
                 UpdateStack(-item.Bet);
             }
         }
         this.dialog = new MessageDialog("Vous avez gagné : " + winnerHand.Bet * 2.5);
     }
     //player loose
     else if (MyGame.Winner == Bank || MyGame.Winner == null)
     {
         Double currentBet = 0;
         foreach (var item in MyUser.UserHands)
         {
             UpdateStack(-item.Bet);
             currentBet += item.Bet;
         }
         UpdateStack(-winnerHand.Bet);
         this.dialog = new MessageDialog("Vous avez perdu : " + -winnerHand.Bet);
     }
     // check assurance
     if (MyGame.Winner == Bank && winnerHand.GetValue() == 21)
     {
         UpdateStack(MyUser.Assurance);
         this.dialog = new MessageDialog("Votre assurance vous rapporte : " + MyUser.Assurance);
     }
     RestartTextBox(this.dialog);
 }