Пример #1
0
 private bool CanUse(EnumSuitList thisSuit, int number)
 {
     if (ThisInfo !.ExcludeList.Count == 0)
     {
         return(true);
     }
     return(!(ThisInfo.ExcludeList.Any(ThisExclude =>
     {
         if (ThisExclude.Number == 1 || ThisExclude.Number == 14)
         {
             if (number == 1 || number == 14)
             {
                 return ThisExclude.Suit == thisSuit;
             }
             else
             {
                 return false; //i think
             }
         }
         else
         {
             return ThisExclude.Number == number && ThisExclude.Suit == thisSuit;
         }
     })));
 }
        protected override async Task ComputerTurnAsync()
        {
            if (SingleInfo !.PlayerCategory != EnumPlayerCategory.Computer)
            {
                throw new BasicBlankException("The computer player can't go for anybody else on this game");
            }
            if (Test !.ComputerEndsTurn == true)
            {
                throw new BasicBlankException("The computer player was suppposed to end turn.  Rethink");
            }
            await Delay !.DelayMilli(200);

            if (SaveRoot !.ChooseSuit == true)
            {
                EnumSuitList thisSuit = _aI.SuitToChoose(SingleInfo);
                await _processes.SuitChosenAsync(thisSuit);

                return;
            }
            await Delay.DelaySeconds(.5);

            int Nums = _aI.CardToPlay(SaveRoot);

            if (Nums > 0)
            {
                await PlayCardAsync(Nums);

                return;
            }
            if (BasicData !.MultiPlayer == true)
            {
                await _gameContainer.SendDrawMessageAsync();
            }
            await DrawAsync();
        }
Пример #3
0
        public bool CanMoveAll(int whichOne)
        {
            var          thisCol      = ListValidCards(whichOne);
            EnumSuitList previousSuit = EnumSuitList.None;
            int          x            = 0;

            if (thisCol.Count != 13)
            {
                return(false);
            }
            foreach (var thisCard in thisCol)
            {
                if (x == 0)
                {
                    previousSuit = thisCard.Suit;
                }
                else if (thisCard.Suit != previousSuit)
                {
                    return(false);
                }
                x++;
            }
            TempList = thisCol;
            return(true);
        }
        public static DeckRegularDict <SolitaireCard> ListValidCardsSameSuit(this IDeckDict <SolitaireCard> givenList)
        {
            int x;
            int previousNumber = 0;
            DeckRegularDict <SolitaireCard> output = new DeckRegularDict <SolitaireCard>();
            EnumSuitList previousSuit = EnumSuitList.None;

            for (x = givenList.Count; x >= 1; x += -1)
            {
                var thisCard = givenList[x - 1];
                if (x == givenList.Count)
                {
                    previousSuit   = thisCard.Suit;
                    previousNumber = (int)thisCard.Value;
                    output.Add(thisCard);
                }
                else
                {
                    if (previousNumber + 1 == (int)thisCard.Value && thisCard.Suit == previousSuit)
                    {
                        output.Add(thisCard);
                    }
                    else
                    {
                        return(output);
                    }
                    previousNumber = (int)thisCard.Value;
                }
            }
            return(output);
        }
Пример #5
0
        public async Task SuitChosenAsync(EnumSuitList chosen)
        {
            _gameContainer.SingleInfo = _gameContainer.PlayerList !.GetWhoPlayer();
            if (_gameContainer.SingleInfo.CanSendMessage(_gameContainer.BasicData !))
            {
                await _gameContainer.Network !.SendAllAsync(mm.ChosenPiece, chosen);
            }
            _gameContainer.SaveRoot !.CurrentSuit = chosen;
            _gameContainer.SaveRoot.ChooseSuit    = false;
            var thisCard = _model !.Pile1 !.CurrentDisplayCard;

            thisCard.DisplaySuit = chosen;
            await _gameContainer.EndTurnAsync !.Invoke();
        }
