Beispiel #1
0
        public void Cast(SpellCard spell, Container target)
        {
            var Mana = Container.GetComponent <Mana>();

            if (Mana == null)
            {
                throw new ArgumentException("No mana in container");
            }
            if (spell == null)
            {
                throw new ArgumentNullException(nameof(spell));
            }
            if (!SpellCards.Contains(spell))
            {
                throw new ArgumentException("It is'not my spell");
            }

            if (Mana.Value < spell.GetComponent <Cost>().Value)
            {
                throw new ArgumentException("Low mana");
            }

            Mana.DeltaMana(-spell.GetComponent <Cost>().Value);
            spell.GetComponent <Spell>().Use(target);

            if (OnSpellCast != null)
            {
                OnSpellCast.Invoke(new SessionChange()); //TODO
            }
        }
Beispiel #2
0
        public void Cast(SpellCard spell, Position target)
        {
            if (target.CompareTo(Container.Session.Map.Size) >= 0)
            {
                throw new ArgumentException("Too big position");
            }
            var f = Container.Session.Map.FindByPosition(target).Positioned;

            if (f == null)
            {
                throw new ArgumentException("No target in this position");
            }
            try
            { Cast(spell, f); }
            catch { throw; }
        }