public ScenarioQuestCard(Card quest)
        {
            _quest = quest;

            EasyModeQuantity = 1;
            NormalModeQuantity = 1;
            NightmareModeQuantity = 1;
        }
        public CardViewModel(Card card, float score)
        {
            _card = card;
            _score = score;

            foreach (var encounterSet in _card.IncludedEncounterSets)
            {
                _includedEncounterSets.Add(new EncounterSetViewModel(encounterSet));
            }
        }
 private bool IsPlayerCard(Card card)
 {
     switch (card.CardType)
     {
         case CardType.Hero:
         case CardType.Ally:
         case CardType.Attachment:
         case CardType.Event:
         //case CardType.Boon:
         case CardType.Treasure:
             return true;
         default:
             return false;
     }
 }
        private IEnumerable<CardEffect> ParseCardEffects(Card card, string text)
        {
            if (string.IsNullOrEmpty(text))
                return Enumerable.Empty<CardEffect>();

            var effects = new List<CardEffect>();

            var isFirst = true;
            foreach (var line in text.Split(new string[] { "\r\n" }, StringSplitOptions.None))
            {
                if (string.IsNullOrEmpty(line))
                    continue;

                effects.Add(ParseCardEffect(card, line, isFirst));
                isFirst = false;
            }

            return effects;
        }
        public static float WeightedScore(Card card, float score)
        {
            var weight = 0;

            if (card.IsUnique)
                weight += 3;

            switch (card.CardType)
            {
                case CardType.Hero:
                    weight += 13;
                    break;
                case CardType.Ally:
                    weight += 9;
                    break;
                case CardType.Objective_Ally:
                    weight += 8;
                    break;
                case CardType.Attachment:
                    weight += 7;
                    break;
                case CardType.Objective:
                    weight += 6;
                    break;
                case CardType.Event:
                    weight += 5;
                    break;
                case CardType.Enemy:
                    weight += 4;
                    break;
                case CardType.Location:
                    weight += 2;
                    break;
                case CardType.Treachery:
                    weight += 1;
                    break;
                default:
                    break;
            }

            return score + weight;
        }
        public float Score(SearchViewModel search, Card card)
        {
            if (_filters != null)
            {
                var bestScore = 0f;
                foreach (var filter in _filters)
                {
                    var score = filter.Score(search, card);
                    if (score > bestScore)
                    {
                        bestScore = score;
                    }
                }

                return bestScore;
            }
            else
            {
                return _check(search, card) ? WeightedScore(card, _score) : _miss;
            }
        }
        public ScenarioCard(Card card)
        {
            Card = card;
            Title = card.Title;
            Set = card.CardSet.NormalizedName;
            EncounterSet = card.EncounterSet;
            EncounterSetNumber = card.CardSet.Number;
            Link = string.Format("/Cards/Details/{0}", card.Slug);

            NightmareQuantity = card.Quantity;

            if (card.CardSet.Cycle == "NIGHTMARE")
            {
                NormalQuantity = 0;
                EasyQuantity = 0;
            }
            else
            {
                NormalQuantity = card.Quantity;
                EasyQuantity = card.EasyModeQuantity.HasValue ? card.EasyModeQuantity.Value : card.Quantity;
            }
        }
        public bool CardIsCustom(Card card)
        {
            if ((this.CardSet == null || this.CardSet == "Any") 
                && (this.EncounterSet == null || this.EncounterSet == "Any") 
                && this.Sphere != Sphere.Mastery 
                && (this.Trait == null || this.Trait == "Any") 
                && (this.Keyword == null || this.Keyword == "Any")
                && (this.Attack == null || this.Attack == "Any")
                && (this.Defense == null || this.Defense == "Any")
                && (this.HitPoints == null || this.HitPoints == "Any")
                && (this.Willpower == null || this.Willpower == "Any")
                && (this.Threat == null || this.Threat == "Any"))
            {
                return card.CardSet.SetType == SetType.CUSTOM;
            }

            return false;
        }
        private CardViewModel GetCardViewModel(Card card)
        {
            var viewModel = new CardViewModel(card);

            foreach (var keyword in card.Keywords)
                viewModel.KeywordEffects.Add(ParseCardEffect(card, keyword, true));

            viewModel.TextEffects.AddRange(ParseCardEffects(card, card.Text));
            viewModel.TextEffects.AddRange(ParseCardEffects(card, card.OppositeText));

            if (!string.IsNullOrEmpty(card.Shadow))
                viewModel.ShadowEffects.Add(ParseCardEffect(card, card.Shadow, true));

            return viewModel;
        }
        private CardEffect ParseCardEffect(Card card, string text, bool isFirst)
        {
            if (text == null)
                return null;

            var effect = new CardEffect();

            var count = 0;
            foreach (var part in text.Split(' '))
            {
                if (string.IsNullOrEmpty(part))
                    continue;

                count++;

                var token = new Token();
                var partText = part;

                var normalized = part.TrimStart('(').TrimEnd('.', ',', ':', '"', '\'', ')');
                var escaped = part.StartsWith("~");

                if (part.Length > 0 && part.EndsWith(":") && char.IsUpper(part.GetFirstLetter()))
                {
                    token.IsTrigger = true;
                    token.Text = part;

                    if (count == 2)
                    {
                        effect.Tokens.First().IsTrigger = true;
                    }

                    checkForTitleReference(token, part);
                }
                else
                {
                    token.Prefix = count > 1 ? " " : string.Empty;

                    if (!escaped && normalized != "Attack")
                    {
                        //NOTE: A Sphere token has priority over a Trait token
                        if (_cardService.Traits().Any(x => string.Equals(x, normalized + ".")) && !_cardService.Spheres().Any(x => string.Equals(x, normalized)))
                        {
                            token.IsTrait = true;
                            token.Text = token.Prefix + part.Trim(',');
                            checkForSuffix(token, part, normalized);
                            effect.Tokens.Add(token);
                            continue;
                        }
                    }

                    token.ImagePath = GetImagePath(normalized);
                    if (token.IsIcon)
                    {
                        if (part.StartsWith("("))
                            token.Prefix = token.Prefix + "(";

                        token.Text = normalized;
                        checkForSuffix(token, part, normalized);
                        effect.Tokens.Add(token);
                        continue;
                    } else if (part.StartsWith("**") && part.EndsWith("**"))
                    {
                        token.IsStrong = true;
                        partText = part.Replace("**", string.Empty);
                    }
                    else if (part.StartsWith("*") && part.EndsWith("*"))
                    {
                        token.IsEmphasized = true;
                        partText = part.Trim('*');
                    }

                    token.Text = token.Prefix + partText.TrimStart('~');
                }

                checkForTitleReference(token, partText);
                
                effect.Tokens.Add(token);
            }

            foreach (var phrase in strongPhrases)
            {
                if (text.ToLower().Contains(phrase))
                {
                    if (!effect.Tokens[0].IsTrigger)
                    {
                        effect.IsCritical = true;
                    }
                }
            }

            return effect;
        }