Пример #6
0
        private bool HeartsValidMove(int deck)
        {
            var          heartSave = (ITrickStatusSavedClass)SaveRoot !;
            var          thisList  = SaveRoot !.TrickList;
            var          thisCard  = _gameContainer.DeckList !.GetSpecificItem(deck);
            EnumSuitList cardSuit  = thisCard.GetSuit.GetRegularSuit();

            if (thisList.Count == 0)
            {
                if (heartSave.TrickStatus == EnumTrickStatus.FirstTrick)
                {
                    var tempCard = SingleInfo !.MainHandList.OrderBy(Items => Items.GetSuit).ThenBy(Items => Items.ReadMainValue).Take(1).Single();
                    if (tempCard.Deck == deck)
                    {
                        return(true);
                    }
                    return(false);
                }
                if (heartSave.TrickStatus == EnumTrickStatus.SuitBroken)
                {
                    return(true);
                }
                if (cardSuit == EnumSuitList.Hearts)
                {
                    return(!SingleInfo !.MainHandList.Any(Items => Items.GetSuit.GetRegularSuit() != EnumSuitList.Hearts));
                }
                return(true);
            }
            var leadCard = thisList.First();

            if (leadCard.GetSuit.Equals(thisCard.GetSuit))
            {
                return(true);
            }
            DeckObservableDict <T> tempList;

            if (_trickData !.HasDummy == true)
            {
                var temps = MainContainer.Resolve <ITrickDummyHand <SU, T> >(); //if you don't have it, then will raise an error.
                tempList = temps.GetCurrentHandList();
            }
Пример #7
0
        private static void SuitPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var thisItem = (CardGraphicsXF)bindable;

            thisItem.MainObject !.Suit = (EnumSuitList)newValue;
        }
Пример #8
0
        private static void SuitValuePropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var thisItem = (DeckOfCardsXF <R>)bindable;

            thisItem.MainObject !.SuitValue = (EnumSuitList)newValue;
        }
Пример #9
0
 public static CustomBasicList <ExcludeRCard> AppendExclude(this CustomBasicList <ExcludeRCard> thisList,
                                                            EnumSuitList suit, int number)
 {
     thisList.Add(new ExcludeRCard(suit, number));
     return(thisList);
 }
        private static void SuitPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var thisItem = (CardGraphicsWPF)sender;

            thisItem.MainObject !.Suit = (EnumSuitList)e.NewValue;
        }
 }                               //i think that number is no problem.
 public ExcludeRCard(EnumSuitList suit, int number)
 {
     Suit   = suit;
     Number = number;
 }
Пример #12
0
        public async Task ChoosePieceReceivedAsync(string data)
        {
            EnumSuitList Suit = await js.DeserializeObjectAsync <EnumSuitList>(data);

            await SuitChosenAsync(Suit);
        }
