private void Calculate() { // import random number generator Random rand = new Random(); //constants const int max = 52; const int min = 1; const int CardTypes = 13; //generate a random number in the deck numberGenerator: int randNum = rand.Next(min, max); //use that random number to generate a value and suit for the card int suit = randNum / CardTypes; int value = randNum % CardTypes; //Track recent cards so no duplicates are created Tuple <int, int> tmp = new Tuple <int, int>(suit, value); Dictionary <string, Tuple <int, int> > cardDictionary = CardStore.GetCardDictionary(); if (cardDictionary.ContainsValue(tmp)) { goto numberGenerator; } //If a new unique card is created store the values this.suit = suit; this.value = value; }
public void DrawCard(CardStore deck) { Card card = deck.DrawCard(); cardList.Add(card.GetImage()); int value = card.GetValue(); if (value >= 10) { value = 10; } else if (value == 0) { value = 11; this.aceCount++; } else { value++; } this.score += value; }