public Luck GetChanceCard() { var random = new Random(); Luck cardToReturn = null; var cardFoundAtIndex = false; if (ChanceCards.Count > 0) { while (!cardFoundAtIndex) { try { // Get a random card var randomCard = random.Next(0, 15); cardToReturn = (Luck)ChanceCards[randomCard]; // Remove the card from the deck ChanceCards.Remove(cardToReturn); cardFoundAtIndex = true; } catch (ArgumentOutOfRangeException) { // If an error was thrown it's because the index from the // random number doesn't exist anymore, so a card wasn't found // and we need to try again (there is a card left // in the collection otherwise we wouldn't be in this codeblock) cardFoundAtIndex = false; } } } return(cardToReturn); }
public void AddCommunityChestCard(Luck communityChestCard) { CommunityChestCards.Add(communityChestCard); }
public void AddChanceCard(Luck chanceCard) { ChanceCards.Add(chanceCard); }
public void AddCommunityChestCard(Luck communityChestCard) { CommunityChestCards.Add(communityChestCard); }
public void AddChanceCard(Luck chanceCard) { ChanceCards.Add(chanceCard); }