public void LoadList(DominosRegularVMData model, IGamePackageResolver resolver)
        {
            _model = model;
            IProportionImage thisP = resolver.Resolve <IProportionImage>(ts.TagUsed);

            Text      = "Display";
            _thisGrid = new Grid();
            Grid finalGrid = new Grid();

            _dominoList = _model.GameBoard1 !.DominoList;
            _dominoList.CollectionChanged += DominoCollectionChange;
            if (_dominoList.Count != 3)
            {
                throw new BasicBlankException("Only 3 dominos are supported");
            }
            if (_dominoList.First().DefaultSize.Width == 0)
            {
                throw new BasicBlankException("The width can never be 0 for dominos");
            }
            SKSize thisSize = _dominoList.First().DefaultSize.GetSizeUsed(thisP.Proportion);
            int    pixels   = (int)thisSize.Width / 2;

            for (int x = 0; x < 4; x++)
            {
                AddPixelColumn(_thisGrid, pixels);
            }
            RepopulateList();
            SetUpMarginsOnParentControl(_thisGrid);
            finalGrid.Children.Add(ThisDraw);
            finalGrid.Children.Add(_thisGrid);
            Content = finalGrid;
        }
示例#2
0
        public D DrawCard()
        {
            if (_objectList.Count == 0)
            {
                throw new BasicBlankException("Cannot draw a card because there are no more cards left");
            }
            D thisCard;

            thisCard = _objectList.First();
            _objectList.RemoveFirstItem();
            thisCard.IsUnknown = false;
            return(thisCard);
        }
        public void Init(BasicTrickAreaObservable <SU, TC> thisMod, string tagUsed)
        {
            if (thisMod.CardList.Count != 2)
            {
                throw new BasicBlankException("Only 2 are supported for 2 player trick taking games.  Otherwise, try using another trick taking control");
            }
            BindingContext = thisMod;
            _thisMod       = thisMod;
            _cardList      = thisMod.CardList;
            _cardList.CollectionChanged += CardList_CollectionChanged;
            float startTop;
            float firstLeft;

            startTop  = 3;
            firstLeft = 3;
            float cardTop;

            cardTop = 33; // if changing, will be here
            var thisLabel = GetLabel("Your Card Played");

            _thisCanvas.Children.Add(thisLabel);
            var thisRect = new Rectangle(firstLeft, firstLeft, thisLabel.WidthRequest, thisLabel.HeightRequest);

            AbsoluteLayout.SetLayoutBounds(thisLabel, thisRect);
            GW      thisCard = new GW();
            Binding thisBind = new Binding(nameof(BasicTrickAreaObservable <SU, TC> .CardSingleClickCommand));

            thisBind.Source = thisMod;                                      // has to be that one
            thisCard.SetBinding(GraphicsCommand.CommandProperty, thisBind); //i think
            thisCard.SendSize(tagUsed, _cardList.First());                  //hopefully this simple.
            thisCard.CommandParameter = _cardList.First();                  // this needs to be the parameter.
            _thisCanvas.Children.Add(thisCard);
            thisRect = new Rectangle(10, cardTop, thisCard.ObjectSize.Width, thisCard.ObjectSize.Height);
            AbsoluteLayout.SetLayoutBounds(thisCard, thisRect);
            thisLabel = GetLabel("Opponent Card Played");
            _thisCanvas.Children.Add(thisLabel);
            thisRect = new Rectangle(150, startTop, thisLabel.WidthRequest, thisLabel.HeightRequest);
            AbsoluteLayout.SetLayoutBounds(thisLabel, thisRect);
            thisCard = new GW();
            thisCard.SendSize(tagUsed, _cardList.Last()); //hopefully this simple.
            _thisCanvas.Children.Add(thisCard);
            thisRect = new Rectangle(170, cardTop, thisCard.ObjectSize.Width, thisCard.ObjectSize.Height);
            AbsoluteLayout.SetLayoutBounds(thisCard, thisRect);
            Binding FinalBind = new Binding(nameof(BasicTrickAreaObservable <SU, TC> .Visible));

            SetBinding(IsVisibleProperty, FinalBind);
            Content = _thisCanvas; // this is the content for this page.
        }
        public void ScatterPieces()
        {
            int maxPointx;
            int maxPointy;

            if (MaxSize.Width == 0 || MaxSize.Height == 0)
            {
                throw new Exception("Must specify height and width in order to scatter the pieces");
            }
            if (RemainingList.Count == 0)
            {
                return;// nothing to scatter anymore.
            }
            D tempObject;

            tempObject = RemainingList.First();
            SKSize NewSize = tempObject.DefaultSize.GetSizeUsed(_thisI.Proportion);

            maxPointx = (int)MaxSize.Width - (int)NewSize.Width - 3;
            maxPointy = (int)MaxSize.Height - (int)NewSize.Height - 3;
            foreach (var thisCard in RemainingList)
            {
                var Locx = _rs.GetRandomNumber(maxPointx, 3);
                var Locy = _rs.GetRandomNumber(maxPointy, 20);

                thisCard.Location = new SKPoint(Locx, Locy); // you need location now.
            }
        }
        private int WhoWonTrick(DeckObservableDict <RoundsCardGameCardInformation> thisCol)
        {
            var leadCard    = thisCol.First();
            var thisCard    = thisCol.Last();
            var tempCard    = _model !.Pile1 !.GetCardInfo();
            var trumpSuit   = tempCard.Suit;
            var trumpNumber = tempCard.Value;

            if (thisCard.Value == trumpNumber)
            {
                return(WhoTurn);
            }
            if (leadCard.Value == trumpNumber)
            {
                return(leadCard.Player);
            }
            if (thisCard.Suit == trumpSuit && thisCard.Suit != leadCard.Suit)
            {
                return(WhoTurn);
            }
            if (leadCard.Suit == trumpSuit && thisCard.Suit != leadCard.Suit)
            {
                return(leadCard.Player);
            }
            if (thisCard.Suit == leadCard.Suit)
            {
                if (thisCard.Value > leadCard.Value)
                {
                    return(WhoTurn);
                }
            }
            return(leadCard.Player);
        }
        public void LoadList(PlayerBoardObservable <TR> thisMod)
        {
            _thisMod  = thisMod;
            _cardList = thisMod.CardList;
            _cardList.CollectionChanged += CardList_CollectionChanged;
            if (thisMod.Game == PlayerBoardObservable <TR> .EnumGameList.None)
            {
                throw new BasicBlankException("Must choose Skuck or Horseshoes");
            }
            if (_cardList.Count == 0)
            {
                throw new BasicBlankException("Must have cardlist already");
            }
            _thisGrid = new Grid();
            GamePackageDIContainer thisC     = Resolve <GamePackageDIContainer>();
            IProportionImage       thisImage = thisC.Resolve <IProportionImage>(ts.TagUsed);
            SKSize thisSize = _cardList.First().DefaultSize;
            SKSize usedSize = thisSize.GetSizeUsed(thisImage.Proportion);
            var    pixels   = usedSize.Height / 2;
            int    x;
            var    loopTo = _cardList.Count;

            for (x = 1; x <= loopTo; x++)
            {
                GridHelper.AddPixelRow(_thisGrid, (int)pixels);
            }
            GridHelper.AddPixelRow(_thisGrid, (int)pixels);
            pixels = usedSize.Width + 6;
            for (x = 1; x <= 4; x++)
            {
                GridHelper.AddPixelColumn(_thisGrid, (int)pixels);
            }
            PopulateControls();
            Content = _thisGrid;
        }