Пример #13
0
 protected SolitaireCard FindCardBySuitValue(EnumCardValueList value, EnumSuitList suit)
 {
     return(DeckList.First(items => items.Value == value && items.Suit == suit));
 }
        public static void DrawCardSuit(this SKCanvas thisCanvas, EnumSuitList suitCategory, SKRect thisRect, SKPaint solidPaint, SKPaint?borderPaint)
        {
            TempPosition temps = GetTempRect(thisRect);

            if (solidPaint == null)
            {
                throw new BasicBlankException("All Cards Must Have Solid Brushes");
            }
            if (borderPaint != null && suitCategory == EnumSuitList.Clubs)
            {
                throw new BasicBlankException("Clubs can't have stroke paint currently");
            }
            if (borderPaint != null && suitCategory == EnumSuitList.Spades)
            {
                throw new BasicBlankException("Spades can't have stroke paint currently");
            }
            switch (suitCategory)
            {
            case EnumSuitList.Clubs:
            {
                SKPath thisPath  = new SKPath();        //used proportions here.  seemed to work great.
                var    firstRect = GetActualRectangle(125, 0, 150, 150, temps);
                thisPath.AddOval(firstRect, SKPathDirection.Clockwise);
                var secondRect = GetActualRectangle(0, 150, 150, 150, temps);
                thisPath.AddOval(secondRect, SKPathDirection.Clockwise);
                var thirdRect = GetActualRectangle(250, 150, 150, 150, temps);
                thisPath.AddOval(thirdRect, SKPathDirection.Clockwise);
                SKPoint point1;
                SKPoint point2;
                point1 = GetActualPoint(185, 150, temps);
                point2 = GetActualPoint(150, 200, temps);
                thisPath.MoveTo(point1);
                point1 = GetActualPoint(175, 180, temps);
                thisPath.QuadTo(point1, point2);
                point2 = GetActualPoint(150, 250, temps);
                thisPath.LineTo(point2);
                point1 = GetActualPoint(175, 270, temps);
                point2 = GetActualPoint(175, 280, temps);
                thisPath.QuadTo(point1, point2);
                point2 = GetActualPoint(150, 400, temps);
                thisPath.LineTo(point2);
                var tempLine = GetActualPoint(250, 400, temps);
                thisPath.LineTo(tempLine);
                point1 = GetActualPoint(225, 350, temps);
                point2 = GetActualPoint(225, 280, temps);
                thisPath.QuadTo(point1, point2);
                point1 = GetActualPoint(225, 270, temps);
                point2 = GetActualPoint(250, 250, temps);
                thisPath.QuadTo(point1, point2);
                point2 = GetActualPoint(250, 200, temps);
                thisPath.LineTo(point2);
                point1 = GetActualPoint(230, 180, temps);
                point2 = GetActualPoint(220, 150, temps);
                thisPath.QuadTo(point1, point2);
                thisPath.Close();
                thisCanvas.DrawPath(thisPath, solidPaint);
                break;
            }

            case EnumSuitList.Diamonds:
            {
                SKPoint[] pts = new SKPoint[4];
                pts[0] = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y);
                pts[1] = new SKPoint(thisRect.Location.X + (thisRect.Width * 3 / 4), thisRect.Location.Y + (thisRect.Height / 2));
                pts[2] = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y + thisRect.Height);
                pts[3] = new SKPoint(thisRect.Location.X + (thisRect.Width / 4), thisRect.Location.Y + (thisRect.Height / 2));
                SKPath ThisPath = new SKPath();
                ThisPath.AddLines(pts, true);
                thisCanvas.DrawPath(ThisPath, solidPaint);
                if (borderPaint == null == false)
                {
                    thisCanvas.DrawPath(ThisPath, borderPaint);
                }
                break;
            }

            case EnumSuitList.Hearts:
            {
                int avg;
                avg = System.Convert.ToInt32((thisRect.Width + thisRect.Height) / 2);
                int radius;
                radius = System.Convert.ToInt32(avg / (double)2);
                var topleftcorner  = new SKPoint(thisRect.Location.X, thisRect.Location.Y);
                var topleftsquare  = SKRect.Create(topleftcorner.X, topleftcorner.Y, radius, radius);
                var toprightsquare = SKRect.Create(topleftcorner.X + radius, topleftcorner.Y, radius, radius);
                var thisPath       = new SKPath();
                thisPath.ArcTo(topleftsquare, 135, 225, false);
                thisPath.ArcTo(toprightsquare, 180, 225, false);
                thisPath.LineTo(radius + thisRect.Location.X, avg + thisRect.Location.Y);
                thisPath.Close();
                thisCanvas.DrawPath(thisPath, solidPaint);
                if (borderPaint == null == false)
                {
                    thisCanvas.DrawPath(thisPath, borderPaint);
                }
                break;
            }

            case EnumSuitList.Spades:
            {
                var firstRect = GetActualRectangle(0, 100, 200, 200, temps);
                thisCanvas.DrawOval(firstRect, solidPaint);
                var secondRect = GetActualRectangle(200, 100, 200, 200, temps);
                thisCanvas.DrawOval(secondRect, solidPaint);
                var nextRect = GetActualRectangle(175, 175, 50, 200, temps);
                thisCanvas.DrawRect(nextRect, solidPaint);
                var tempRect = GetActualRectangle(0, 0, 400, 175, temps);
                thisCanvas.DrawTriangle(tempRect, solidPaint, null !);
                break;
            }

            default:
                throw new BasicBlankException("Must choose one of the 4 suits to draw");
            }
        }
Пример #15
0
        private static void SuitValuePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var thisItem = (DeckOfCardsWPF <R>)sender;

            thisItem.MainObject !.SuitValue = (EnumSuitList)e.NewValue;
        }