Example #1
0
        public static WikiCard ParseItem(ValveSet set, ValveCard card)
        {
            var wcard = new WikiCard(set.set_info.set_id, card);

            wcard.SubCard = new WikiItem(wcard.Abilities, card);
            return(wcard);
        }
Example #2
0
        public static WikiCard ParseAbility(ValveSet set, ValveCard card)
        {
            var wcard = new WikiCard(set.set_info.set_id, card);

            wcard.SubCard = new WikiAbility(card);
            return(wcard);
        }
Example #3
0
        public string GenerateNewArticle(WikiCard card)
        {
            string result = $@"{TabTemplate}
{CardInfobox}
{SubcardInfobox}


{CardStinger}


{GenerateSections(Sections)}

{GenerateCategories(Categories)}
";

            result = result.Replace("\r", "");
            result = Regex.Replace(result, @"\n\n\n+", "\n\n\n").Trim();

            if (Finalizer != null)
            {
                result = Finalizer(card, result);
            }

            return(result);
        }
        public static string GetCardInfobox(WikiCard card)
        {
            return($@"{{{{Card Infobox
| ID = {card.ID}
| BaseID = {card.BaseID}
| MarketplaceID = {card.MarketplaceID}
| Name = {card.Name}
| Aliases = {String.Join(",", card.Aliases)}
| SetID = {card.SetID}
| CardType = {card.CardType}
| SubType = {card.SubType}
| Rarity = {card.Rarity}
| Color = {card.Color}
| Abilities = {(card.Abilities.Count > 0 ? String.Join(",", card.Abilities.Select(x => x.Value.ID)) : "")}
| TokenOf = {(card.TokenParents.Count > 0 ? String.Join(",", card.TokenParents.Select(x => x.ID)) : "")}
| SignatureOf = {(card.SignatureOf.HasValue ? card.SignatureOf.ToString() : "")}
| IsCollectable = {card.IsCollectable}
| Text = {(String.IsNullOrWhiteSpace(card.Text) ? String.Join("\n", card?.Abilities.Select(x => x.Value.Text)) : card.Text)}
| TextRaw = {card.TextRaw}
| TextFormatted = {(String.IsNullOrWhiteSpace(card.TextFormatted) ? String.Join("\n", card?.Abilities.Select(x => x.Value.TextFormatted)) : card.TextFormatted)}
| CardImage = {card.CardImage}
| CardImageRaw = {card.CardImageRaw}
| CardIcon = {card.CardIcon}
| Illustrator = {card.Illustrator}
| VoiceActor = {card.VoiceActor}
| Lore = {card.Lore}
| LoreFormatted = {card.LoreFormatted}
| Keywords = {String.Join(",", card.Keywords.Keys)}}}}}
");
        }
Example #5
0
            public override void Transform(WikiCard card)
            {
                if (card.LoreFormatted == null)
                {
                    return;
                }

                card.LoreFormatted = Regex.Replace(card.LoreFormatted, RegexString, Replacement);
            }
Example #6
0
 public virtual void Transform(WikiCard card)
 {
     if (card.Text == null)
     {
         Console.WriteLine($"Card {card.Name} has no text!");
         return;
     }
     card.Text = Regex.Replace(card.Text, RegexString, Replacement);
 }
