コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        private void ShowNextCardInPile()
        {
            GenericCard f = (GenericCard)spCards.Children[0];

            f.Visibility = Visibility.Visible;
            f.Flip();
        }
コード例 #2
0
        public void RemoveCardFromDeck()
        {
            SetUpTestDeck();
            var cardToRemove = new GenericCard();

            deck.AddCardToDeck(cardToRemove);

            deck.RemoveCardFromDeck(cardToRemove.Id);

            Assert.AreEqual(20, deck.Cards.Count);
            Assert.IsFalse(deck.Cards.Contains(cardToRemove));
        }
コード例 #3
0
        private void Discard(GenericCard target)
        {
            Panel _parentT = (Panel)VisualTreeHelper.GetParent(target);

            if (target.Symbol.Equals("10"))
            {
                _parentT.Children.Remove(target);

                target.RenderTransform = new RotateTransform(30.0);

                cnvDiscard.Children.Add(target);
            }
        }
コード例 #4
0
        public void SetUp()
        {
            var info = new GenericCardInfo
            {
                Name                 = "testing card",
                LoreText             = "a short description",
                AbilityText          = "get a free card",
                Size                 = CardSize.American,
                Type                 = GenericCardTestType.Fire,
                MainImage            = "image.png",
                BackImage            = "back.png",
                FrontBackgroundImage = "front_background.png"
            };

            _card = new GenericCard(info);
        }
コード例 #5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            GenericCard card = value is GenericCard ? (GenericCard)value : null;

            if (card == null)
            {
                return(null);
            }

            if (card.Type == Enums.CardType.Item)
            {
                return(card.GoldCost);
            }
            else
            {
                return(card.ManaCost);
            }
        }
コード例 #6
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            GenericCard card = value is GenericCard ? (GenericCard)value : null;

            if (card == null)
            {
                return(null);
            }

            switch (card.Type)
            {
            case CardType.Creep:
                return(new BitmapImage(new Uri("pack://application:,,,/ArtifactAPI.Example;component/Images/card_type_creep.png", UriKind.Absolute)));

            case CardType.Item:
            {
                return(ConvertFromSubtype(card.SubType));
            }

            case CardType.Armor:
                return(new BitmapImage(new Uri("pack://application:,,,/ArtifactAPI.Example;component/Images/card_type_armor.png", UriKind.Absolute)));

            case CardType.Health:
                return(new BitmapImage(new Uri("pack://application:,,,/ArtifactAPI.Example;component/Images/card_type_health.png", UriKind.Absolute)));

            case CardType.Improvement:
                return(new BitmapImage(new Uri("pack://application:,,,/ArtifactAPI.Example;component/Images/card_type_improvement.png", UriKind.Absolute)));

            case CardType.Spell:
                return(new BitmapImage(new Uri("pack://application:,,,/ArtifactAPI.Example;component/Images/card_type_spell.png", UriKind.Absolute)));

            case CardType.Weapon:
                return(new BitmapImage(new Uri("pack://application:,,,/ArtifactAPI.Example;component/Images/card_type_weapon.png", UriKind.Absolute)));

            default:
                return(null);
            }

            throw new NotImplementedException("");
        }