示例#7
0
        private int WhoWonTrick(DeckObservableDict <SkuckCardGameCardInformation> thisCol)
        {
            if (thisCol.Count != 2)
            {
                throw new BasicBlankException("The trick list must have 2 cards");
            }
            var leadCard  = thisCol.First();
            int begins    = leadCard.Player;
            var otherCard = thisCol.Last();

            if (otherCard.Suit == SaveRoot !.TrumpSuit && leadCard.Suit != SaveRoot.TrumpSuit && CanConsiderTrump(otherCard) == true)
            {
                return(WhoTurn);
            }
            if (leadCard.Suit == SaveRoot.TrumpSuit && otherCard.Suit != SaveRoot.TrumpSuit && CanConsiderTrump(otherCard) == true)
            {
                return(begins);
            }
            if (leadCard.Suit == otherCard.Suit)
            {
                if (otherCard.Value > leadCard.Value)
                {
                    return(WhoTurn);
                }
            }
            return(begins);
        }
        public void Init(BasicTrickAreaObservable <SU, TC> thisMod, string tagUsed)
        {
            if (thisMod.CardList.Count != 2)
            {
                throw new BasicBlankException("Only 2 are supported for 2 player trick taking games.  Otherwise, try using another trick taking control");
            }
            DataContext = thisMod;
            _thisMod    = thisMod;
            _cardList   = thisMod.CardList;
            _cardList.CollectionChanged += CardList_CollectionChanged;
            float startTop;
            float firstLeft;

            startTop  = 3;
            firstLeft = 3;
            float cardTop;

            cardTop = 33; // if changing, will be here
            var thisLabel = GetLabel("Your Card Played");

            _thisCanvas.Children.Add(thisLabel);
            Canvas.SetLeft(thisLabel, firstLeft);
            Canvas.SetTop(thisLabel, startTop);
            GW      thisCard = new GW();
            Binding thisBind = new Binding(nameof(BasicTrickAreaObservable <SU, TC> .CardSingleClickCommand));

            thisBind.Source = thisMod;                                                    // has to be that one
            thisCard.SetBinding(BaseDeckGraphicsWPF <TC, GC> .CommandProperty, thisBind); //i think
            thisCard.SendSize(tagUsed, _cardList.First());                                //hopefully this simple.
            thisCard.CommandParameter = _cardList.First();                                // this needs to be the parameter.
            _thisCanvas.Children.Add(thisCard);
            Canvas.SetTop(thisCard, cardTop);
            Canvas.SetLeft(thisCard, 10); // its manually done.
            thisLabel = GetLabel("Opponent Card Played");
            _thisCanvas.Children.Add(thisLabel);
            Canvas.SetLeft(thisLabel, 250); // try 150.  can always adjust as needed
            Canvas.SetTop(thisLabel, startTop);
            thisCard = new GW();
            thisCard.SendSize(tagUsed, _cardList.Last()); //hopefully this simple.
            _thisCanvas.Children.Add(thisCard);
            Canvas.SetTop(thisCard, cardTop);
            Canvas.SetLeft(thisCard, 270);
            Binding FinalBind = GetVisibleBinding(nameof(BasicTrickAreaObservable <SU, TC> .Visible)); //hopefully no problem (?)

            SetBinding(VisibilityProperty, FinalBind);
            Content = _thisCanvas; // this is the content for this page.
        }
