예제 #1
0
        public EmbedBuilder RulingOutput(ScryFallCardRulingsModel rulings, ScryfallDataModel.BaseCodeObject cardData)
        {
            EmbedBuilder rulingEmbed = new EmbedBuilder();
            const int    dataCount   = 9; // This limit is added due to Discord's hard limitation on message character sizes.

            rulingEmbed.WithColor(successfulColor);
            rulingEmbed.Title = $"Rulings for {cardData.Name}";
            rulingEmbed.Url   = cardData.ScryfallUri;

            if (rulings.data.Count > dataCount)
            {
                for (int i = 0; i < dataCount; i++)
                {
                    rulingEmbed.AddField($"{rulings.data[i].published_at}", rulings.data[i].comment, false);
                }
                rulingEmbed.AddField($"Additional Rulings", $"This card had too many rules to fit. Plesae check out the rest of them on ScryFall \n {cardData.ScryfallUri}", false);
            }
            else
            {
                foreach (var rule in rulings.data)
                {
                    rulingEmbed.AddField($"{rule.published_at}", rule.comment, false);
                }
            }

            return(rulingEmbed);
        }
예제 #2
0
        private List <EmbedFieldBuilder> DetermineLegality(ScryfallDataModel.BaseCodeObject cardInfo)
        {
            List <EmbedFieldBuilder> EmbededList = new List <EmbedFieldBuilder>();
            var dictionary = cardInfo.AllLegalities;
            var NotLegal   = FillLegalitiesLists(dictionary, "Not Legal");
            var Legal      = FillLegalitiesLists(dictionary, "Legal");
            var Banned     = FillLegalitiesLists(dictionary, "Banned");
            var Restricted = FillLegalitiesLists(dictionary, "Restricted");

            if (Legal.Count > 0 && Legal != null)
            {
                EmbededList.Add(BuildLegalityFields("Legal", EmbedLegalityStringBuilder(Legal)));
            }
            if (NotLegal.Count > 0 && NotLegal != null)
            {
                EmbededList.Add(BuildLegalityFields("Not Legal", EmbedLegalityStringBuilder(NotLegal)));
            }
            if (Banned.Count > 0 && Banned != null)
            {
                EmbededList.Add(BuildLegalityFields("Banned", EmbedLegalityStringBuilder(Banned)));
            }
            if (Restricted.Count > 0 && Restricted != null)
            {
                EmbededList.Add(BuildLegalityFields("Restricted", EmbedLegalityStringBuilder(Restricted)));
            }

            return(EmbededList);
        }
예제 #3
0
        public static ScryfallDataModel.BaseCodeObject PullScryfallData(string cardname)
        {
            var PullCard = new ScryfallDataModel.BaseCodeObject();

            cardname = FormatUserInput.FormatEntry(cardname);

            if (CardDictionary.ContainsKey(cardname))
            {
                return(CardDictionary[cardname]);
            }
            //Store downloaded summary into memory.
            string CallAPI = ExactScryFall(cardname);

            if (CallAPI != null)
            {
                PullCard = JsonConvert.DeserializeObject <ScryfallDataModel.BaseCodeObject>(CallAPI, JsonDeserializeHelper.settings);
                PullCard.AllLegalities = SetLegalList(PullCard.Legalities);
                CardDictionary.Add(cardname, PullCard);
                return(PullCard);
            }
            return(null);
        }
예제 #4
0
        public EmbedBuilder CardOutput(ScryfallDataModel.BaseCodeObject PulledCard)
        {
            EmbedBuilder Card = new EmbedBuilder();

            if (PulledCard.Layout == ScryfallEnums.transform.ToString())
            {
                Card.ThumbnailUrl = PulledCard.card_faces[0].image_uris.Png;
            }
            else
            {
                Card.ThumbnailUrl = PulledCard.ImageUris.Png ?? "none";
            }

            if (PulledCard.Power == null || PulledCard.Toughness == null)
            {
                Card.WithDescription($"{PulledCard.TypeLine} \n {PulledCard.OracleText}");
            }
            else if (!PulledCard.Power.Contains("*"))
            {
                Card.WithDescription($"{PulledCard.TypeLine} \n {PulledCard.OracleText} \n {PulledCard.Power}/{PulledCard.Toughness}");
            }
            else
            {
                Card.WithDescription($"{PulledCard.TypeLine} \n {PulledCard.OracleText} \n \\{PulledCard.Power}/{PulledCard.Toughness}");
            }
            Card.WithColor(successfulColor);
            Card.Url    = PulledCard.ScryfallUri;
            Card.Title  = $"{PulledCard.Name} {PulledCard.ManaCost}";
            Card.Fields = DetermineLegality(PulledCard);

            Card.AddField("Non-Foil Price: ", $"{PulledCard.Prices.Usd ?? "No Pricing Data".TrimStart('$')}", false);
            Card.AddField("Foil Price: ", $"{PulledCard.Prices.UsdFoil ?? "No Pricing Data".TrimStart('$')}", false);

            Card.WithFooter(successfulFooter);

            return(Card);
        }