コード例 #7
0
        /// <summary>
        /// Custom Logic to handle the DragDrop events of cards in the window.
        /// </summary>
        /// <param name="sender">The Panel object raising the Drop event.</param>
        /// <param name="e">The DragEventArgs object being handled by this method.</param>
        private void Panel_Drop(object sender, DragEventArgs e)
        {
            // If an element in the panel has already handled the drop,
            // the panel should not also handle it.
            //if (e.Handled == false)
            //{
            lblAlerts.Content    = "";
            lblAlerts.Visibility = Visibility.Collapsed;
            if (_matchingMode == false)                                           //WE ARE PLACING CARDS ON THE BOARD
            {
                Panel       _target     = (Panel)sender;                          //THE TARGET OF THE DROP EVENT (an empty spot)
                UIElement   _element    = (UIElement)e.Data.GetData("Object");    //THE UIELEMENT BEING DRAGGED AND DROPPED
                GenericCard _gcDragging = new GenericCard((GenericCard)_element); //THE GenericCard CONTAINED IN _element

                if (_target != null && _target.Children.Count == 0 && _element != null)
                {
                    // Get the panel that the element currently belongs to,
                    // then remove it from that panel and add it the Children of
                    // the panel that its been dropped on.
                    //Panel _targetParent = (Panel)VisualTreeHelper.GetParent(_target); //THE Panel THAT CONTAINS _target
                    Panel _elementParent = (Panel)VisualTreeHelper.GetParent(_element);     //THE Panel THAT CONTAINS _element


                    if (_elementParent == spCards)     //THE PARENT OF _element IS THE DRAW PILE (spCards)
                    {
                        if (e.AllowedEffects.HasFlag(DragDropEffects.Move))
                        {
                            if (_gcDragging.Symbol.Equals("K"))     //IF THE CARD IS A KING
                            {
                                if ((_target.GetValue(Grid.RowProperty).Equals(0) || _target.GetValue(Grid.RowProperty).Equals(3)) &&
                                    (_target.GetValue(Grid.ColumnProperty).Equals(0) || _target.GetValue(Grid.ColumnProperty).Equals(3))) //CHECK IF THE TARGET IS ONE OF THE CORNER SLOTS
                                {
                                    _gcDragging.locked = true;                                                                            //SET THE locked PROPERTY OF THE CARD TO true
                                    _elementParent.Children.Remove(_element);                                                             //REMOVE THE CARD FROM THE DRAW PILE
                                    //_gcDragging.SetValue(Grid.RowProperty, _target.GetValue(Grid.RowProperty)); //SET THE ROW PROPERTY OF THE CARD
                                    //_gcDragging.SetValue(Grid.ColumnProperty, _target.GetValue(Grid.ColumnProperty)); //SET THE COLUMN PROPERTY OF THE CARD
                                    _target.Children.Add(_gcDragging);
                                    ShowNextCardInPile();
                                    CardsInPlay.Add(_gcDragging);
                                }
                            }
                            else if (_gcDragging.Symbol.Equals("Q"))     //IF THE CARD IS A QUEEN
                            {
                                if ((_target.GetValue(Grid.RowProperty).Equals(0) || _target.GetValue(Grid.RowProperty).Equals(3)) &&
                                    (_target.GetValue(Grid.ColumnProperty).Equals(1) || _target.GetValue(Grid.ColumnProperty).Equals(2))) //CHECK IF THE TARGET IS ONE OF THE TOP OR BOTTOM MIDDLE SLOTS
                                {
                                    _gcDragging.locked = true;                                                                            //SET THE locked PROPERTY OF THE CARD TO true
                                    _elementParent.Children.Remove(_element);                                                             //REMOVE THE CARD FROM THE DRAW PILE
                                    //_gcDragging.SetValue(Grid.RowProperty, _target.GetValue(Grid.RowProperty)); //SET THE ROW PROPERTY OF THE CARD
                                    //_gcDragging.SetValue(Grid.ColumnProperty, _target.GetValue(Grid.ColumnProperty)); //SET THE COLUMN PROPERTY OF THE CARD
                                    _target.Children.Add(_gcDragging);
                                    ShowNextCardInPile();
                                    CardsInPlay.Add(_gcDragging);
                                }
                            }
                            else if (_gcDragging.Symbol.Equals("J"))     //IF THE CARD IS A JACK
                            {
                                if ((_target.GetValue(Grid.RowProperty).Equals(1) || _target.GetValue(Grid.RowProperty).Equals(2)) &&
                                    (_target.GetValue(Grid.ColumnProperty).Equals(0) || _target.GetValue(Grid.ColumnProperty).Equals(3))) //CHECK IF THE TARGET IS ONE OF THE LEFT OR RIGHT MIDDLE SLOTS
                                {
                                    _gcDragging.locked = true;                                                                            //SET THE locked PROPERTY OF THE CARD TO true
                                    _elementParent.Children.Remove(_element);                                                             //REMOVE THE CARD FROM THE DRAW PILE
                                    //_gcDragging.SetValue(Grid.RowProperty, _target.GetValue(Grid.RowProperty)); //SET THE ROW PROPERTY OF THE CARD
                                    //_gcDragging.SetValue(Grid.ColumnProperty, _target.GetValue(Grid.ColumnProperty)); //SET THE COLUMN PROPERTY OF THE CARD
                                    _target.Children.Add(_gcDragging);
                                    ShowNextCardInPile();
                                    CardsInPlay.Add(_gcDragging);
                                }
                            }
                            else                                          //IF THE CARD IS AN ACE OR NUMBER CARD
                            {
                                _elementParent.Children.Remove(_element); //REMOVE THE CARD FROM THE DRAW PILE
                                //_gcDragging.SetValue(Grid.RowProperty, _target.GetValue(Grid.RowProperty)); //SET THE ROW PROPERTY OF THE CARD
                                //_gcDragging.SetValue(Grid.ColumnProperty, _target.GetValue(Grid.ColumnProperty)); //SET THE COLUMN PROPERTY OF THE CARD
                                _target.Children.Add(_gcDragging);
                                ShowNextCardInPile();
                                CardsInPlay.Add(_gcDragging);
                            }
                            // set the value to return to the DoDragDrop call
                            e.Effects = DragDropEffects.Move;

                            if (IsBoardFilled() == true)     //Is every slot on the board filled?
                            {
                                //Are there legal matches on the board?
                                if (LegalMatchCheck() == true)      //YES
                                {
                                    _matchingMode = true;
                                }
                                else     //NO
                                {
                                    //game over
                                    lblAlerts.Content    = KCstrings.GameOver;
                                    lblAlerts.Visibility = Visibility.Visible;
                                }
                            }
                        }
                    }
                    else if (VisualTreeHelper.GetParent(_elementParent).Equals(gridBoard))     //YOU CAN'T DISCARD WHILE THERE ARE STILL EMPTY SLOTS ON THE BOARD
                    {
                        lblAlerts.Content    = KCstrings.BoardNotFilled;
                        lblAlerts.Visibility = Visibility.Visible;
                    }
                }
            }
            else if (_matchingMode == true)     //WE ARE NOW REMOVING CARDS FROM THE BOARD
            {
                Panel       _target      = sender as Panel;
                UIElement   _element     = (UIElement)e.Data.GetData("Object");    //THE UIELEMENT BEING DRAGGED AND DROPPED
                GenericCard CardDragging = new GenericCard((GenericCard)_element); //THE GenericCard CONTAINED IN _element
                //GenericCard CardTarget = new GenericCard((GenericCard)_target.Children[0]);
                //GenericCard target = new GenericCard((GenericCard)_target);


                /*if (_target != null && _element != null)
                 * {
                 *  // Get the panel that the element currently belongs to,
                 *  // then remove it from that panel and add it the Children of
                 *  // the panel that its been dropped on.
                 *  Panel _elementParent = (Panel)VisualTreeHelper.GetParent(_element);
                 *
                 *  if (_elementParent != null)
                 *  {
                 *      if (gridBoard.Children.Contains(_elementParent)) //THE PARENT OF THE DRAGGED CARD IS THE BOARD
                 *      {
                 *          if (e.AllowedEffects.HasFlag(DragDropEffects.Move))
                 *          {
                 *
                 *              if (LegalMatchCheck() == true)
                 *              {
                 *                  Discard(CardTarget, CardDragging);
                 *
                 *              }
                 *              // set the value to return to the DoDragDrop call
                 *              e.Effects = DragDropEffects.Move;
                 *              //Are there legal matches on the board? Is the board filled?
                 *
                 *              if (LegalMatchCheck() == false && IsBoardFilled() == false) //NO AND NO
                 *              {
                 *                  //Can the next card on the draw pile be legally placed on the board?
                 *                  if (CanPlayNextCard() == true) //YES
                 *                  {
                 *                      _matchingMode = false;
                 *                  }
                 *                  else //NO. GAME OVER!
                 *                  {
                 *                      lblAlerts.Content = KCstrings.GameOver;
                 *                      lblAlerts.Visibility = Visibility.Visible;
                 *                  }
                 *              }
                 *          }
                 *      }
                 *  }
                 * }*/
            }
            // }
        }