Beispiel #11
0
 public void AddScenarioCard(Card card)
 {
     scenarioCards.Add(new ScenarioCard(card));
 }
Beispiel #12
0
 public void AddQuestCard(Card card)
 {
     questCards.Add(new ScenarioQuestCard(card));
 }
Beispiel #13
0
 public void SetCampaignCard(Card card)
 {
     campaignCard = new ScenarioCard(card);
 }
 public CardViewModel(Card card)
     : this(card, 0f)
 {
 }
Beispiel #15
0
 public static bool TextMatches(this Models.Card self, string pattern)
 {
     return(self.Text.ToLowerSafe().MatchesPattern(pattern) || self.OppositeText.ToLowerSafe().MatchesPattern(pattern));
 }
 public bool CardSetMatches(Card card)
 {
     return card.CardSet.Name == this.CardSet || (!string.IsNullOrEmpty(card.CardSet.AlternateName) && card.CardSet.AlternateName == this.CardSet) || (!string.IsNullOrEmpty(card.CardSet.NormalizedName) && card.CardSet.NormalizedName == this.CardSet) || (!string.IsNullOrEmpty(card.CardSet.Cycle) && card.CardSet.Cycle.ToUpper() == this.CardSet);
 }
 public bool CardTypeMatches(Card card)
 {
     if (CardType == CardType.Player)
     {
         return card.CardType == CardType.Hero || card.CardType == Models.CardType.Ally || card.CardType == Models.CardType.Attachment || card.CardType == Models.CardType.Event;
     }
     else if (CardType == CardType.Character)
     {
         return card.CardType == Models.CardType.Hero || card.CardType == Models.CardType.Ally || card.CardType == Models.CardType.Objective_Ally || (card.CardType == Models.CardType.Objective && card.HitPoints > 0);
     }
     else if (CardType == CardType.Encounter)
     {
         return card.CardType == Models.CardType.Enemy || card.CardType == Models.CardType.Location || card.CardType == Models.CardType.Treachery || card.CardType == Models.CardType.Objective || card.CardType == Models.CardType.Objective_Ally;
     }
     else if (CardType == CardType.Objective)
     {
         return card.CardType == Models.CardType.Objective || card.CardType == Models.CardType.Objective_Ally;
     }
     else
         return CardType == card.CardType;
 }
        public bool VictoryPointsMatch(Card card)
        {
            if (!HasVictoryPoints())
                return false;

            byte victoryPoints = 0;
            if (byte.TryParse(this.VictoryPoints.Replace("Victory", string.Empty).Trim('.'), out victoryPoints))
            {
                return card.VictoryPoints == victoryPoints;
            }

            return false;
        }
Beispiel #19
0
 public CardScore(Card card, float score)
 {
     this.Card = card;
     this.Score = score;
 }