示例#9
0
 public void AddRestOfDeck(IDeckDict <D> currentList)
 {
     if (currentList.ObjectExist(_objectList.First().Deck))
     {
         _objectList.RemoveFirstItem(); //try to remove the first item.  hopefully does not cause another issue.
     }
     _objectList.AddRange(currentList);
     _previousNum = _objectList.Count; // so far should be fine
 }
        private void ResetCards(bool wasUpdate)
        {
            var thisCard = GetCard(0);

            thisCard.BindingContext   = null;
            thisCard.BindingContext   = _cardList.First();
            thisCard.CommandParameter = _cardList.First();
            if (wasUpdate == false)
            {
                thisCard.IsUnknown = true;
            }
            thisCard = GetCard(1);
            thisCard.BindingContext = null;
            thisCard.BindingContext = _cardList.Last();
            if (wasUpdate == false)
            {
                thisCard.IsUnknown = true; // maybe had to do manually
            }
            thisCard.CommandParameter = _cardList.Last();
        }
示例#11
0
        private int WhoWonTrick(DeckObservableDict <GalaxyCardGameCardInformation> thisCol)
        {
            var leadCard = thisCol.First();
            var tempList = thisCol.ToRegularDeckDict();

            tempList.RemoveSpecificItem(leadCard);
            if (!tempList.Any(items => items.Suit == leadCard.Suit && items.Value > leadCard.Value))
            {
                return(leadCard.Player);
            }
            return(WhoTurn);
        }
示例#12
0
        private void PopulateControls()
        {
            _thisGrid !.ColumnDefinitions.Clear();
            _thisGrid.Children.Clear();
            if (_cardList !.Count == 0)
            {
                return;
            }
            var pixels = _widthUsed / 4;
            int totals = _cardList.Count + 3;

            totals.Times(x => AddPixelColumn(_thisGrid, (int)pixels));
            int y, m;

            if (_isReversed)
            {
                y = _cardList.Count;
                //d = -1;
                m = 0;
            }
            else
            {
                y = 0;
                //d = 1;
                m = _cardList.Count;
            }
            _cardList.ForEach(thisCard =>
            {
                var thisGraphics = GetNewCard(thisCard);
                AddControlToGrid(_thisGrid, thisGraphics, 0, y);
                Grid.SetColumnSpan(thisGraphics, 4);
                if (_isReversed)
                {
                    y--;
                }
                else
                {
                    y++;
                }
            });
            if (_isReversed)
            {
                _currentCard = _cardList.Last();
            }
            else
            {
                _currentCard = _cardList.First();
            }
            _currentCard.IsSelected = _thisMod !.IsSelected;
        }
        private int WhoWonTrick(DeckObservableDict <GermanWhistCardInformation> thisCol)
        {
            GermanWhistCardInformation leadCard = thisCol.First();
            var thisCard = thisCol.Last();

            if (thisCard.Suit == SaveRoot !.TrumpSuit && leadCard.Suit != SaveRoot.TrumpSuit)
            {
                return(WhoTurn);
            }
            if (leadCard.Suit == SaveRoot.TrumpSuit && thisCard.Suit != SaveRoot.TrumpSuit)
            {
                return(leadCard.Player);
            }
            if (thisCard.Suit == leadCard.Suit)
            {
                if (thisCard.Value > leadCard.Value)
                {
                    return(WhoTurn);
                }
            }
            return(leadCard.Player);
        }
示例#14
0
        private int WhoWonTrick(DeckObservableDict <SixtySix2PlayerCardInformation> thisCol)
        {
            var leadCard = thisCol.First();
            var thisCard = thisCol.Last();

            if (thisCard.Suit == SaveRoot !.TrumpSuit && leadCard.Suit != SaveRoot.TrumpSuit)
            {
                return(WhoTurn);
            }
            if (leadCard.Suit == SaveRoot.TrumpSuit && thisCard.Suit != SaveRoot.TrumpSuit)
            {
                return(leadCard.Player);
            }
            if (thisCard.Suit == leadCard.Suit)
            {
                if (thisCard.PinochleCardValue > leadCard.PinochleCardValue)
                {
                    return(WhoTurn);
                }
            }
            return(leadCard.Player);
        }
        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;
        }