protected override Card[] GetDeck() { Card[] deck = new Card[DeckSize]; int counter = 0; foreach (Suite suite in ListUtilities.GetValues <Suite>()) { foreach (CardName cardName in ListUtilities.GetValues <CardName>()) { if (cardName == CardName.Ace) { deck[counter] = new Card(suite, cardName, new int[] { 14 }); } else if (cardName == CardName.Jack) { deck[counter] = new Card(suite, cardName, new int[] { 11 }); } else if (cardName == CardName.Queen) { deck[counter] = new Card(suite, cardName, new int[] { 12 }); } else if (cardName == CardName.King) { deck[counter] = new Card(suite, cardName, new int[] { 13 }); } else { int value = 0; bool parsed = int.TryParse(cardName.ToString(), out value); if (!parsed) { //potentiall log something here Console.WriteLine("Error parsing " + cardName.ToString() + " to an int value, setting value to 0"); } deck[counter] = new Card(suite, cardName, new int[] { value }); } counter++; } } return(deck); }
protected override Card[] GetDeck() { Card[] deck = new Card[DeckSize]; int counter = 0; foreach (Suite suite in ListUtilities.GetValues <Suite>()) { foreach (CardName cardName in ListUtilities.GetValues <CardName>()) { if (cardName == CardName.Ace) { deck[counter] = new Card(suite, cardName, new int[] { 1, 11 }); } else if (cardName == CardName.King || cardName == CardName.Queen || cardName == CardName.Jack) { deck[counter] = new Card(suite, cardName, new int[] { 10 }); } else { int value = 0; switch (cardName.ToString().ToLower()) { case "one": value = 1; break; case "two": value = 2; break; case "three": value = 3; break; case "four": value = 4; break; case "five": value = 5; break; case "six": value = 6; break; case "seven": value = 7; break; case "eight": value = 8; break; case "nine": value = 9; break; case "ten": value = 10; break; default: value = 0; Console.WriteLine("Error parsing " + cardName.ToString() + " to int value"); break; } deck[counter] = new Card(suite, cardName, new int[] { value }); } counter++; } } return(deck); }