public int CardNeeded(int position) { RegularRummyCard thisCard; if (_setType == EnumWhatSets.kinds || position == 1) { thisCard = HandList.First(); } else { thisCard = HandList.Last(); } int x; if (_setType == EnumWhatSets.kinds) { if (HandList.Count == 4) { return(0); //because all 4 are taken. } for (x = 1; x <= 4; x++) { if (HandList.Any(y => y.Suit == (EnumSuitList)x) == false) { return(_gameContainer.DeckList.Single(y => y.Suit == (EnumSuitList)x && y.Value == thisCard.Value).Deck); } } throw new BasicBlankException("Cannot find the card needed for kinds"); } if (position == 1) { if (thisCard.SecondNumber == EnumCardValueList.LowAce) //since i don't know which is which. needs to cover both cases. { return(0); } EnumCardValueList LowerValue; LowerValue = thisCard.Value - 1; return(_gameContainer.DeckList.Single(x => x.SecondNumber == LowerValue && x.Suit == thisCard.Suit).Deck); } if (thisCard.Value == EnumCardValueList.HighAce) //has to lean towards low. if i do something else, i risk breaking other rummy games. { return(0); //because nothing higher than high ace. } EnumCardValueList higherValue = thisCard.Value + 1; return(_gameContainer.DeckList.Single(Items => Items.Value == higherValue && Items.Suit == thisCard.Suit).Deck); //hopefully this simple. }
public int CalculateScore(BlackjackMainViewModel model) { if (model.SelectedYet == false) { if (SecondCard !.Points == 0) { throw new BasicBlankException("Cannot have 0 points. Find out what happened"); } return(SecondCard.Points); } if (_mVarComputer == false) { if (HandList.Any(Items => Items.Points == 0)) { throw new BasicBlankException("A card cannot be worth 0 points. find out what happened"); } } return(HandList.Sum(Items => Items.Points)); }