コード例 #8
0
        /// <summary>
        /// Check if a pair of cards adds up to 10. Moves them from the board to the discard pile if they do.
        /// </summary>
        /// <param name="dragged">The card being dragged</param>
        /// <param name="target">The card being dropped on</param>
        private void Discard(GenericCard target, GenericCard dragged)
        {
            Panel _parentD = (Panel)VisualTreeHelper.GetParent(dragged);
            Panel _parentT = (Panel)VisualTreeHelper.GetParent(target);

            if (target.locked != true && dragged.locked != true)
            {
                if (dragged.FaceValue + target.FaceValue == 10)
                {
                    Grid newGridD = new Grid();
                    newGridD.Width  = 68;
                    newGridD.Height = 93;
                    Grid newGridT = new Grid();
                    newGridT.Width  = 68;
                    newGridT.Height = 93;

                    int r1 = (int)dragged.GetValue(Grid.RowProperty);
                    int c1 = (int)dragged.GetValue(Grid.ColumnProperty);
                    int r2 = (int)target.GetValue(Grid.RowProperty);
                    int c2 = (int)target.GetValue(Grid.ColumnProperty);

                    _parentD.Children.Remove(dragged);
                    _parentT.Children.Remove(target);

                    //DRAGGED SPOT
                    if ((r1 == 0 || r1 == 3) && (c1 == 0 || c1 == 3)) //KINGS
                    {
                        newGridD.Background = brickKing.Background;
                        newGridD.SetValue(Grid.RowProperty, r1);
                        newGridD.SetValue(Grid.ColumnProperty, c1);
                        gridBoard.Children.Add(newGridD);
                    }
                    else if ((r1 == 0 || r1 == 3) && (c1 == 1 || c1 == 2)) //QUEENS
                    {
                        newGridD.Background = brickQueen.Background;
                        newGridD.SetValue(Grid.RowProperty, r1);
                        newGridD.SetValue(Grid.ColumnProperty, c1);
                        gridBoard.Children.Add(newGridD);
                    }
                    else if ((r1 == 1 || r1 == 2) && (c1 == 0 || c1 == 3)) //JACKS
                    {
                        newGridD.Background = brickJack.Background;
                        newGridD.SetValue(Grid.RowProperty, r1);
                        newGridD.SetValue(Grid.ColumnProperty, c1);
                        gridBoard.Children.Add(newGridD);
                    }
                    else if ((r1 == 1 || r1 == 2) && (c1 == 1 || c1 == 2)) //BLANKS
                    {
                        newGridD.Background = brickBlank.Background;
                        newGridD.SetValue(Grid.RowProperty, r1);
                        newGridD.SetValue(Grid.ColumnProperty, c1);
                        gridBoard.Children.Add(newGridD);
                    }

                    //TARGET SPOT
                    if ((r2 == 0 || r2 == 3) && (c2 == 0 || c2 == 3)) //KINGS
                    {
                        newGridT.Background = brickKing.Background;
                        newGridT.SetValue(Grid.RowProperty, r2);
                        newGridT.SetValue(Grid.ColumnProperty, c2);
                        gridBoard.Children.Add(newGridT);
                    }
                    else if ((r2 == 0 || r2 == 3) && (c2 == 1 || c2 == 2)) //QUEENS
                    {
                        newGridT.Background = brickQueen.Background;
                        newGridT.SetValue(Grid.RowProperty, r2);
                        newGridT.SetValue(Grid.ColumnProperty, c2);
                        gridBoard.Children.Add(newGridT);
                    }
                    else if ((r2 == 1 || r2 == 2) && (c2 == 0 || c2 == 3)) //JACKS
                    {
                        newGridT.Background = brickJack.Background;
                        newGridT.SetValue(Grid.RowProperty, r2);
                        newGridT.SetValue(Grid.ColumnProperty, c2);
                        gridBoard.Children.Add(newGridT);
                    }
                    else if ((r2 == 1 || r2 == 2) && (c2 == 1 || c2 == 2)) //BLANKS
                    {
                        newGridT.Background = brickBlank.Background;
                        newGridT.SetValue(Grid.RowProperty, r2);
                        newGridT.SetValue(Grid.ColumnProperty, c2);
                        gridBoard.Children.Add(newGridT);
                    }
                    CardsInPlay.Remove(target);
                    CardsInPlay.Remove(dragged);

                    target.RenderTransform  = new RotateTransform(30.0);
                    dragged.RenderTransform = new RotateTransform(-14.5);
                    cnvDiscard.Children.Add(target);
                    cnvDiscard.Children.Add(dragged);
                }
            }
        }
