public override string Execute(SpellHero s, string[] text)
        {
            string   result = null;
            Spell    _spellFetch;
            Location _loc = null;

            if (text.Length == 5 && text[3] == "to")
            {
                string _locName = text[4];
                _spellFetch = FetchSpell(s, text[1]);
                if (_spellFetch == null)
                {
                    return("You haven't learned this spell");
                }
                _loc = FetchLocation(_locName);
                if (_loc == null)
                {
                    return("There is no Location like that on the map");
                }
                result = TeleportHeroTo(s, _loc, _spellFetch);
            }
            else
            {
                result = "Wrong Spell Cast's format: Cast Teleport Spell to (X)";
            }
            return(result);
        }
        public override string Execute(SpellHero s, string[] text)
        {
            string result   = "Spell Cast is incorrect!";
            string _locName = text[3];
            Spell  _spellFetch;

            if (text.Length != 4)
            {
                return(result);
            }
            else
            {
                if (text[2] != "to")
                {
                    result = "You mean 'Teleport to'?";
                }
                else
                {
                    _spellFetch = FetchSpell(s, "teleport");
                    if (_spellFetch == null)
                    {
                        return("You haven't learned this spell");
                    }
                    result = text[2];
                    if (FetchLocation(_locName) == null)
                    {
                        return("There is no Location like that on the map");
                    }
                    FetchLocation(_locName);
                    result = TeleportHeroTo(s, FetchLocation(_locName), FetchSpell(s, "teleport"));
                }
                return(result);
            }
        }
Example #3
0
        public override string Execute(SpellHero h, string[] text)
        {
            string _result = null;
            Enemy  _target = null;
            Spell  _spellFetch;

            if (text.Length == 6 && text[4] == "enemy" && text[2] == "spell")
            {
                _spellFetch = FetchSpell(h, "explose");
                if (_spellFetch == null)
                {
                    _result = "You haven't learned this spell";
                }
                else
                {
                    _target = FetchEnemy(h, text[5]);
                    if (_target != null && EnemyManager.Instance.AttackAble(_target))
                    {
                        _result = ExploseThisEnemy(h, _target, _spellFetch);
                    }
                    else
                    {
                        _result = "There is no enemy like that.";
                    }
                }
            }
            else
            {
                _result = "Invalid Attack Command!: Cast Explose Spell to Enemy (X)";
            }
            return(_result);
        }
Example #4
0
 /// <summary>
 /// Locate spell which the Spell Hero has learned
 /// </summary>
 /// <param name="s"></param>
 /// <param name="spellId"></param>
 /// <returns></returns>
 public Spell FetchSpell(SpellHero s, string spellId)
 {
     if (!(s.LocateSpell(spellId) is GameObject))
     {
         return(null);
     }
     else
     {
         return(s.LocateSpell(spellId));
     }
 }
        /// <summary>
        /// Process the command and tell the valid spell cast to execute the its effect
        /// </summary>
        /// <param name="h">Hero h, who specify the casting command</param>
        /// <param name="text">The command</param>
        /// <returns>resutls of the casting command</returns>
        public override string Execute(Hero h, string[] text)
        {
            SpellHero s = h as SpellHero;

            if (s != null)
            {
                foreach (SpellCast c in _spellCastList)
                {
                    if (c.AreYou(text[1]))
                    {
                        return(c.Execute(s, text));
                    }
                }
                return("There is no Spell Casting like that");
            }
            return("You're not Spell-Type Hero");
        }
Example #6
0
        /// <summary>
        /// check if the Cast is success, then move the hero to targeted location
        /// else, move the player to random location and return the result
        /// </summary>
        /// <param name="h">hero which is affected by this spell</param>
        /// <param name="obj">Targetted Location, which hero want to teleport to</param>
        /// <returns></returns>
        public override string Cast(Object sHero, Object location)
        {
            SpellHero s      = sHero as SpellHero;
            string    result = "obj was not a location";

            if (location is Location)
            {
                if (sHero is SpellHero)
                {
                    if (CastingChance())
                    {
                        s.Location = (Location)location;
                        return(result = "Success!");
                    }
                }
                result += "the obj is not Spell Hero";
            }
            return(result += "Casting Fail!");
        }
Example #7
0
        /// <summary>
        /// Effect of the Spell, process on the target
        /// </summary>
        /// <param name="sHero"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override string Cast(Object sHero, Object obj)
        {
            SpellHero s      = sHero as SpellHero;
            Enemy     e      = obj as Enemy;
            string    result = "obj was not a Enemy";

            if (e is Enemy)
            {
                if (sHero is SpellHero)
                {
                    if (CastingChance())
                    {
                        e.HitTaken(e.Health / 2);
                        return(result = "Success! " + e.FullDescription);
                    }
                }
                result += "the obj is not Spell Hero";
            }
            return(result += "Casting Fail!");
        }
        public override string Execute(SpellHero h, string[] text)
        {
            string _result    = "Invalid Attack Command!: Cast Eplose the Enemy X";
            string _enemyName = text[4];
            Enemy  _target;
            Spell  _spellFetch;

            if (text.Length != 5)
            {
                return(_result);
            }
            else
            {
                if (text[3] != "enemy")
                {
                    _result = "Invalid Attack Command!: Cast eplose the Enemy X";
                }
                else
                {
                    _spellFetch = FetchSpell(h, "explose");
                    if (_spellFetch == null)
                    {
                        return("You haven't learned this spell");
                    }
                    _target = FetchEnemy(_enemyName);
                    if (_target == null)
                    {
                        return("There is no enemy like that.");
                    }
                    else if (AttackAble(h, _target))
                    {
                        _result = ExploseThisEnemy(h, _target, _spellFetch);
                    }
                }
                return(_result);
            }
        }
 private string TeleportHeroTo(SpellHero stu, Location s, Spell spell)
 {
     return(spell.Cast(stu, s));
 }
Example #10
0
 /// <summary>
 /// Cast the spell effect
 /// </summary>
 /// <param name="s">Hero</param>
 /// <param name="e">Targetted Enenmy</param>
 /// <param name="spell">Spell</param>
 /// <returns></returns>
 private string ExploseThisEnemy(SpellHero stu, Enemy e, Spell spell)
 {
     return(spell.Cast(stu, e));
 }
Example #11
0
 public abstract string Execute(SpellHero s, string[] text);
Example #12
0
 /// <summary>
 /// create 2 hero object and assign the default hero to be the Spell Type
 /// </summary>
 private HeroManager()
 {
     _spellHero   = new SpellHero();
     _meleeHero   = new MeleeHero();
     _currentHero = _spellHero;
 }
 private string TeleportHeroTo(SpellHero stu, Location s, Spell spell)
 {
     return(spell.Cast(stu, s) + " " + stu.Location.FullDescription);
 }