Example #7
0
            public void Transform(WikiCard card)
            {
                foreach (var ability in card.Abilities.Values)
                {
                    if (ability.AbilityType == ArtifactAbilityType.Active)
                    {
                        if (card.CardType == ArtifactCardType.Creep)
                        {
                            ability.AbilityCardParent.CardIcon = "Creep_ability_active_icon.png";
                        }
                    }
                    else if (card.Keywords.ContainsKey(ArtifactKeyword.DeathEffect))
                    {
                        ability.PassiveAbilityType = ArtifactPassiveAbilityType.Death;

                        if (card.CardType == ArtifactCardType.Creep)
                        {
                            ability.AbilityCardParent.CardIcon = "Creep_ability_death_icon.png";
                        }
                    }
                    else if (card.Keywords.ContainsKey(ArtifactKeyword.ReactiveEffect))
                    {
                        ability.PassiveAbilityType = ArtifactPassiveAbilityType.Reactive;
                        if (card.CardType == ArtifactCardType.Creep)
                        {
                            ability.AbilityCardParent.CardIcon = "Creep_ability_reactive_icon.png";
                        }
                    }
                    else if (card.Keywords.ContainsKey(ArtifactKeyword.PlayEffect))
                    {
                        ability.PassiveAbilityType = ArtifactPassiveAbilityType.Play;
                        if (card.CardType == ArtifactCardType.Creep)
                        {
                            ability.AbilityCardParent.CardIcon = "Creep_ability_reactive_icon.png";
                        }
                    }
                    else
                    {
                        ability.PassiveAbilityType = ArtifactPassiveAbilityType.Continuous;
                        card.Keywords.Add(ArtifactKeyword.ContinuousEffect, "process of elimination");
                        if (card.CardType == ArtifactCardType.Creep)
                        {
                            ability.AbilityCardParent.CardIcon = "Creep_ability_continuous_icon.png";
                        }
                    }

                    if (card.CardType == ArtifactCardType.Item || card.CardType == ArtifactCardType.Improvement)
                    {
                        ability.AbilityCardParent.CardIcon = card.CardIcon;
                    }
                }

                //if(card.Keywords.ContainsKey(ArtifactKeyword.DeathEffect))
                //{
                //	card.
                //}
            }
        protected string Finalize(WikiCard card, string result)
        {
            if (card.VoiceOverLines.Count == 0)
            {
                return(GetEmptyResponseArticle(card));
            }

            return(Regex.Replace(result, @"\n\n+", "\n\n"));
        }
Example #9
0
 protected override void TransformSingle(WikiCard card)
 {
     if (card.CardType == ArtifactCardType.Ability ||
         card.CardType == ArtifactCardType.PassiveAbility)
     {
         var ability = card.SubCard as WikiAbility;
         ability.Text          = card.Text;
         ability.TextFormatted = card.TextFormatted;
     }
 }
Example #10
0
            public override void Transform(WikiCard card)
            {
                Dictionary <string, string> newVO = new Dictionary <string, string>();

                foreach (var pair in card.VoiceOverLines)
                {
                    newVO[pair.Key] = Regex.Replace(pair.Value, RegexString, Replacement);
                }

                card.VoiceOverLines = newVO;
            }
Example #11
0
 protected override void TransformSingle(WikiCard card)
 {
     if (card.Rarity == ArtifactRarity.Basic ||
         card.CardType == ArtifactCardType.Stronghold ||
         card.CardType == ArtifactCardType.Pathing ||
         card.CardType == ArtifactCardType.Ability ||
         card.CardType == ArtifactCardType.PassiveAbility)
     {
         card.IsCollectable = false;
     }
 }
Example #12
0
 public static List <string> GetStandardCategories(WikiCard card, string typeCat, string setName)
 {
     return(new List <string>()
     {
         typeCat,
         card.Color.ToString(),
         card.Rarity.ToString(),
         card.IsCollectable ? "Collectable" : "Non-collectable",
         setName
     });
 }
Example #13
0
            public override void Transform(WikiCard card)
            {
                if (card.Text != null)
                {
                    card.Text = Regex.Replace(card.Text, RegexString, card.Name);
                }

                if (card.TextFormatted != null)
                {
                    card.TextFormatted = Regex.Replace(card.TextFormatted, RegexString, card.Name);
                }
            }
Example #14
0
            public void Transform(WikiCard card)
            {
                card.Text          = card.TextRaw;
                card.TextFormatted = card.TextRaw;
                card.Lore          = card.LoreRaw;
                card.LoreFormatted = card.LoreRaw;

                foreach (var pair in card.VoiceOverLinesRaw)
                {
                    card.VoiceOverLines[pair.Key] = pair.Value;
                }
            }
Example #15
0
        public static string GetTokenParents(WikiCard card)
        {
            string result = "";

            foreach (var parent in card.TokenParents)
            {
                if (parent.CardType == ArtifactCardType.Ability || parent.CardType == ArtifactCardType.PassiveAbility)
                {
                    var ability = parent.SubCard as WikiAbility;
                    result += GetCardReference(ability.Parent.Name);
                }
                else
                {
                    result += GetCardReference(parent.Name);
                }
            }

            return(result);
        }