コード例 #9
0
ファイル: VCardReader.cs プロジェクト: JaCraig/FileCurator
        /// <summary>
        /// Reads the specified stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns>The file</returns>
        public override ICard Read(Stream stream)
        {
            var    ReturnValue = new GenericCard();
            string Content     = GetData(stream);

            foreach (Match TempMatch in EntryRegex.Matches(Content))
            {
                var Title = TempMatch.Groups["Title"].Value.ToUpperInvariant().Trim();
                var Value = TempMatch.Groups["Value"].Value.Trim();
                if (Title == "N")
                {
                    var Name = Value.Split(';');
                    if (Name.Length > 0)
                    {
                        ReturnValue.LastName = Name[0];
                        if (Name.Length > 1)
                        {
                            ReturnValue.FirstName = Name[1];
                        }
                        if (Name.Length > 2)
                        {
                            ReturnValue.MiddleName = Name[2];
                        }
                        if (Name.Length > 3)
                        {
                            ReturnValue.Prefix = Name[3];
                        }
                        if (Name.Length > 4)
                        {
                            ReturnValue.Suffix = Name[4];
                        }
                    }
                }
                else if (Title.StartsWith("TEL", StringComparison.Ordinal))
                {
                    var Type = TypeRegex.Match(Title);
                    ReturnValue.DirectDial.Add(new PhoneNumber
                    {
                        Number = Value,
                        Type   = Type?.Groups["Title"].Value ?? string.Empty
                    });
                }
                else if (Title.StartsWith("EMAIL", StringComparison.Ordinal))
                {
                    var Type = TypeRegex.Match(Title);
                    ReturnValue.Email.Add(new MailAddress
                    {
                        EmailAddress = Value,
                        Type         = Type?.Groups["Title"].Value ?? string.Empty
                    });
                }
                else if (Title.StartsWith("TITLE", StringComparison.Ordinal))
                {
                    ReturnValue.Title = Value;
                }
                else if (Title.StartsWith("ORG", StringComparison.Ordinal))
                {
                    ReturnValue.Organization = Value;
                }
                else if (Title.StartsWith("URL", StringComparison.Ordinal))
                {
                    ReturnValue.Url = Value;
                }
                else if (Title.StartsWith("ADR", StringComparison.Ordinal))
                {
                    var Type = TypeRegex.Match(Title);
                    var Name = Value.Split(';');
                    ReturnValue.Addresses.Add(new Address
                    {
                        Name            = Name.Length > 1 ? Name[1] : "",
                        Type            = Type?.Groups["Title"].Value ?? string.Empty,
                        Street          = Name.Length > 2 ? Name[2] : "",
                        City            = Name.Length > 3 ? Name[3] : "",
                        StateOrProvence = Name.Length > 4 ? Name[4] : "",
                        ZipCode         = Name.Length > 5 ? Name[5] : "",
                        Country         = Name.Length > 6 ? Name[6] : ""
                    });
                }
            }
            return(ReturnValue);
        }
