Ejemplo n.º 1
0
 public static DominionCard Create(Dominion.Card card)
 {
     if (card == null)
     {
         return(null);
     }
     return(mpCardNameToCard[card.name]);
 }
Ejemplo n.º 2
0
        public bool IsExcluded(Dominion.Card card)
        {
            bool unused;

            if (this.excludes.TryGetValue(card, out unused))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        bool CurrentConstraint(Dominion.Card card)
        {
            foreach (var current in RequiredCards)
            {
                if (!currentCards.Contains(current))
                {
                    return(card == current);
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
        bool MatchesOtherConstraints(Dominion.Card card)
        {
            if (!this.allowAttack && card.isAttack)
            {
                return(false);
            }
            if (!this.enabledExpansions.Contains(card.expansion))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
 private DominionCard(Dominion.Card card)
 {
     this.Id           = card.ProgrammaticName;
     this.Name         = card.name;
     this.Coin         = card.DefaultCoinCost;
     this.Potion       = card.potionCost;
     this.Expansion    = GetExpansionIndex(card.expansion);
     this.IsAttack     = card.isAttack;
     this.IsAction     = card.isAction;
     this.IsReaction   = card.isReaction;
     this.IsDuration   = card.isDuration;
     this.isWebCard    = false;
     this.dominionCard = card;
 }
Ejemplo n.º 6
0
 private DominionCard(Dominion.Card card)
 {
     this.Id = card.ProgrammaticName;
     this.Name = card.name;
     this.Coin = card.DefaultCoinCost;
     this.Potion = card.potionCost;
     this.Expansion = GetExpansionIndex(card.expansion);
     this.IsAttack = card.isAttack;
     this.IsAction = card.isAction;
     this.IsReaction = card.isReaction;
     this.IsDuration = card.isDuration;
     this.isWebCard = false;
     this.dominionCard = card;
 }
Ejemplo n.º 7
0
 private async System.Threading.Tasks.Task PopulateCommonFromResources()
 {
     Dominion.Card[] commonCards = new Dominion.Card[] {
         Dominion.Cards.Province,
         Dominion.Cards.Duchy,
         Dominion.Cards.Estate,
         Dominion.Cards.Gold,
         Dominion.Cards.Silver,
         Dominion.Cards.Copper,
     };
     foreach (Dominion.Card card in commonCards)
     {
         this.originalCards.Add(DominionCard.Create(card));
     }
 }
Ejemplo n.º 8
0
 public DominionCard(Windows.Data.Json.JsonValue jsonDescription)
 {
     var dictionary = jsonDescription.GetObject();
     this.Id = dictionary.GetNamedString("id");
     this.Name = dictionary.GetNamedString("name");
     this.Coin = (int)dictionary.GetNamedNumber("coin");
     this.Potion = (int)dictionary.GetNamedNumber("potion");
     this.Expansion = GetExpansionIndex(dictionary.GetNamedString("expansion"));
     this.IsAction = dictionary.GetNamedBoolean("isAction");
     this.IsAttack = dictionary.GetNamedBoolean("isAttack");
     this.IsReaction = dictionary.GetNamedBoolean("isReaction");
     this.IsDuration = dictionary.GetNamedBoolean("isDuration");
     this.isWebCard = true;
     this.dominionCard = null;
 }
Ejemplo n.º 9
0
        public Dominion.Card GetCard(Func <Dominion.Card, bool> meetConstraint)
        {
            int curIndex = this.maxIndex;

            while (curIndex >= 0)
            {
                int           resultCardIndex = NumberBetweenInclusive(MainPage.random, 0, maxIndex);
                Dominion.Card currentCard     = this.allCards[remainingCards[resultCardIndex]];

                if (!IsExcluded(currentCard) && meetConstraint(currentCard))
                {
                    remainingCards[resultCardIndex] = remainingCards[maxIndex];
                    --maxIndex;
                    return(currentCard);
                }
                --curIndex;
            }

            return(null);
        }
Ejemplo n.º 10
0
        internal static bool GenerateRandom(
            int targetCount,
            ref DominionCard baneCard,
            IList <DominionCard> resultList,
            IList <DominionCard> sourceList,
            IEnumerable <DominionCard> allCards,
            IEnumerable <DominionCard> itemsToReplace)
        {
            bool isReplacingItems = itemsToReplace != null && itemsToReplace.Any() && sourceList.Count <= targetCount;
            bool isReducingItems  = itemsToReplace != null && itemsToReplace.Any() && sourceList.Count > targetCount;
            var  cardPicker       = new Dominion.UniqueCardPicker <Dominion.Card>(allCards.Select(c => c.dominionCard), MainPage.random);

            bool isCleanRoll = false;

            if (isReplacingItems)
            {
                cardPicker.ExcludeCards(itemsToReplace.Select(c => c.dominionCard));
            }

            baneCard = DominionCard.Create(cardPicker.GetCard(c => c.DefaultCoinCost == 2 || c.DefaultCoinCost == 3));

            if (isReplacingItems)
            {
                foreach (DominionCard cardToReplace in itemsToReplace)
                {
                    for (int i = 0; i < resultList.Count; ++i)
                    {
                        if (resultList[i] == cardToReplace)
                        {
                            var nextCard = cardPicker.GetCard(c => true);
                            if (nextCard == null)
                            {
                                resultList.Remove(cardToReplace);
                                i--;  // do this index again
                            }
                            else
                            {
                                resultList[i] = DominionCard.Create(nextCard);
                            }
                        }
                    }
                }
            }
            else if (sourceList.Count < targetCount && sourceList.Count > 0)
            {
                var listRemoved = new List <DominionCard>();
                foreach (var card in resultList)
                {
                    if (!sourceList.Contains(card))
                    {
                        listRemoved.Add(card);
                    }
                }

                foreach (var card in listRemoved)
                {
                    resultList.Remove(card);
                }
            }
            else if (isReducingItems)
            {
                foreach (var card in itemsToReplace)
                {
                    resultList.Remove(card);
                }
            }
            else
            {
                resultList.Clear();
                isCleanRoll = true;
            }

            while (resultList.Count < targetCount)
            {
                Dominion.Card currentCard = cardPicker.GetCard(c => true);
                if (currentCard == null)
                {
                    break;
                }
                resultList.Add(DominionCard.Create(currentCard));
            }

            return(isCleanRoll);
        }
Ejemplo n.º 11
0
 bool MatchesAttack(Dominion.Card card)
 {
     return(card.isAttack);
 }
Ejemplo n.º 12
0
 bool MatchesPlusCard(Dominion.Card card)
 {
     return(card.plusCard > 1);
 }
Ejemplo n.º 13
0
 bool MatchesVillage(Dominion.Card card)
 {
     return(card.plusAction > 0);
 }
Ejemplo n.º 14
0
 bool MatchesPlusBuy(Dominion.Card card)
 {
     return(card.plusBuy > 0);
 }
Ejemplo n.º 15
0
 public static DominionCard Create(Dominion.Card card)
 {
     return(mpCardNameToCard[card.name]);
 }
Ejemplo n.º 16
0
        string[] GetSearchWordsForCard(Dominion.Card card)
        {
            var result = new List <string>();

            result.Add(card.name);
            result.Add(ExpansionToString(card.expansion));
            result.Add(card.DefaultCoinCost.ToString());
            if (card.isAction)
            {
                result.Add("action");
            }
            if (card.isAttack)
            {
                result.Add("attack");
            }
            if (card.isReaction)
            {
                result.Add("reaction");
            }
            if (card.isVictory)
            {
                result.Add("victory");
            }
            if (card.isTreasure)
            {
                result.Add("treasure");
            }
            if (card.isShelter)
            {
                result.Add("shelter");
            }
            if (card.isReserve)
            {
                result.Add("reserve");
            }
            if (card.isTraveller)
            {
                result.Add("traveller");
            }
            if (card.isEvent)
            {
                result.Add("event");
            }
            if (card.isDuration)
            {
                result.Add("duration");
            }
            if (card.requiresRuins)
            {
                result.Add("ruins");
            }
            if (card.requiresSpoils)
            {
                result.Add("spoils");
            }
            if (card.isPrize)
            {
                result.Add("prize");
            }
            if (card.isRuins)
            {
                result.Add("ruins");
            }
            if (card.isRuins)
            {
                result.Add("ruins");
            }
            if (card.potionCost != 0)
            {
                result.Add("potion");
            }

            if (this.appDataContext.CurrentDeck.CurrentCards.Where(c => c.dominionCard == card).Any())
            {
                result.Add("current");
                result.Add("deck");
                result.Add("selected");
            }

            return(result.ToArray());
        }