示例#1
0
 public Game(int id)
 {
     Deck = new Deck(); //Creates a new deck
     Player = Player.Get(id);
     Dealer = new Hand(); //Creates a new dealer
 }
示例#2
0
 public void CalculateResult(Hand Dealer)
 {
     this.Hand.CheckHandIfBustedAndCalculatesSum(); //Calculate the sum of the players cards
     if (this.Hand.Busted == false)
     { //If the player arnt busted
         if (Dealer.Busted == false)
         { //If dealer arnt busted
             if (this.Hand.Sum == Dealer.Sum)
             { //If the player and the dealer have the same sum
                 if (this.Hand.Sum.IsBetween(17, 19))
                 {
                     this.Lose();
                 }
                 else if (this.Hand.Sum.IsBetween(20, 21))
                 {
                     this.Winnings = 0; //Player got his bet back
                 }
             }
             else if (this.Hand.Sum > Dealer.Sum && this.Hand.Busted == false)
             {
                 if (this.HasBlackJack())
                 {
                     this.BlackJack();
                 }
                 else
                 {
                     this.Win();
                 }
             }
             else
             {
                 this.Lose();
             }
         }
         else if (this.HasBlackJack())
         {
             this.Win();
         }
     }
     else
     {
         this.Lose();
     }
 }