コード例 #10
0
        /// <summary>
        /// Converts a DecodedDeck to return a complete deck with all stats
        /// </summary>
        /// <param name="decodedDeck">A DecodedDeck</param>
        /// <returns>A complete deck with cards and their info</returns>
        public async Task <Deck> GetCardsFromDecodedDeckAsync(DecodedDeck decodedDeck)
        {
            if (decodedDeck == null)
            {
                return(null);
            }

            List <HeroCard>    heroCards    = new List <HeroCard>();
            List <GenericCard> genericCards = new List <GenericCard>();

            foreach (DecodedHero dHero in decodedDeck.Heroes)
            {
                Card card = await GetCardAsync(dHero.Id);

                if (card == null || !(card is HeroCard))
                {
                    continue;
                }

                HeroCard heroCard = (HeroCard)card;
                heroCard.Turn = dHero.Turn;

                if (heroCard.References != null)
                {
                    foreach (Reference referenceCard in heroCard.References)
                    {
                        Card refCard = await GetCardAsync(referenceCard.Id);

                        if (refCard is SignatureCard)
                        {
                            genericCards.Add((SignatureCard)refCard);
                        }
                    }
                }

                heroCards.Add(heroCard);
            }

            foreach (DecodedCard dCard in decodedDeck.Cards)
            {
                Card card = await GetCardAsync(dCard.Id);

                if (card == null || !(card is GenericCard))
                {
                    continue;
                }

                GenericCard genericCard = card as GenericCard;
                genericCard.Count = dCard.Count;

                genericCards.Add(genericCard);
            }

            Deck d = new Deck()
            {
                Name   = decodedDeck.Name,
                Heroes = heroCards,
                Cards  = genericCards,
            };

            return(d);
        }
