コード例 #1
0
ファイル: Spells.cs プロジェクト: benbennza1/YouShaltNotPass
    public static Dictionary <spellEnum, SpellDetails> createSpellsEnumToSpellDetailsMap(List <Spells.InspectableSpellDictionaryEntry> inspectorDictionary)
    {
        var spellsEnumToSpellDetailsMap = new Dictionary <spellEnum, SpellDetails>();
        int i = 0;

        foreach (InspectableSpellDictionaryEntry entry in inspectorDictionary)
        {
            var key = elementsPairToSpellEnum[new ElementsPair(entry.firstElement, entry.secondElement)];
            if (spellsEnumToSpellDetailsMap.ContainsKey(key))
            {
                Debug.Log("[Spells][createSpellsEnumToSpellDetailsMap] Warning: There exists duplicte key for element " + i + ": "
                          + entry.firstElement + " | " + entry.secondElement);
            }
            else
            {
                spellsEnumToSpellDetailsMap.Add(key, entry.spellDetails);

                // below is a way to ignore order of spells
                if (entry.secondElement != Elements.elemEnum.none && entry.firstElement != entry.secondElement)
                {
                    var secondkey          = elementsPairToSpellEnum[new ElementsPair(entry.secondElement, entry.firstElement)];
                    var secondSpellDetails = new SpellDetails(entry.spellDetails.secondElementCost, entry.spellDetails.firstElementCost, entry.spellDetails.spellObject);
                    spellsEnumToSpellDetailsMap.Add(secondkey, secondSpellDetails);
                }
            }
            i++;
        }

        return(spellsEnumToSpellDetailsMap);
    }
コード例 #2
0
        public SpellDetails ProduceSpellInfo(int spellIndex)
        {
            using (var webClient = new WebClient())
            {
                string rawJSON = webClient.DownloadString("http://dnd5eapi.co/api/spells/" + spellIndex);

                SpellDetails spellInfo = JsonConvert.DeserializeObject <SpellDetails>(rawJSON);

                return(spellInfo);
            }
        }
コード例 #3
0
    public void ClearSpell()
    {
        m_spell = null;

        m_icon.sprite  = null;
        m_icon.enabled = false;

        m_spellFrame.sprite = m_disabledFrameSprite;

        Tooltip.instance.HideTooltip();
    }
コード例 #4
0
        public async Task produceURL(string message)
        {
            message    = message.ToLower();
            SpellArray = Context.Message.ToString().Split(" ");


            Dictionary <string, string> SpellDictionary = CreateArrayOfAllSpells(SpellArray);
            string url;

            if (SpellDictionary.TryGetValue(message.ToString(), out url))
            {
                int spellIndex = (Array.IndexOf(SpellDictionary.Keys.ToArray(), message) + 1);

                SpellDetails spellDetials = ProduceSpellInfo(spellIndex);
                EmbedBuilder SpellCard    = SpellCardMaker(spellDetials);
                await Context.Channel.SendMessageAsync("", false, SpellCard.Build());
            }
        }
コード例 #5
0
    public void AddSpell(SpellDetails spell)
    {
        if (m_spell == spell)
        {
            return;
        }

        m_spell = spell;

        m_icon.sprite  = spell.icon;
        m_icon.enabled = true;

        m_spellFrame.sprite = m_activeFrameSprite;

        //Sets tooltip text
        m_tooltipText = m_spell.GetTooltipText();

        Tooltip.instance.HideTooltip();
    }
コード例 #6
0
        public EmbedBuilder SpellCardMaker(SpellDetails spellDetails)
        {
            string components = "";

            foreach (string x in spellDetails.components)
            {
                components += x + " ";
            }

            var spellCard = new EmbedBuilder();

            spellCard.WithTitle(spellDetails.name);

            if (!(spellDetails.casting_time == null))
            {
                spellCard.AddField("Casting Time", spellDetails.casting_time, true);
            }
            if (!(spellDetails.range == null))
            {
                spellCard.AddField("Range", spellDetails.range, true);
            }
            if (!(spellDetails.duration == null))
            {
                spellCard.AddField("Duration", spellDetails.duration, true);
            }
            if (!(spellDetails.components == null))
            {
                spellCard.AddField("Components", components, true);
            }
            if (!(spellDetails.material == null))
            {
                spellCard.AddField("Materials", spellDetails.material, true);
            }
            if (!(spellDetails.desc[0] == null))
            {
                spellCard.WithDescription(spellDetails.desc[0]);
            }


            return(spellCard);
        }