public bool CanExpand(RegularRummyCard thisCard) { if (thisCard.IsObjectWild == true) { return(true); } EnumCardValueList numberNeeded = HandList.First(items => items.IsObjectWild == false).Value; return(thisCard.Value == numberNeeded); }
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. }
private bool IsMultiMove(CribbageCombos thisCombo, IDeckDict <CribbageCard> thisCol) { var newCol = thisCol.ToRegularDeckDict(); newCol.Add(StartCard()); var whatNewRummy = _rummys !.WhatNewRummy(newCol, thisCombo.NumberInStraight, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Runs, false); if (whatNewRummy.Count == 0) { return(false); } if (whatNewRummy.Count > thisCombo.NumberInStraight) { return(false); } whatNewRummy.ForEach(thisCard => thisCard.HasUsed = true); EnumCardValueList firstNumber = whatNewRummy.First().Value; EnumCardValueList secondNumber = whatNewRummy.Last().Value; var lastTemp = newCol.ToRegularDeckDict(); lastTemp.KeepConditionalItems(items => items.Value >= firstNumber || items.Value <= secondNumber); newCol.Clear(); newCol.AddRange(lastTemp); whatNewRummy = _rummys.WhatNewRummy(newCol, thisCombo.NumberForKind, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Sets, false); if (whatNewRummy.Count == 0 || whatNewRummy.Count > thisCombo.NumberForKind) { thisCol.ForEach(thisCard => thisCard.HasUsed = false); StartCard().HasUsed = false; return(false); } if (thisCombo.DoublePairNeeded == true) { lastTemp.KeepConditionalItems(items => items.Value != whatNewRummy.First().Value); newCol.Clear(); newCol.AddRange(lastTemp); whatNewRummy = _rummys.WhatNewRummy(newCol, thisCombo.NumberForKind, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Sets, false); if (whatNewRummy.Count == 0 || whatNewRummy.Count > thisCombo.NumberForKind) { thisCol.ForEach(thisCard => thisCard.HasUsed = false); StartCard().HasUsed = false; return(false); } whatNewRummy.ForEach(thisCard => thisCard.HasUsed = true); } return(true); }
private static void CardValuePropertyChanged(BindableObject bindable, object oldValue, object newValue) { var thisItem = (CardGraphicsXF)bindable; thisItem.MainObject !.CardValue = (EnumCardValueList)newValue; }
private static void DisplayValuePropertyChanged(BindableObject bindable, object oldValue, object newValue) { var ThisItem = (DeckOfCardsXF <R>)bindable; ThisItem.MainObject !.DisplayValue = (EnumCardValueList)newValue; }
private static void CardValuePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var thisItem = (CardGraphicsWPF)sender; thisItem.MainObject !.CardValue = (EnumCardValueList)e.NewValue; }
protected SolitaireCard FindCardBySuitValue(EnumCardValueList value, EnumSuitList suit) { return(DeckList.First(items => items.Value == value && items.Suit == suit)); }
private Task AskList_ItemClickedAsync(EnumCardValueList piece) { _model.CardYouAsked = piece; _model.AskList !.SelectSpecificItem(piece); //try this. return(Task.CompletedTask); }
private static void DisplayValuePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var thisItem = (DeckOfCardsWPF <R>)sender; thisItem.MainObject !.DisplayValue = (EnumCardValueList)e.NewValue; }
private int WhoWonTrick(DeckObservableDict <HorseshoeCardGameCardInformation> thisCol) { if (thisCol.Count != 4) { throw new BasicBlankException("Must have 4 cards for the trick list to see who won"); } var thisCard = thisCol.First(); int begins = thisCard.Player; EnumCardValueList nums = thisCard.Value; if (thisCol.All(Items => Items.Value == nums)) { return(begins); } DeckRegularDict <HorseshoeCardGameCardInformation> playerStarted = new DeckRegularDict <HorseshoeCardGameCardInformation>(); DeckRegularDict <HorseshoeCardGameCardInformation> otherPlayer = new DeckRegularDict <HorseshoeCardGameCardInformation>(); playerStarted.Add(thisCol.First()); playerStarted.Add(thisCol.Last()); otherPlayer.Add(thisCol[1]); otherPlayer.Add(thisCol[2]); HorseshoeCardGameCardInformation firstCard = playerStarted.First(); HorseshoeCardGameCardInformation secondCard = playerStarted.Last(); EnumSuitList whichSuit = firstCard.Suit; EnumCardValueList pairAmount; EnumCardValueList highestSuitNumber = EnumCardValueList.None; int possibleWinPlayer = 0; if (firstCard.Value == secondCard.Value) { pairAmount = firstCard.Value; } else { pairAmount = EnumCardValueList.None; var card = thisCol.Where(x => x.Suit == whichSuit).OrderByDescending(x => x.Value).Take(1).Single(); highestSuitNumber = card.Value; possibleWinPlayer = card.Player; //if (secondCard.Value > firstCard.Value && secondCard.Suit == firstCard.Suit) // highestSuitNumber = secondCard.Value; //else if (secondCard.Suit == firstCard.Suit) // highestSuitNumber = firstCard.Value; } firstCard = otherPlayer.First(); secondCard = otherPlayer.Last(); if (firstCard.Value != secondCard.Value && pairAmount > 0) { return(begins); } if (firstCard.Value == secondCard.Value) { if (firstCard.Value > pairAmount) { if (begins == 1) { return(2); } return(1); } } if (pairAmount > 0) { return(begins); } if (possibleWinPlayer == 0) { throw new BasicBlankException("Sombody had to win it"); } return(possibleWinPlayer); //if (firstCard.Suit == whichSuit) //{ // if (firstCard.Value > highestSuitNumber) // { // if (begins == 1) // return 2; // return 1; // } //} //if (secondCard.Suit == whichSuit) //{ // if (secondCard.Value > highestSuitNumber) // { // if (begins == 1) // return 2; // return 1; // } //} //return begins; }