public static DeckRegularDict <SolitaireCard> ListValidCardsAlternateColors(this IDeckDict <SolitaireCard> givenList)
        {
            int x;
            int previousNumber = 0;
            DeckRegularDict <SolitaireCard> output = new DeckRegularDict <SolitaireCard>();
            EnumColorList previousColor            = EnumColorList.None;

            for (x = givenList.Count; x >= 1; x += -1)
            {
                var thisCard = givenList[x - 1];
                if (x == givenList.Count)
                {
                    previousColor  = thisCard.Color;
                    previousNumber = (int)thisCard.Value;
                    output.Add(thisCard);
                }
                else
                {
                    if (previousNumber + 1 == (int)thisCard.Value && thisCard.Color != previousColor) //i think this was the problem.
                    {
                        output.Add(thisCard);
                    }
                    else
                    {
                        return(output);
                    }
                    previousNumber = (int)thisCard.Value;
                    previousColor  = thisCard.Color;
                }
            }
            return(output);
        }
        private DeckRegularDict <HeapSolitaireCardInfo> GetFirstList()
        {
            DeckRegularDict <HeapSolitaireCardInfo> output = new DeckRegularDict <HeapSolitaireCardInfo>();
            EnumColorList newColor  = (EnumColorList)_rs.GetRandomNumber(2);
            int           newNumber = 7;

            do
            {
                if (output.Count < 13)
                {
                    if (newColor == EnumColorList.Black)
                    {
                        newColor = EnumColorList.Red;
                    }
                    else
                    {
                        newColor = EnumColorList.Black;
                    }
                    var finalCard = _cardList.First(items => (int)items.Value == newNumber && items.Color == newColor);
                    output.Add(finalCard);
                    _cardList.RemoveSpecificItem(finalCard);
                    if (output.Count == 13)
                    {
                        return(output);
                    }
                    newNumber++;
                    if (newNumber > 13)
                    {
                        newNumber = 1;
                    }
                }
            } while (true);
        }
Beispiel #3
0
        private void GenerateList()
        {
            _list.Clear();
            int x, y, z, q = 0;

            for (x = 1; x <= ThisInfo !.HowManyDecks; x++)
            {
                for (y = 0; y < ThisInfo.SuitList.Count; y++)
                {
                    for (z = ThisInfo.LowestNumber; z <= ThisInfo.HighestNumber; z++)
                    {
                        if (CanUse(ThisInfo.SuitList[y], z))
                        {
                            q++;

                            RegularSimpleCard card = new RegularSimpleCard();
                            card.Deck = q;
                            card.Suit = ThisInfo.SuitList[y];
                            if (z == 1 || z == 14)
                            {
                                PopulateAceValue();
                            }
                            else
                            {
                                Value = (EnumCardValueList)z;
                            }
                            card.Value    = Value;
                            card.Section  = x;
                            card.CardType = EnumCardTypeList.Regular;
                            if (card.Suit == EnumSuitList.Clubs || card.Suit == EnumSuitList.Spades)
                            {
                                card.Color = EnumColorList.Black;
                            }
                            else
                            {
                                card.Color = EnumColorList.Red;
                            }
                            _list.Add(card);
                        }
                    }
                }
            }
            if (ThisInfo.UseJokers == true)
            {
                for (int r = 1; r <= ThisInfo.HowManyDecks; r++)
                {
                    for (int p = 1; p <= 2; p++)
                    {
                        q++;
                        RegularSimpleCard card = new RegularSimpleCard();
                        card.Value    = EnumCardValueList.Joker;
                        card.Deck     = q;
                        card.CardType = EnumCardTypeList.Joker;
                        if (p == 1)
                        {
                            card.Color = EnumColorList.Black;
                        }
                        else
                        {
                            card.Color = EnumColorList.Red;
                        }
                        card.Section = r;
                        _list.Add(card);
                    }
                }
                EnumColorList last = EnumColorList.Red;
                int           s    = ThisInfo.HowManyDecks;
                for (int i = 0; i < ThisInfo.GetExtraJokers; i++)
                {
                    q++;
                    if (last == EnumColorList.Red)
                    {
                        last = EnumColorList.Black;
                    }
                    else
                    {
                        last = EnumColorList.Red;
                    }
                    s++;
                    if (s > ThisInfo.HowManyDecks)
                    {
                        s = 1;
                    }
                    RegularSimpleCard card = new RegularSimpleCard();
                    card.Value    = EnumCardValueList.Joker;
                    card.Deck     = q;
                    card.CardType = EnumCardTypeList.Joker;
                    card.Section  = s;
                    card.Color    = last;
                    _list.Add(card);
                }
            }
        }
Beispiel #4
0
        private static void MainColorPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var thisItem = (DeckOfCardsXF <R>)bindable;

            thisItem.MainObject !.MainColor = (EnumColorList)newValue;
        }
        public static CustomBasicList <CustomBasicList <RegularSimpleCard> > PossibleCombinations(this IDeckDict <RegularSimpleCard> thisList, EnumColorList whatColor, int maxs)
        {
            if (maxs < 3 && whatColor == EnumColorList.Red)
            {
                throw new BasicBlankException("Attack must allow 3 cards for combinations");
            }
            int mins;

            if (whatColor == EnumColorList.Red)
            {
                mins = 2;
            }
            else
            {
                mins = 1;
            }
            int x;
            CustomBasicList <int> firstList = new CustomBasicList <int>();
            var loopTo = maxs;

            for (x = mins; x <= loopTo; x++)
            {
                firstList.Add(x);
            }
            var newList = thisList.Where(items => items.Color == whatColor).ToCustomBasicList();
            CustomBasicList <CustomBasicList <RegularSimpleCard> > fullList = new CustomBasicList <CustomBasicList <RegularSimpleCard> >();

            firstList.ForEach(y =>
            {
                var thisCombo = newList.GetCombinations(y);
                fullList.AddRange(thisCombo);
            });
            return(fullList); //looks like has to return a standard list for this one.
        }
 public static CustomBasicList <CustomBasicList <RegularSimpleCard> > PossibleCombinations(this IDeckDict <RegularSimpleCard> thisList, EnumColorList whatColor)
 {
     return(thisList.PossibleCombinations(whatColor, 3));
 }
Beispiel #7
0
        private static void MainColorPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var thisItem = (DeckOfCardsWPF <R>)sender;

            thisItem.MainObject !.MainColor = (EnumColorList)e.NewValue;
        }