예제 #1
0
    private IEnumerator VisitReleaseStatementAsync(JObject obj)
    {
        validate(obj, "from");

        var holder = (string)obj["from"];

        if (!storage.ContainsKey(holder))
        {
            SayError($"There is nothing in {holder}");
            yield break;
        }

        var rel = storage[holder];

        if ((new[] { "left hand", "right hand" }).Any(holder.Equals))
        {
            if (rel is Element)
            {
                var skill = CreateElementSkill(rel.ToString());
                yield return(CallSkill(skill));
            }
            else if (rel is MagicItem || rel is Item)
            {
                var skill = CreateItemSkill(rel.ToString());
                yield return(CallSkill(skill));
            }
            else if (rel is ICastSpell)
            {
                yield return(CallSkill(rel as ICastSpell));
            }
            else
            {
                SayError($"unknown skill for {holder}");
            }
        }
        if (holder == "soul")
        {
            if (rel is Element)
            {
                if (rel.ToString() == "water")
                {
                    stats.AddLife(1);
                }
                else
                {
                    SayError($"this element cannot be naturally released by humans");
                }
            }
        }
        storage.Remove(holder);

        yield return(new WaitForSeconds(0.05f));
    }