コード例 #11
0
        /// <summary>
        /// Sorts through cards and sets converts SignatureCards to the correct type
        /// </summary>
        /// <param name="cardSet"></param>
        /// <returns></returns>
        private async Task <List <Card> > SetSignatureCardsAsync(List <Card> cardSet)
        {
            List <Card> modifiedCards = new List <Card>(cardSet);
            await Task.Run(() =>
            {
                foreach (Card gCard in cardSet)
                {
                    if (gCard is HeroCard)
                    {
                        HeroCard heroCard = gCard as HeroCard;
                        if (gCard.References != null)
                        {
                            foreach (Reference r in gCard.References)
                            {
                                if (r.Type == ReferenceType.Included)
                                {
                                    GenericCard g = (GenericCard)modifiedCards.FirstOrDefault(x => x.Id == r.Id);
                                    if (g == null)
                                    {
                                        continue;
                                    }

                                    modifiedCards.Remove(g);
                                    SignatureCard sigCard = new SignatureCard()
                                    {
                                        HeroId = gCard.Id, //Set the parent card id of the signature card

                                        Count        = 3,  //Signature cards always have x3 of theirselves //g.Amount,
                                        Armor        = g.Armor,
                                        AttackDmg    = g.AttackDmg,
                                        BaseId       = g.BaseId,
                                        GoldCost     = g.GoldCost,
                                        HitPoints    = g.HitPoints,
                                        Id           = g.Id,
                                        Illustrator  = g.Illustrator,
                                        IngameImage  = g.IngameImage,
                                        IsBlack      = g.IsBlack,
                                        IsBlue       = g.IsBlue,
                                        IsGreen      = g.IsGreen,
                                        IsRed        = g.IsRed,
                                        FactionColor = g.FactionColor,
                                        ItemDef      = g.ItemDef,
                                        LargeImage   = g.LargeImage,
                                        ManaCost     = g.ManaCost,
                                        MiniImage    = g.MiniImage,
                                        Names        = g.Names,
                                        Rarity       = g.Rarity,
                                        References   = g.References,
                                        SubType      = g.SubType,
                                        Text         = g.Text,
                                        Type         = g.Type,
                                    };

                                    modifiedCards.Add(sigCard);
                                }
                            }
                        }
                    }
                }
            });

            return(modifiedCards);
        }
コード例 #12
0
 public bool Snap(GenericCard other)
 {
     return(CardValue == other.CardValue);
 }
コード例 #13
0
ファイル: SkiUIManager.cs プロジェクト: wbshim/ProposalGame
 // Use this for initialization
 void Awake()
 {
     scoreCard = ScoreCard.GetComponent <GenericCard>();
     livesCard = LivesCard.GetComponent <GenericCard>();
 }