Example #16
0
 public WikiHero(Dictionary <int, WikiAbility> abilities, int setID, ValveCard hero) : base(hero.card_id, hero.card_name["english"])
 {
     Attack      = hero.attack;
     Armor       = hero.armor;
     Health      = hero.hit_points;
     HeroIcon    = WikiCard.GetImageName(setID, hero, "herocolor", extension: "png");
     HeroIconRaw = WikiCard.GetImageName(setID, hero, "hero", extension: "png");
     foreach (var reference in hero.references)
     {
         if (reference.ref_type == ArtifactReferenceType.Signature)
         {
             SignatureCardID = reference.card_id;
         }
         else
         {
             abilities[reference.card_id] = new WikiAbility(reference, null);
         }
     }
 }
Example #17
0
            public void Transform(WikiCard card)
            {
                if (card.TextRaw == null)
                {
                    Console.WriteLine($"Card {card.Name} has no text!");
                    return;
                }
                var match = Regex.Match(card.TextRaw, @"\[activatedability\[\[color:ability\[Active &#9632;(\d):]]");

                if (match.Captures.Count > 0)
                {
                    foreach (var ability in card.Abilities.Values)
                    {
                        if (ability.AbilityType == ArtifactAbilityType.Active)
                        {
                            ability.Cooldown = Int32.Parse(match.Groups[1].Value);
                        }
                    }
                }
            }
Example #18
0
            public override void Transform(WikiCard card)
            {
                if (card.TextRaw == null)
                {
                    return;
                }
                if (!Regex.IsMatch(card.Text, RegexString) && !Regex.IsMatch(card.TextFormatted, RegexString))
                {
                    return;
                }

                string parent = "";

                if (card.CardType == ArtifactCardType.Ability || card.CardType == ArtifactCardType.PassiveAbility)
                {
                    parent = (card.SubCard as WikiAbility).Parent.Name;
                }

                //if(card.TokenParents.Count == 0)
                //{
                //	parent = card.TokenParent.Name;
                //}

                if (card.SignatureParent != null)
                {
                    parent = card.SignatureParent.Name;
                }

                if (String.IsNullOrWhiteSpace(parent))
                {
                    throw new Exception("Couldn't find the parent name for some reason.");
                }

                card.Text          = Regex.Replace(card.Text, RegexString, parent);
                card.TextFormatted = Regex.Replace(card.TextFormatted, RegexString, parent);
            }
Example #19
0
            public void Transform(WikiCard card)
            {
                foreach (var pair in KeywordTriggers)
                {
                    foreach (string trigger in pair.Value)
                    {
                        if (String.IsNullOrWhiteSpace(trigger) || String.IsNullOrWhiteSpace(card.Text))
                        {
                            continue;
                        }

                        var match = Regex.Match(card.Text, trigger);
                        if (match.Success)
                        {
                            card.Keywords[pair.Key] = match.Value;
                        }
                    }
                }

                //if(card.Keywords.ContainsKey(ArtifactKeyword.DeathEffect))
                //{
                //	card.
                //}
            }
Example #20
0
 protected abstract void TransformChildren(IDictionary <int, WikiCard> cards, WikiCard card);
Example #21
0
 protected abstract void TransformSingle(WikiCard card);
Example #22
0
 public void Transform(WikiCard card)
 {
     TransformSingle(card);
 }
Example #23
0
 public void Transform(IDictionary <int, WikiCard> cards, WikiCard card)
 {
     TransformSingle(card);
     TransformChildren(cards, card);
 }
Example #24
0
 public WikiArticleCombiner(WikiCard card)
 {
     Card = card;
 }
Example #25
0
 public OldLoreArticleCombiner(WikiCard card) : base(card)
 {
 }
Example #26
0
 protected WikiArticleGenerator(WikiCard card, ArtifactCardType type)
 {
     Card     = card;
     CardType = type;
 }
Example #27
0
 protected override void TransformChildren(IDictionary <int, WikiCard> cards, WikiCard card)
 {
 }
Example #28
0
 protected override void TransformChildren(IDictionary <int, WikiCard> cards, WikiCard card)
 {
     foreach (var pair in card.References)
     {
         cards[pair.Key].IsCollectable = false;
     }
 }
Example #29
0
 public static string GetImageName(WikiCard card, string imageType, string language = "default", string extension = "jpg")
 {
     return($"{card.SetID.ToString("00")}_{ScrubString(card.Name)}_{card.ID}_{imageType}_{language}.{extension}");
 }
Example #30
0
 public static string GetAudioName(WikiCard card, string audioType, string audioName, string extension = "mp3")
 {
     return($"{card.SetID.ToString("00")}_{ScrubString(card.Name)}_{card.ID}_{audioType}_{ScrubString(audioName)}.{extension}");
 }