public EmbedBuilder DetermineTypeOfMessage(string matchName)
        {
            MTGCardOutput MessageOutput = new MTGCardOutput();

            var cardData = GetScryFallData.PullScryfallData(matchName);

            if (cardData == null)
            {
                var formattedName = FormatUserInput.FormatEntry(matchName).ToLower();

                var autoComplete = GetScryFallData.PullScryFallAutoComplete(formattedName);

                if (autoComplete.data.Count == 0)
                {
                    return(MessageOutput.DetermineFailure(0));
                }
                else
                {
                    return(MessageOutput.DetermineFailure(0, autoComplete, formattedName));
                }
            }

            if (matchName.Contains('?'))
            {
                return(MessageOutput.RulingOutput(GetScryFallData.PullScryFallRuleData(cardData.Id), cardData));
            }
            else
            {
                return(MessageOutput.CardOutput(cardData));
            }
        }
예제 #2
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);
        }