Beispiel #1
0
        protected override void AddSections(WikiArticle article)
        {
            var match = Regex.Match(CurrentArticle, @"(?s)==+\s*Artifact\s*==+\s*\n+((\{\{.*?\}\}\n*)+)");

            if (match.Success)
            {
                article.AddSection("Artifact", match.Groups[1].Value);
                CurrentArticle = CurrentArticle.Replace(match.Value, "");
            }
            else
            {
                match = Regex.Match(CurrentArticle, @"(?s)==+\s*Artifact\s*==+\s*\n*");
                if (match.Success)
                {
                    article.AddSection("Artifact", "");
                    CurrentArticle = CurrentArticle.Replace(match.Value, "");
                }
            }

            match = Regex.Match(CurrentArticle, @"(?s)==+\s*Dota 2\s*==+\s*\n+(\{\{.*?\}\})");
            if (match.Success)
            {
                article.AddSection("Dota 2", match.Groups[1].Value);
                CurrentArticle = CurrentArticle.Replace(match.Value, "");
            }

            match = Regex.Match(CurrentArticle, @"(?s)==+\s*Related Lore\s*==+\s*\n+((\{\{.*?\}\}\n*)+)");
            if (match.Success)
            {
                article.AddSection("Related Lore", match.Groups[1].Value);
                CurrentArticle = CurrentArticle.Replace(match.Value, "");
            }
        }
        protected override void AddSections(WikiArticle article)
        {
            if (!String.IsNullOrWhiteSpace(Card.TextFormatted))
            {
                article.AddSection("Card Text", Card.TextFormatted);
            }

            if (Card.TokenParents.Count > 0)
            {
                article.AddSection("Summoned By", GetTokenParents(Card));
            }

            if (Card.Abilities.Count > 0)
            {
                article.AddSection("Ability", GetAbilityInfoboxes(Card.Abilities.Values));

                if (Card.Abilities.Any(x => x.Value.CardSpawned != null))
                {
                    var cardSpawned = Card.Abilities.Where(x => x.Value.CardSpawned != null).Select(x => x.Value.CardSpawned).First();
                    article.AddSection("Card Summoned", GetCardReference(cardSpawned));
                }
            }

            article.AddSection("Miscellaneous", GetIllustrator(Card));
        }
        protected override void AddSections(WikiArticle article)
        {
            if (Card.Abilities.Count > 0)
            {
                article.AddSection("Ability", GetAbilityInfoboxes(Card.Abilities.Values));

                if (Card.Abilities.Any(x => x.Value.CardSpawned != null))
                {
                    var cardSpawned = Card.Abilities.Where(x => x.Value.CardSpawned != null).Select(x => x.Value.CardSpawned).First();
                    article.AddSection("Card Summoned", GetCardReference(cardSpawned));
                }
            }
            else
            {
                article.AddSection("Ability", $"{{{{{TypeTemplate}|{Card.Name}}}}} has no abilities.");
            }


            if (SubCard.SignatureCard != null)
            {
                article.AddSection("Signature Card", GetCardReference(SubCard.SignatureCard));
            }

            if (Card.TokenParents.Count > 0)
            {
                article.AddSection("Summoned By", GetTokenParents(Card));
            }

            article.AddSection("Miscellaneous", GetIllustrator(Card));
        }
        protected override void CombineCategories(WikiArticle parsed, WikiArticle generated, WikiArticle combined)
        {
            foreach (string cat in generated.Categories)
            {
                combined.Categories.Add(cat);
            }

            foreach (string cat in parsed.Categories)
            {
                if (cat == "Unreleased")
                {
                    continue;
                }

                bool found = false;
                foreach (string gcat in generated.Categories)
                {
                    if (gcat.Contains(cat) || cat.Contains(gcat))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    combined.Categories.Add(cat);
                }
            }
        }
        protected override void CombineSections(WikiArticle parsed, WikiArticle generated, WikiArticle combined)
        {
            var sections = GetFreshSections();

            foreach (var pair in generated.Sections)
            {
                sections[pair.Key] += pair.Value + "\n";
            }

            foreach (var pair in parsed.Sections)
            {
                string key = SectionMapping[pair.Key];
                if (SkippedSections.Contains(key) || String.IsNullOrWhiteSpace(key))
                {
                    continue;
                }

                sections[key] += pair.Value + "\n";
            }

            foreach (var pair in sections)
            {
                if (String.IsNullOrWhiteSpace(pair.Value) && !MandatorySections.Contains(pair.Key))
                {
                    continue;
                }

                combined.AddSection(pair.Key, pair.Value);
            }
        }
        protected override void AddSubcardInfobox(WikiArticle article)
        {
            article.SubcardInfobox += $@"{{{{Item Infobox
| ID = {Card.ID}
| Name = {Card.Name}
| GoldCost = {SubCard.GoldCost}}}}}";
        }
        protected override void CombineSections(WikiArticle parsed, WikiArticle generated, WikiArticle combined)
        {
            var sections = GetFreshSections();

            foreach (var pair in generated.Sections)
            {
                sections[pair.Key] += pair.Value + "\n";
            }

            foreach (var pair in parsed.Sections)
            {
                string key = SectionMapping[pair.Key];
                if (SkippedSections.Contains(key) || String.IsNullOrWhiteSpace(key))
                {
                    continue;
                }

                if (key == "Miscellaneous")
                {
                    foreach (string line in pair.Value.Split("\n"))
                    {
                        if (line.ToLower().Contains("illustrator") || line.ToLower().Contains("illustrated"))
                        {
                            continue;
                        }
                        if (line.ToLower().Contains("source needed"))
                        {
                            continue;
                        }

                        if (line.Contains("More information has been revealed on"))
                        {
                            sections[key] += line.Replace("More information has been revealed on", "This card was included in") + "\n";
                            continue;
                        }

                        sections[key] += line + "\n";
                    }

                    sections[key] += "\n";
                    continue;
                }

                sections[key] += pair.Value + "\n";
            }

            foreach (var pair in sections)
            {
                if (String.IsNullOrWhiteSpace(pair.Value) && !MandatorySections.Contains(pair.Key))
                {
                    continue;
                }

                combined.AddSection(pair.Key, pair.Value);
            }
        }
        protected override void AddSubcardInfobox(WikiArticle article)
        {
            article.SubcardInfobox += $@"{{{{Spell Infobox
| ID = {Card.ID}
| Name = {Card.Name}
| CardSpawned = {SubCard.CardSpawned?.ID}
| ManaCost = {SubCard.ManaCost}
| Charges = {SubCard.Charges}
| IsCrosslane = {SubCard.IsCrosslane}}}}}";
        }
        protected override void AddSubcardInfobox(WikiArticle article)
        {
            article.SubcardInfobox += $@"{{{{Creep Infobox
| ID = {Card.ID}
| Name = {Card.Name}
| ManaCost = {SubCard.ManaCost}
| Attack = {SubCard.Attack}
| Armor = {SubCard.Armor}
| Health = {SubCard.Health}}}}}";
        }
        public string GenerateArticleText(WikiArticle article = null)
        {
            if (article == null)
            {
                article = GenerateArticle();
            }
            string result = article.GenerateNewArticle(Card);

            return(result);
        }
Beispiel #11
0
        protected override void AddCardStinger(WikiArticle article)
        {
            var match = Regex.Match(CurrentArticle, $@"(?s).*?{Card.Name}\}}?\}}? (is|are) .*?\n+(?=(\[\[Category|==))");

            if (match.Success)
            {
                article.CardStinger = match.Value.Trim();
                CurrentArticle      = CurrentArticle.Replace(match.Value, "");
            }
        }
Beispiel #12
0
        protected override void AddCategories(WikiArticle article)
        {
            var matches = Regex.Matches(CurrentArticle, @"\[\[Category:(.*?)]]");

            foreach (Match cat in matches)
            {
                article.Categories.Add(cat.Groups[1].Value);
                CurrentArticle = CurrentArticle.Replace(cat.Value, "");
            }
        }
        public WikiArticle GenerateArticle()
        {
            WikiArticle article = new WikiArticle();

            AddTabTemplate(article);
            AddCardInfobox(article);
            AddSubcardInfobox(article);
            AddCardStinger(article);
            AddSections(article);
            AddCategories(article);
            return(article);
        }
        protected override void AddSubcardInfobox(WikiArticle article)
        {
            article.SubcardInfobox = $@"{{{{Hero Infobox
| ID = {Card.ID}
| Name = {Card.Name}
| Attack = {SubCard.Attack}
| Armor = {SubCard.Armor}
| Health = {SubCard.Health}
| SignatureCardID = {SubCard.SignatureCardID}
| HeroIcon = {SubCard.HeroIcon}
| HeroIconRaw = {SubCard.HeroIconRaw}}}}}";
        }
 protected override void AddSections(WikiArticle article)
 {
     if (!String.IsNullOrWhiteSpace(Card.TextFormatted))
     {
         article.AddSection("Card Text", Card.TextFormatted);
     }
     if (SubCard.CardSpawned != null)
     {
         article.AddSection("Card Summoned", GetCardReference(SubCard.CardSpawned));
     }
     article.AddSection("Miscellaneous", GetIllustrator(Card));
 }
 protected override void AddCategories(WikiArticle article)
 {
     article.Categories = new List <string>()
     {
         "Items",
         CategoryMapping[Card.SubType],
         Card.Color != ArtifactColor.None ? Card.Color.ToString() : "No Color",
         Card.Rarity.ToString(),
         Card.IsCollectable ? "Collectable" : "Non-collectable",
         Sets[Card.SetID].Name
     };
 }
Beispiel #17
0
        protected override void AddCardInfobox(WikiArticle article)
        {
            var match = Regex.Match(CurrentArticle, @"^(?s)\s*\{\{\w+ Infobox.*?\}\}\n+");

            if (!match.Success)
            {
                return;
            }

            article.CardInfobox = match.Value.Trim();
            CurrentArticle      = CurrentArticle.Replace(match.Value, "");
        }
        protected override void AddSections(WikiArticle article)
        {
            if (Card.LoreFormatted == null)
            {
                article.AddSection("Artifact", $"This card does not have lore.");
            }
            else
            {
                string[] loreChunks = Card.LoreFormatted.Split("—");
                article.AddSection("Artifact", $@"{{{{Quote
| text = {loreChunks[0].Trim()}
| source = {loreChunks[1].Trim()}}}}}");
            }
        }
Beispiel #19
0
        public WikiArticle CombineArticles(WikiArticle parsed, WikiArticle generated)
        {
            if (parsed == null)
            {
                return(generated);
            }

            WikiArticle combined = new WikiArticle();

            CombineTabTemplate(parsed, generated, combined);
            CombineCardInfobox(parsed, generated, combined);
            CombineSubcardInfobox(parsed, generated, combined);
            CombineCardStinger(parsed, generated, combined);
            CombineSections(parsed, generated, combined);
            CombineCategories(parsed, generated, combined);
            return(combined);
        }
Beispiel #20
0
        protected override void AddTabTemplate(WikiArticle article)
        {
            var match = Regex.Match(CurrentArticle, @"\{\{Tabs.*\n+");

            if (match.Success)
            {
                article.TabTemplate = match.Value.Trim();
                CurrentArticle      = CurrentArticle.Replace(match.Value, "");
            }

            match = Regex.Match(CurrentArticle, @"\{\{unreleased content\}\}\n+");
            if (match.Success)
            {
                article.TabTemplate += $"\n{match.Value.Trim()}";
                CurrentArticle       = CurrentArticle.Replace(match.Value, "");
            }
        }
        protected override void AddSections(WikiArticle article)
        {
            string combined = @"{| class=""wikitable"" style=""width: 95 %; margin: auto; ""
!style = ""width: 300px"" | File
!Name
!Transcription
";

            foreach (var pair in Card.VoiceOverFiles)
            {
                combined += $@"|-
|[[File:{pair.Value}]]
|{pair.Key}
|{Card.VoiceOverLines[pair.Key]}
";
            }
            combined += "|}";
            article.AddSection("Uncategorized", combined);
        }
Beispiel #22
0
        protected override void CombineCardStinger(WikiArticle parsed, WikiArticle generated, WikiArticle combined)
        {
            string parsedStinger = parsed.CardStinger ?? "";

            parsedStinger = Regex.Replace(parsedStinger, @"[^\w]+", "").ToLower();

            string generatedStinger = generated.CardStinger;

            generatedStinger = Regex.Replace(generatedStinger, @"[^\w]+", "").ToLower();

            string shortStinger = $"{Card.Name} is a {Card.Color.ToString()} {Card.CardType}".ToLower();

            if (generatedStinger.Contains(parsedStinger))
            {
                combined.CardStinger = generated.CardStinger;
            }
            else
            {
                combined.CardStinger = $"{generated.CardStinger}\n\n{parsed.CardStinger}";
            }
        }
Beispiel #23
0
 protected abstract void CombineCategories(WikiArticle parsed, WikiArticle generated, WikiArticle combined);
Beispiel #24
0
 protected abstract void CombineSections(WikiArticle parsed, WikiArticle generated, WikiArticle combined);
Beispiel #25
0
 protected abstract void CombineCardStinger(WikiArticle parsed, WikiArticle generated, WikiArticle combined);
Beispiel #26
0
 protected abstract void CombineSubcardInfobox(WikiArticle parsed, WikiArticle generated, WikiArticle combined);
Beispiel #27
0
 protected abstract void CombineTabTemplate(WikiArticle parsed, WikiArticle generated, WikiArticle combined);
Beispiel #28
0
 protected override void CombineCategories(WikiArticle parsed, WikiArticle generated, WikiArticle combined)
 {
     combined.Categories = generated.Categories;
 }
Beispiel #29
0
 protected override void CombineCardStinger(WikiArticle parsed, WikiArticle generated, WikiArticle combined)
 {
 }
Beispiel #30
0
 protected override void CombineSubcardInfobox(WikiArticle parsed, WikiArticle generated, WikiArticle combined)
 {
 }