Exemple #1
0
        public List <Cards> MenuAddSpell(List <Cards> cartas)
        {
            string nome, efeito;

            Console.Write("Nome: ");
            nome = Console.ReadLine();

            Console.WriteLine("Escolha a Categoria da Carta Mágica:");
            Console.WriteLine("1 - Normal");
            Console.WriteLine("2 - Contínua");
            Console.WriteLine("3 - Jogo Rápido");
            Console.WriteLine("4 - Equipamento");
            Console.WriteLine("5 - Campo");
            Console.WriteLine("6 - Ritual");

            SpellCategory categoria = (SpellCategory)Convert.ToInt32(Console.ReadLine());

            Console.Write("Efeito: ");
            efeito = Console.ReadLine();

            SpellCard spell = new SpellCard(nome, efeito, categoria);

            cartas.Add(spell);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Magia Adicionada com Sucesso!");
            Console.ResetColor();
            Console.ReadKey();

            Console.Clear();
            return(cartas);
        }
Exemple #2
0
 public RunescapeSpell(int id, string name, int level, int air, int water, int earth, int fire, int mind,
     int body, int cosmic, int chaos, int astral, int nature, int death, int law, int blood, int soul, double exp,
     SpellCategory category, SpellType spellGroup, string description, Type requiredItem, params Type[] ingredients)
 {
     ID = id;
     Name = name;
     Level = level;
     Air = air;
     Water = water;
     Earth = earth;
     Fire = fire;
     Mind = mind;
     Body = body;
     Cosmic = cosmic;
     Chaos = chaos;
     Astral = astral;
     Nature = nature;
     Death = death;
     Law = law;
     Blood = blood;
     Soul = soul;
     Exp = exp;
     Category = category;
     SpellGroup = spellGroup;
     Description = description;
     RequiredItem = requiredItem;
     Ingredients = ingredients;
 }
Exemple #3
0
 public List <Spell> FindSpells(SpellCategory spellCategory)
 {
     return(this.FindAll(delegate(Spell s)
     {
         return s.Category == spellCategory;
     }));
 }
Exemple #4
0
 public RunescapeSpell(int id, string name, int level, int air, int water, int earth, int fire, int mind,
                       int body, int cosmic, int chaos, int astral, int nature, int death, int law, int blood, int soul, double exp,
                       SpellCategory category, SpellType spellGroup, string description, Type requiredItem, params Type[] ingredients)
 {
     ID           = id;
     Name         = name;
     Level        = level;
     Air          = air;
     Water        = water;
     Earth        = earth;
     Fire         = fire;
     Mind         = mind;
     Body         = body;
     Cosmic       = cosmic;
     Chaos        = chaos;
     Astral       = astral;
     Nature       = nature;
     Death        = death;
     Law          = law;
     Blood        = blood;
     Soul         = soul;
     Exp          = exp;
     Category     = category;
     SpellGroup   = spellGroup;
     Description  = description;
     RequiredItem = requiredItem;
     Ingredients  = ingredients;
 }
Exemple #5
0
 public RunescapeSpell(int id, string name, int level, int air, int water, int earth, int fire, int mind,
                       int body, int cosmic, int chaos, int astral, int nature, int death, int law, int blood, int soul, double exp,
                       SpellCategory category, SpellType spellGroup, string description, params Type[] ingredients)
     : this(id, name, level, air, water, earth, fire, mind, body, cosmic, chaos, astral, nature, death, law, blood,
            soul, exp, category, spellGroup, description, null, ingredients)
 {
 }
        public SpellCastComparer(SpellSelector spellSelector, SpellCategory category)
        {
            this.Category        = category;
            this.m_spellSelector = spellSelector;
            this.m_comparers     = new System.Collections.Generic.Dictionary <SpellCategory, Func <SpellCastInformations, SpellCastInformations, int> >
            {
                {
                    SpellCategory.Summoning,
                    new Func <SpellCastInformations, SpellCastInformations, int>(this.CompareSummon)
                },

                {
                    SpellCategory.Buff,
                    new Func <SpellCastInformations, SpellCastInformations, int>(this.CompareBoost)
                },

                {
                    SpellCategory.Damages,
                    new Func <SpellCastInformations, SpellCastInformations, int>(this.CompareDamage)
                },

                {
                    SpellCategory.Healing,
                    new Func <SpellCastInformations, SpellCastInformations, int>(this.CompareHeal)
                },

                {
                    SpellCategory.Curse,
                    new Func <SpellCastInformations, SpellCastInformations, int>(this.CompareCurse)
                }
            };
        }
Exemple #7
0
 public RunescapeSpell(int id, string name, int level, int air, int water, int earth, int fire, int mind,
     int body, int cosmic, int chaos, int astral, int nature, int death, int law, int blood, int soul, double exp,
     SpellCategory category, SpellType spellGroup, string description, params Type[] ingredients)
     : this(id, name, level, air, water, earth, fire, mind, body, cosmic, chaos, astral, nature, death, law, blood,
         soul, exp, category, spellGroup, description, null, ingredients)
 {
 }
Exemple #8
0
 public Spell(string name, string words, int mana, bool isRune, SpellCategory category, SpellType type)
 {
     Name     = name;
     Words    = words;
     Mana     = mana;
     IsRune   = isRune;
     Category = category;
     Type     = type;
 }
Exemple #9
0
 public SpellCastComparer(SpellSelector spellSelector, SpellCategory category)
 {
     Category        = category;
     m_spellSelector = spellSelector;
     m_comparers     = new Dictionary <SpellCategory, Func <SpellCastImpact, SpellCastImpact, int> >()
     {
         { SpellCategory.Summoning, CompareSummon },
         { SpellCategory.Buff, CompareBoost },
         { SpellCategory.Damages, CompareDamage },
         { SpellCategory.Healing, CompareHeal },
         { SpellCategory.Curse, CompareCurse },
     };
 }
Exemple #10
0
 public SpellClass(int cost, int amount, float cooldown, float castTime, string name, string desc, Spell spell, SpellCategory category, SpellType type)
 {
     this.SpellCost = cost;
     this.SpellAmount = amount;
     this.SpellBaseAmount = amount;
     this.SpellCooldown = cooldown;
     this.SpellBaseCooldown = cooldown;
     this.SpellCastTime = castTime;
     this.SpellBaseCastTime = castTime;
     this.SpellName = name;
     this.SpellDescription = desc;
     this.SpellEnum = spell;
     this.Category = category;
     this.Type = type;
 }
Exemple #11
0
        private List <Cards> MenuAddSpell(List <Cards> cartas)
        {
            try {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("MAGIA\n");
                Console.ResetColor();
                Console.Write("Nome: ");
                string nome = Console.ReadLine();

                Console.WriteLine("Escolha a Categoria da Carta Mágica:");
                Console.WriteLine("1 - Normal");
                Console.WriteLine("2 - Contínua");
                Console.WriteLine("3 - Jogo Rápido");
                Console.WriteLine("4 - Equipamento");
                Console.WriteLine("5 - Campo");
                Console.WriteLine("6 - Ritual");
                int cat = Convert.ToInt32(Console.ReadLine());

                if (cat > 6 || cat < 1)
                {
                    throw new FormatException("Categoria Inválida!");
                }

                SpellCategory categoria = (SpellCategory)cat;

                Console.Write("Efeito: ");
                string efeito = Console.ReadLine();

                SpellCard spell = new SpellCard(nome, efeito, categoria);
                cartas.Add(spell);
            }
            catch (FormatException e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ReadKey();
                Console.ResetColor();
                Console.Clear();
                MenuAddSpell(cartas);
            }
            return(cartas);
        }
Exemple #12
0
 public static g7.SpellCategory ToInternal(this SpellCategory instance)
 {
     return((g7.SpellCategory)instance);
 }
Exemple #13
0
 public SpellKey(SpellCategory category, int tier)
 {
     Category = category;
     Tier     = tier;
 }
        /// <summary>
        /// Add spellImpact for a given effect, taking into account caster bonus and target resistance.
        /// </summary>
        /// <param name="effect"></param>
        /// <param name="spellImpact"></param>
        /// <param name="caster"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static DamageType CumulEffects(EffectInstanceDice effect, ref SpellImpact spellImpact, PlayedFighter caster, Fighter target /*, Spell.SpellCategory Categories*/, Spell spell)
        {
            bool        isFriend = caster.Team.Id == target.Team.Id;
            SpellImpact result   = new SpellImpact();

            SpellTargetType targetType = (SpellTargetType)effect.targetId;


            //if ((targetType & SpellTargetType.ENEMIES) == 0) return spellImpact; // No enemy can be targeted

            SpellCategory category = GetEffectCategories(effect.effectId, spell.LevelTemplate.id) /* & Categories*/;

            if (category == 0)
            {
                return(0);              // No category selected in this spell
            }
            if (spell.Template.id == 0) // Weapon => ignore non heal or damage effects
            {
                if ((category & (SpellCategory.Damages | SpellCategory.Healing)) == 0)
                {
                    return(0);
                }
            }

            double chanceToHappen = 1.0; //

            // When chances to happen is under 100%, then we reduce spellImpact accordingly, for simplicity, but after having apply damage bonus & reduction.
            // So average damage should remain exact even if Min and Max are not.
            if (effect.random > 0)
            {
                chanceToHappen = effect.random / 100.0;
            }

            if (target.Summoned && (caster.Breed.Id != (int)BreedEnum.Osamodas || target.Team.Id != caster.Team.Id))
            {
                chanceToHappen /= 2; // It's much better to hit non-summoned foes => effect on summons (except allies summon for Osa) is divided by 2.
            }
            SpellException spellException = null;

            if (spellExceptions.ContainsKey(spell.LevelTemplate.id))
            {
                spellException = spellExceptions[spell.LevelTemplate.id];
            }
            if ((category & SpellCategory.DamagesNeutral) > 0)
            {
                AdjustDamage(result, spellException != null ? spellException.MinNeutral : effect.diceNum, spellException != null ? spellException.MaxNeutral : effect.diceSide, SpellCategory.DamagesNeutral, chanceToHappen,
                             GetSafetotal(caster, Stats.PlayerField.NeutralDamageBonus) + GetSafetotal(caster, Stats.PlayerField.DamageBonus) + GetSafetotal(caster, Stats.PlayerField.PhysicalDamage),
                             GetSafetotal(caster, Stats.PlayerField.DamageBonusPercent) + GetSafetotal(caster, Stats.PlayerField.Strength),
                             target == null ? 0 : target.Stats.NeutralElementReduction,
                             target == null ? 0 : target.Stats.NeutralResistPercent, isFriend);
            }

            if ((category & SpellCategory.DamagesFire) > 0)
            {
                AdjustDamage(result, spellException != null ? spellException.MinFire : effect.diceNum, spellException != null ? spellException.MaxFire : effect.diceSide, SpellCategory.DamagesFire, chanceToHappen,
                             GetSafetotal(caster, Stats.PlayerField.FireDamageBonus) + GetSafetotal(caster, Stats.PlayerField.DamageBonus) + GetSafetotal(caster, Stats.PlayerField.MagicDamage),
                             GetSafetotal(caster, Stats.PlayerField.DamageBonusPercent) + GetSafetotal(caster, Stats.PlayerField.Intelligence),
                             target == null ? 0 : target.Stats.FireElementReduction,
                             target == null ? 0 : target.Stats.FireResistPercent, isFriend);
            }

            if ((category & SpellCategory.DamagesAir) > 0)
            {
                AdjustDamage(result, spellException != null ? spellException.MinAir : effect.diceNum, spellException != null ? spellException.MaxAir : effect.diceSide, SpellCategory.DamagesAir, chanceToHappen,
                             GetSafetotal(caster, Stats.PlayerField.AirDamageBonus) + GetSafetotal(caster, Stats.PlayerField.DamageBonus) + GetSafetotal(caster, Stats.PlayerField.MagicDamage),
                             GetSafetotal(caster, Stats.PlayerField.DamageBonusPercent) + GetSafetotal(caster, Stats.PlayerField.Agility),
                             target == null ? 0 : target.Stats.AirElementReduction,
                             target == null ? 0 : target.Stats.AirResistPercent, isFriend);
            }

            if ((category & SpellCategory.DamagesWater) > 0)
            {
                AdjustDamage(result, spellException != null ? spellException.MinWater : effect.diceNum, spellException != null ? spellException.MaxWater : effect.diceSide, SpellCategory.DamagesWater, chanceToHappen,
                             GetSafetotal(caster, Stats.PlayerField.WaterDamageBonus) + GetSafetotal(caster, Stats.PlayerField.DamageBonus) + GetSafetotal(caster, Stats.PlayerField.MagicDamage),
                             GetSafetotal(caster, Stats.PlayerField.DamageBonusPercent) + GetSafetotal(caster, Stats.PlayerField.Chance),
                             target == null ? 0 : target.Stats.WaterElementReduction,
                             target == null ? 0 : target.Stats.WaterResistPercent, isFriend);
            }

            if ((category & SpellCategory.DamagesEarth) > 0)
            {
                AdjustDamage(result, spellException != null ? spellException.MinEarth : effect.diceNum, spellException != null ? spellException.MaxEarth : effect.diceSide, SpellCategory.DamagesEarth, chanceToHappen,
                             GetSafetotal(caster, Stats.PlayerField.EarthDamageBonus) + GetSafetotal(caster, Stats.PlayerField.DamageBonus) + GetSafetotal(caster, Stats.PlayerField.MagicDamage),
                             GetSafetotal(caster, Stats.PlayerField.DamageBonusPercent) + GetSafetotal(caster, Stats.PlayerField.Strength),
                             target == null ? 0 : target.Stats.EarthElementReduction,
                             target == null ? 0 : target.Stats.EarthResistPercent, isFriend);
            }

            if ((category & SpellCategory.Healing) > 0)
            {
                bool steal = (category & SpellCategory.Damages) > 0;
                if (steal)
                {
                    target = caster;                                                               // Probably hp steal
                }
                uint hptoHeal = (uint)(Math.Max(0, target.Stats.MaxHealth - target.Stats.Health)); // Can't heal over max
                if (steal)
                {
                    result.MinHeal = -Math.Min(hptoHeal, Math.Abs(result.MinDamage));
                    result.MaxHeal = -Math.Min(hptoHeal, Math.Abs(result.MaxDamage));
                }
                else
                {
                    bool skip = false;
                    if (spell.Template.id == 140) // Mot de reconstruction => do only use it on purpose
                    {
                        if (hptoHeal < target.Stats.Health || hptoHeal < 400)
                        {
                            skip = true;                                                   // Only heal targets with under 50% of health and at least 400 hp to heal
                        }
                    }
                    if (!skip && hptoHeal > 0)
                    {
                        AdjustDamage(result, Math.Min(effect.diceNum, hptoHeal), Math.Min(effect.diceSide, hptoHeal), SpellCategory.Healing, chanceToHappen,
                                     GetSafetotal(caster, Stats.PlayerField.HealBonus),
                                     GetSafetotal(caster, Stats.PlayerField.Intelligence),
                                     0,
                                     0, isFriend);
                        if (result.Heal > hptoHeal)
                        {
                            if (isFriend)
                            {
                                result.MinHeal = result.MaxHeal = -hptoHeal;
                            }
                            else
                            {
                                result.MinHeal = result.MaxHeal = hptoHeal;
                            }
                        }
                    }
                }
            }
            if ((category & SpellCategory.Buff) > 0)
            {
                if (isFriend)
                {
                    result.Boost -= spell.Level * chanceToHappen;
                }
                else
                {
                    result.Boost += spell.Level * chanceToHappen;
                }
            }

            if ((category & SpellCategory.Curse) > 0)
            {
                DamageType ratio = spell.Level * chanceToHappen;

                if (effect.effectId == (int)EffectsEnum.Effect_SkipTurn) // Let say this effect counts as 2 damage per level of the target
                {
                    ratio = target.Level * 2 * chanceToHappen;
                }

                if (isFriend)
                {
                    result.Curse -= 2 * ratio;
                }
                else
                {
                    result.Curse += ratio;
                }
            }
            if (isFriend)
            {
                result.Add(result);                                                                              // amplify (double) effects on friends.
            }
            if (!isFriend && ((category & SpellCategory.Damages) > 0) && result.MinDamage > target.Stats.Health) // Enough damage to kill the target => affect an arbitrary 50% of max heal (with at least current health), so strong spells are not favored anymore.
            {
                double ratio = Math.Max(target.Stats.MaxHealth / 2, target.Stats.Health) / result.MinDamage;
                result.Multiply(ratio);
            }

            if (spell.Template.id == 114) // Rekop
            {
                if (target.Stats.Health < 1000)
                {
                    result.Multiply(0.1);
                }
                else
                if (target.Stats.Health < 2000)
                {
                    result.Multiply(0.5);
                }
            }

            // Damage reflection
            if (((category & SpellCategory.Damages) > 0) && result.Damage > 0 && !isFriend)
            {
                DamageType reflected = spell.GetDamageReflection(target);
                if (reflected > 0)
                {
                    if (reflected >= spellImpact.Damage)
                    {
                        return(0);                                 // Reflect all damages
                    }
                    result.MinHeal += reflected * 2;
                    result.MaxHeal += reflected * 2;
                }
            }

            if (spell.Template.id == 0 && (category & SpellCategory.Damages) > 0) // Weapon => consider effect of "maîtrise"
            {
                Weapon weapon = caster.Character.Inventory.GetEquippedWeapon();
                if (weapon != null)
                {
                    foreach (var boost in caster.GetBoostWeaponDamagesEffects())
                    {
                        if (boost.weaponTypeId == weapon.typeId)
                        {
                            result.Multiply(1.0 + boost.delta / 100.0);
                        }
                    }
                }
            }

            if (spellImpact != null)
            {
                spellImpact.Add(result);
            }
            else
            {
                spellImpact = result;
            }
            return(result.Damage);
        }
Exemple #15
0
        public IEnumerable <SpellCast> EnumerateSpellsCast()
        {
            Func <MapPoint, uint> keySelector = null;

            foreach (KeyValuePair <SpellCategory, int> iteratorVariable0 in from x in this.Priorities
                     orderby x.Value descending
                     select x)
            {
                SpellImpactComparer comparer = new SpellImpactComparer(this, iteratorVariable0.Key);
                foreach (SpellCastInformations iteratorVariable2 in this.Possibilities.OrderBy <SpellCastInformations, SpellCastInformations>(x => x, new SpellCastComparer(this, iteratorVariable0.Key)))
                {
                    SpellCategory spellCategories = SpellIdentifier.GetSpellCategories(iteratorVariable2.Spell);
                    if ((spellCategories & ((SpellCategory)iteratorVariable0.Key)) != SpellCategory.None)
                    {
                        if (this.Fighter.AP == 0)
                        {
                            break;
                        }
                        if (iteratorVariable2.MPToUse <= this.Fighter.MP)
                        {
                            if (iteratorVariable2.IsSummoningSpell)
                            {
                                yield return(new SpellCast(iteratorVariable2.Spell, iteratorVariable2.SummonCell));
                            }
                            else
                            {
                                foreach (SpellTarget iteratorVariable4 in iteratorVariable2.Impacts.OrderByDescending <SpellTarget, SpellTarget>(x => x, comparer))
                                {
                                    int iteratorVariable5;
                                    if (this.CanReach(iteratorVariable4.Target, iteratorVariable2.Spell, out iteratorVariable5))
                                    {
                                        SpellCast iteratorVariable6 = new SpellCast(iteratorVariable2.Spell, iteratorVariable4.Target.Cell);
                                        if (iteratorVariable5 == 0)
                                        {
                                            yield return(iteratorVariable6);
                                        }
                                        else if (iteratorVariable5 <= this.Fighter.MP)
                                        {
                                            if (keySelector == null)
                                            {
                                                keySelector = entry => entry.DistanceToCell(this.Fighter.Position.Point);
                                            }
                                            MapPoint point = iteratorVariable4.Target.Position.Point.GetAdjacentCells(new Func <short, bool>(this.m_environment.CellInformationProvider.IsCellWalkable)).OrderBy <MapPoint, uint>(keySelector).FirstOrDefault <MapPoint>();
                                            if (point == null)
                                            {
                                                point = iteratorVariable4.Target.Position.Point;
                                            }
                                            Path iteratorVariable9 = new Pathfinder(this.m_environment.CellInformationProvider).FindPath(this.Fighter.Position.Cell.Id, point.CellId, false, this.Fighter.MP);
                                            if (!iteratorVariable9.IsEmpty() && (iteratorVariable9.MPCost <= this.Fighter.MP))
                                            {
                                                iteratorVariable6.MoveBefore = iteratorVariable9;
                                                yield return(iteratorVariable6);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #16
0
 public bool HasCategory(SpellCategory? category)
 {
     if (category == null) return true;
     return (category & Categories) > 0;
 }
Exemple #17
0
 public SpellCard(string nome, string effect, SpellCategory category) : base(nome)
 {
     this._effect   = effect;
     this._category = category;
 }
        private void XmlSpellsToGeneric(ref Monster monster, Attack[] spells, SpellCategory category)
        {
            if (spells != null)
            {
                foreach (var attack in spells)
                {
                    Spell spell = new Spell()
                    {
                        SpellCategory = category
                    };
                    spell.Name = attack.name;
                    if (attack.interval != 0)
                    {
                        spell.Interval = (uint)attack.interval;
                    }
                    else if (attack.speed != 0)
                    {
                        spell.Interval = (uint)attack.speed;
                    }
                    else
                    {
                        spell.Interval = ATTACK_INTERVAL_DEFAULT;
                    }

                    spell.Chance = (uint)attack.chance;

                    if (attack.name == "melee")
                    {
                        if ((attack.attack > 0) && (attack.skill > 0))
                        {
                            spell.AttackValue = attack.attack;
                            spell.Skill       = attack.skill;
                        }
                        else
                        {
                            spell.MinDamage = attack.min;
                            spell.MaxDamage = attack.max;
                        }

                        if (attack.fire != 0)
                        {
                            spell.Condition   = Condition.Fire;
                            spell.StartDamage = attack.poison;
                            spell.Tick        = (attack.tick != 0) ? attack.tick : 9000;
                        }
                        else if (attack.poison != 0)
                        {
                            spell.Condition   = Condition.Poison;
                            spell.StartDamage = attack.poison;
                            spell.Tick        = (attack.tick != 0) ? attack.tick : 4000;
                        }
                        else if (attack.energy != 0)
                        {
                            spell.Condition   = Condition.Energy;
                            spell.StartDamage = attack.energy;
                            spell.Tick        = (attack.tick != 0) ? attack.tick : 10000;
                        }
                        else if (attack.drown != 0)
                        {
                            spell.Condition   = Condition.Drown;
                            spell.StartDamage = attack.drown;
                            spell.Tick        = (attack.tick != 0) ? attack.tick : 5000;
                        }
                        else if (attack.dazzle != 0)
                        {
                            spell.Condition   = Condition.Dazzled;
                            spell.StartDamage = attack.dazzle;
                            spell.Tick        = (attack.tick != 0) ? attack.tick : 10000;
                        }
                        else if (attack.curse != 0)
                        {
                            spell.Condition   = Condition.Cursed;
                            spell.StartDamage = attack.curse;
                            spell.Tick        = (attack.tick != 0) ? attack.tick : 4000;
                        }
                        else if (attack.bleed != 0)
                        {
                            spell.Condition   = Condition.Bleeding;
                            spell.StartDamage = attack.bleed;
                            spell.Tick        = (attack.tick != 0) ? attack.tick : 4000;
                        }
                        else if (attack.physical != 0)
                        {
                            spell.Condition   = Condition.Bleeding;
                            spell.StartDamage = attack.physical;
                            spell.Tick        = (attack.tick != 0) ? attack.tick : 4000;
                        }
                    }
                    else if (attack.name == "speed")
                    {
                        spell.SpeedChange = attack.speedchange;
                        spell.Duration    = attack.duration;
                        if (attack.duration == 0)
                        {
                            spell.Duration = 10000; // Default when no duration set
                        }
                    }
                    else
                    {
                        // Always default both if max is included to be explicit
                        // Some spells don't have damage so don't include either of them
                        if (attack.max != 0)
                        {
                            spell.MinDamage = attack.min;
                            spell.MaxDamage = attack.max;
                        }

                        if (attack.attribute != null)
                        {
                            foreach (var attr in attack.attribute)
                            {
                                if (attr.key.ToLower() == "shootEffect".ToLower())
                                {
                                    spell.ShootEffect = shootTypeNames[attr.value.ToLower()];
                                }
                                else if (attr.key.ToLower() == "areaEffect".ToLower())
                                {
                                    spell.AreaEffect = magicEffectNames[attr.value.ToLower()];
                                }
                                else
                                {
                                    Console.WriteLine($"Unkown attack attribute {attr.key}");
                                }
                            }
                        }

                        if (attack.range > 0)
                        {
                            spell.Range = (uint?)attack.range;
                        }

                        if (attack.length > 0)
                        {
                            spell.Length = (uint?)attack.length;
                            spell.Spread = (uint?)attack.spread;
                            if ((spell.Length > 3) && (spell.Spread == 0))
                            {
                                spell.Spread = 3;
                            }
                        }
                        spell.Target = (attack.target == 1);

                        if (CombatDamageNames.ContainsKey(spell.Name))
                        {
                            spell.DamageElement = CombatDamageNames[spell.Name];
                        }

                        if (!string.IsNullOrEmpty(attack.monster))
                        {
                            spell.MonsterName = attack.monster;
                        }
                        else if (attack.item > 0)
                        {
                            spell.ItemId = attack.item;
                        }
                    }

                    monster.Attacks.Add(spell);
                }
            }
        }
Exemple #19
0
 public static List<SpellClass> GetSpellCategory(SpellCategory cat)
 {
     return AllSpells.FindAll(item => cat == item.Category);
 }
Exemple #20
0
 public static IEnumerable <SpellSlot> Category(this IEnumerable <SpellSlot> spells, SpellCategory category)
 => spells.Where(spell => spell.GetSpellDescriptor().TryGetCategory() == category);
 public AISpellEffectAttribute(SpellCategory category, EffectsEnum effect)
 {
     Category = category;
     Effect   = effect;
 }
 public AISpellEffectAttribute(SpellCategory category)
 {
     Category = category;
 }
Exemple #23
0
        private static void AdjustDamage(SpellTarget damages, uint damage1, uint damage2, SpellCategory category, double chanceToHappen, int addDamage, int addDamagePercent, int reduceDamage, int reduceDamagePercent, bool negativ)
        {
            double num  = damage1;
            double num2 = (damage1 >= damage2) ? damage1 : damage2;

            if (reduceDamagePercent < 100)
            {
                num  = (num * (1.0 + (double)addDamagePercent / 100.0) + (double)addDamage - (double)reduceDamage) * (1.0 - (double)reduceDamagePercent / 100.0) * chanceToHappen;
                num2 = (num2 * (1.0 + (double)addDamagePercent / 100.0) + (double)addDamage - (double)reduceDamage) * (1.0 - (double)reduceDamagePercent / 100.0) * chanceToHappen;
                if (num < 0.0)
                {
                    num = 0.0;
                }
                if (num2 < 0.0)
                {
                    num2 = 0.0;
                }
                if (negativ)
                {
                    num  *= -1.5;
                    num2 *= -1.5;
                }
                if (category <= SpellCategory.DamagesEarth)
                {
                    if (category != SpellCategory.Healing)
                    {
                        if (category != SpellCategory.DamagesWater)
                        {
                            if (category == SpellCategory.DamagesEarth)
                            {
                                damages.MinEarth += num;
                                damages.MaxEarth += num2;
                            }
                        }
                        else
                        {
                            damages.MinWater += num;
                            damages.MaxWater += num2;
                        }
                    }
                    else
                    {
                        damages.MinHeal += num;
                        damages.MaxHeal += num2;
                    }
                }
                else
                {
                    if (category != SpellCategory.DamagesAir)
                    {
                        if (category != SpellCategory.DamagesFire)
                        {
                            if (category == SpellCategory.DamagesNeutral)
                            {
                                damages.MinNeutral += num;
                                damages.MaxNeutral += num2;
                            }
                        }
                        else
                        {
                            damages.MinFire += num;
                            damages.MaxAir  += num2;
                        }
                    }
                    else
                    {
                        damages.MinAir += num;
                        damages.MaxAir += num2;
                    }
                }
            }
        }
Exemple #24
0
        private void CumulEffects(EffectDice effect, ref SpellTarget spellImpact, FightActor target, Spell spell)
        {
            bool            flag             = this.Fighter.Team.Id == target.Team.Id;
            SpellTarget     spellTarget      = new SpellTarget();
            SpellTargetType arg_2A_0         = effect.Targets;
            SpellCategory   effectCategories = SpellIdentifier.GetEffectCategories(effect.EffectId);

            if (effectCategories != SpellCategory.None)
            {
                double num = 1.0;
                if (effect.Random > 0)
                {
                    num = (double)effect.Random / 100.0;
                }
                if (target is SummonedFighter)
                {
                    num /= 2.0;
                }
                uint damage  = (uint)System.Math.Min(effect.DiceNum, effect.DiceFace);
                uint damage2 = (uint)System.Math.Max(effect.DiceNum, effect.DiceFace);
                if ((effectCategories & SpellCategory.DamagesNeutral) > SpellCategory.None)
                {
                    SpellSelector.AdjustDamage(spellTarget, damage, damage2, SpellCategory.DamagesNeutral, num, this.Fighter.Stats.GetTotal(PlayerFields.NeutralDamageBonus) + this.Fighter.Stats.GetTotal(PlayerFields.DamageBonus) + this.Fighter.Stats.GetTotal(PlayerFields.PhysicalDamage), this.Fighter.Stats.GetTotal(PlayerFields.DamageBonusPercent) + this.Fighter.Stats.GetTotal(PlayerFields.Strength), target.Stats.GetTotal(PlayerFields.NeutralElementReduction), target.Stats.GetTotal(PlayerFields.NeutralResistPercent), flag);
                }
                if ((effectCategories & SpellCategory.DamagesFire) > SpellCategory.None)
                {
                    SpellSelector.AdjustDamage(spellTarget, damage, damage2, SpellCategory.DamagesNeutral, num, this.Fighter.Stats.GetTotal(PlayerFields.FireDamageBonus) + this.Fighter.Stats.GetTotal(PlayerFields.DamageBonus) + this.Fighter.Stats.GetTotal(PlayerFields.MagicDamage), this.Fighter.Stats.GetTotal(PlayerFields.DamageBonusPercent) + this.Fighter.Stats.GetTotal(PlayerFields.Intelligence), target.Stats.GetTotal(PlayerFields.FireElementReduction), target.Stats.GetTotal(PlayerFields.FireResistPercent), flag);
                }
                if ((effectCategories & SpellCategory.DamagesAir) > SpellCategory.None)
                {
                    SpellSelector.AdjustDamage(spellTarget, damage, damage2, SpellCategory.DamagesNeutral, num, this.Fighter.Stats.GetTotal(PlayerFields.AirDamageBonus) + this.Fighter.Stats.GetTotal(PlayerFields.DamageBonus) + this.Fighter.Stats.GetTotal(PlayerFields.MagicDamage), this.Fighter.Stats.GetTotal(PlayerFields.DamageBonusPercent) + this.Fighter.Stats.GetTotal(PlayerFields.Agility), target.Stats.GetTotal(PlayerFields.AirElementReduction), target.Stats.GetTotal(PlayerFields.AirResistPercent), flag);
                }
                if ((effectCategories & SpellCategory.DamagesWater) > SpellCategory.None)
                {
                    SpellSelector.AdjustDamage(spellTarget, damage, damage2, SpellCategory.DamagesNeutral, num, this.Fighter.Stats.GetTotal(PlayerFields.WaterDamageBonus) + this.Fighter.Stats.GetTotal(PlayerFields.DamageBonus) + this.Fighter.Stats.GetTotal(PlayerFields.MagicDamage), this.Fighter.Stats.GetTotal(PlayerFields.DamageBonusPercent) + this.Fighter.Stats.GetTotal(PlayerFields.Chance), target.Stats.GetTotal(PlayerFields.WaterElementReduction), target.Stats.GetTotal(PlayerFields.WaterResistPercent), flag);
                }
                if ((effectCategories & SpellCategory.DamagesEarth) > SpellCategory.None)
                {
                    SpellSelector.AdjustDamage(spellTarget, damage, damage2, SpellCategory.DamagesNeutral, num, this.Fighter.Stats.GetTotal(PlayerFields.EarthDamageBonus) + this.Fighter.Stats.GetTotal(PlayerFields.DamageBonus) + this.Fighter.Stats.GetTotal(PlayerFields.PhysicalDamage), this.Fighter.Stats.GetTotal(PlayerFields.DamageBonusPercent) + this.Fighter.Stats.GetTotal(PlayerFields.Strength), target.Stats.GetTotal(PlayerFields.EarthElementReduction), target.Stats.GetTotal(PlayerFields.EarthResistPercent), flag);
                }
                if ((effectCategories & SpellCategory.Healing) > SpellCategory.None)
                {
                    bool flag2;
                    if (flag2 = ((effectCategories & SpellCategory.Damages) > SpellCategory.None))
                    {
                        target = this.Fighter;
                    }
                    uint num2 = (uint)System.Math.Max(0, target.MaxLifePoints - target.LifePoints);
                    if (flag2)
                    {
                        spellTarget.MinHeal = System.Math.Min(num2, System.Math.Abs(spellTarget.MinDamage));
                        spellTarget.MaxHeal = System.Math.Min(num2, System.Math.Abs(spellTarget.MaxDamage));
                    }
                    else
                    {
                        if (num2 > 0u)
                        {
                            SpellSelector.AdjustDamage(spellTarget, (uint)System.Math.Min((long)effect.DiceNum, (long)((ulong)num2)), (uint)System.Math.Min((long)effect.DiceFace, (long)((ulong)num2)), SpellCategory.Healing, num, this.Fighter.Stats.GetTotal(PlayerFields.HealBonus), this.Fighter.Stats.GetTotal(PlayerFields.Intelligence), 0, 0, !flag);
                            if (spellTarget.Heal > num2)
                            {
                                if (flag)
                                {
                                    spellTarget.MinHeal = (spellTarget.MaxHeal = num2);
                                }
                                else
                                {
                                    spellTarget.MinHeal = (spellTarget.MaxHeal = (double)(-(double)((ulong)num2)));
                                }
                            }
                        }
                    }
                }
                if ((effectCategories & SpellCategory.Buff) > SpellCategory.None)
                {
                    if (flag)
                    {
                        spellTarget.Boost += (double)spell.CurrentLevel * num;
                    }
                    else
                    {
                        spellTarget.Boost -= (double)spell.CurrentLevel * num;
                    }
                }
                if ((effectCategories & SpellCategory.Curse) > SpellCategory.None)
                {
                    double num3 = (double)spell.CurrentLevel * num;
                    if (effect.EffectId == EffectsEnum.Effect_SkipTurn)
                    {
                        num3 = (double)(target.Level * 2) * num;
                    }
                    if (flag)
                    {
                        spellTarget.Curse -= 2.0 * num3;
                    }
                    else
                    {
                        spellTarget.Curse += num3;
                    }
                }
                if (flag)
                {
                    spellTarget.Add(spellTarget);
                }
                if (!flag && (effectCategories & SpellCategory.Damages) > SpellCategory.None && spellTarget.MinDamage > (double)target.LifePoints)
                {
                    double num3 = System.Math.Max((double)target.MaxLifePoints / 2.0, (double)target.LifePoints) / spellTarget.MinDamage;
                    spellTarget.Multiply(num3);
                }
                if (spellImpact != null)
                {
                    spellImpact.Add(spellTarget);
                }
                else
                {
                    spellImpact = spellTarget;
                }
            }
        }
        private void XmlSpellsToGeneric(ref Monster monster, Attack[] spells, SpellCategory category)
        {
            if (spells != null)
            {
                foreach (var attack in spells)
                {
                    Spell spell = new Spell()
                    {
                        SpellCategory = category
                    };

                    if (!string.IsNullOrWhiteSpace(attack.script))
                    {
                        spell.Name            = attack.script;
                        spell.DefinitionStyle = SpellDefinition.TfsLuaScript;
                    }
                    else
                    {
                        // Pure XML spell name or spell name registered within spell system
                        spell.Name            = attack.name;
                        spell.DefinitionStyle = SpellDefinition.Raw;
                    }

                    if (attack.interval != 0)
                    {
                        spell.Interval = (uint)attack.interval;
                    }
                    else if (attack.speed != 0)
                    {
                        spell.Interval = (uint)attack.speed;
                    }
                    else
                    {
                        spell.Interval = ATTACK_INTERVAL_DEFAULT;
                    }

                    spell.Chance = attack.chance / 100.0;

                    if (attack.attribute != null)
                    {
                        foreach (var attr in attack.attribute)
                        {
                            if (attr.key.ToLower() == "shootEffect".ToLower())
                            {
                                spell.ShootEffect = shootTypeNames[attr.value.ToLower()];
                            }
                            else if (attr.key.ToLower() == "areaEffect".ToLower())
                            {
                                spell.AreaEffect = magicEffectNames[attr.value.ToLower()];
                            }
                            else
                            {
                                Console.WriteLine($"Unkown attack attribute {attr.key}");
                            }
                        }
                    }

                    if (attack.range > 0)
                    {
                        spell.Range = (uint?)attack.range;
                    }

                    if (attack.length > 0)
                    {
                        spell.Length = (uint?)attack.length;
                        spell.Spread = (attack.spread == -1) ? 3 : (uint?)attack.spread;
                    }

                    if (attack.radius > 0)
                    {
                        spell.Radius   = (uint?)attack.radius;
                        spell.OnTarget = (attack.target == 1);
                    }

                    if (attack.target != -1)
                    {
                        spell.OnTarget = (attack.target == 1);
                    }

                    if (attack.direction != -1)
                    {
                        spell.IsDirectional = (attack.direction == 1);
                    }

                    if (attack.name == "melee")
                    {
                        if ((attack.attack > 0) && (attack.skill > 0))
                        {
                            spell.AttackValue = attack.attack;
                            spell.Skill       = attack.skill;
                        }
                        else
                        {
                            spell.MinDamage = attack.min;
                            spell.MaxDamage = attack.max;
                        }

                        if (attack.fire != 0)
                        {
                            spell.Condition   = ConditionType.Fire;
                            spell.StartDamage = attack.poison;
                        }
                        else if (attack.poison != 0)
                        {
                            spell.Condition   = ConditionType.Poison;
                            spell.StartDamage = attack.poison;
                        }
                        else if (attack.energy != 0)
                        {
                            spell.Condition   = ConditionType.Energy;
                            spell.StartDamage = attack.energy;
                        }
                        else if (attack.drown != 0)
                        {
                            spell.Condition   = ConditionType.Drown;
                            spell.StartDamage = attack.drown;
                        }
                        else if (attack.dazzle != 0)
                        {
                            spell.Condition   = ConditionType.Dazzled;
                            spell.StartDamage = attack.dazzle;
                        }
                        else if (attack.curse != 0)
                        {
                            spell.Condition   = ConditionType.Cursed;
                            spell.StartDamage = attack.curse;
                        }
                        else if (attack.bleed != 0)
                        {
                            spell.Condition   = ConditionType.Bleeding;
                            spell.StartDamage = attack.bleed;
                        }
                        else if (attack.physical != 0)
                        {
                            spell.Condition   = ConditionType.Bleeding;
                            spell.StartDamage = attack.physical;
                        }
                        else if (attack.freeze != 0)
                        {
                            spell.Condition   = ConditionType.Freezing;
                            spell.StartDamage = attack.freeze;
                        }
                        if (spell.Condition != ConditionType.None)
                        {
                            spell.Tick = (attack.tick != 0) ? attack.tick : conditionDefaultTick[spell.Condition];
                        }
                    }
                    else if (attack.name == "speed")
                    {
                        if (attack.speedchange != 0)
                        {
                            spell.MinSpeedChange = attack.speedchange;
                            spell.MaxSpeedChange = attack.speedchange;
                        }
                        else
                        {
                            spell.MinSpeedChange = attack.minspeedchange;
                            spell.MaxSpeedChange = attack.maxspeedchange;
                        }
                    }
                    else if (attack.name == "drunk")
                    {
                        spell.Drunkenness = attack.drunkenness / 100.0;
                    }
                    else
                    {
                        if (attack.name.Contains("condition"))
                        {
                            spell.Condition   = conditionDamageNames[attack.name];
                            spell.Name        = "condition";
                            spell.Tick        = (attack.tick != 0) ? attack.tick : conditionDefaultTick[spell.Condition];
                            spell.StartDamage = attack.start;
                        }

                        // Always default both if max is included to be explicit
                        // Some spells don't have damage so don't include either of them
                        if (attack.max != 0)
                        {
                            spell.MinDamage = attack.min;
                            spell.MaxDamage = attack.max;
                        }

                        if (combatDamageNames.ContainsKey(spell.Name))
                        {
                            spell.DamageElement = combatDamageNames[spell.Name];
                            spell.Name          = "combat";
                        }

                        if (!string.IsNullOrEmpty(attack.monster))
                        {
                            spell.MonsterName = attack.monster;
                        }
                        else if (attack.item > 0)
                        {
                            spell.ItemId = attack.item;
                        }
                    }

                    if ((attack.name == "speed") || (attack.name == "outfit") || (attack.name == "invisible") || (attack.name == "drunk"))
                    {
                        spell.Duration = attack.duration;
                    }

                    monster.Attacks.Add(spell);
                }
            }
        }
Exemple #26
0
        private bool TryToCastSpell(SpellTarget target, SpellCategory category, bool checkCastState)
        {
            try
            {
                if (checkCastState && _localPlayerCharacterView.IsCasting())
                {
                    Core.Log("You are casting. Wait for casting to finish");
                    return(false);
                }

                var spells      = _combatSpells.Target(target).Category(category);
                var spellToCast = spells.Any() ? spells.First() : null;
                if (spellToCast == null)
                {
                    Core.LogOnce("Spell to Cast == Null. Exit spell cast");
                    return(false);
                }

                var spellName = "Unknown";
                try
                {
                    spellName = spellToCast.GetSpellDescriptor().TryGetName();

                    var spellSlot = spellToCast.Slot;
                    switch (target)
                    {
                    case (SpellTarget.Self):
                        Core.Log("Casting " + spellName + " on self.");
                        _localPlayerCharacterView.CastOnSelf(spellSlot);
                        break;

                    case (SpellTarget.Enemy):
                        Core.Log("Casting " + spellName + " on enemy.");
                        _localPlayerCharacterView.CastOn(spellSlot, _combatTarget);
                        break;

                    case (SpellTarget.Ground):
                        Core.Log("Casting " + spellName + " on ground.");
                        _localPlayerCharacterView.CastAt(spellSlot, _combatTarget.GetPosition());
                        break;

                    default:
                        Core.Log($"[SpellTarget {target} is not supported. Spell skipped]");
                        return(false);
                    }

                    _combatCooldown = 0.1f;
                    return(true);
                }
                catch (Exception e)
                {
                    Core.Log($"[Error while casting {spellName} ({target}/{category}/{checkCastState})]");
                    Core.Log(e);
                    return(false);
                }
            }
            catch (Exception e)
            {
                Core.Log($"[Generic casting error ({target}/{category}/{checkCastState})]");
                Core.Log(e);
                return(false);
            }
        }
Exemple #27
0
 // Fast function that says how big is the area covered by effects from a given category
 public uint GetArea(SpellCategory? category = SpellCategory.Damages)
 {
     uint area = 0;
     foreach (var effect in GetEffects())
         if ((Spell.GetEffectCategories((uint)effect.Id, LevelTemplate.id) & category) > 0)
             area = Math.Max(area, effect.Surface);
     return area;
 }
 public SpellImpactComparer(SpellSelector spellSelector, SpellCategory category)
 {
     this.Category        = category;
     this.m_spellSelector = spellSelector;
 }
Exemple #29
0
 public IEnumerable<EffectDice> GetEffects(SpellCategory? category = null)
 {
     foreach (EffectInstanceDice effect in LevelTemplate.effects)
         if (category == null || (GetEffectCategories(effect.effectId, LevelTemplate.id) & category) > 0)
             yield return new EffectDice(effect);
 }
 public SpellException(SpellCategory category)
 {
     Category = category;
 }
        private static void AdjustDamage(SpellImpact damages, uint damage1, uint damage2, SpellCategory category, double chanceToHappen, int addDamage, int addDamagePercent, int reduceDamage, int reduceDamagePercent, bool negativ)
        {
            DamageType minDamage = damage1;
            DamageType maxDamage = damage1 >= damage2 ? damage1 : damage2;

            if (reduceDamagePercent >= 100)
            {
                return; // No damage
            }
            minDamage = (DamageType)(((minDamage * (1 + (addDamagePercent / 100.0)) + addDamage) - reduceDamage) * (1 - (reduceDamagePercent / 100.0)) * chanceToHappen);
            maxDamage = (DamageType)(((maxDamage * (1 + (addDamagePercent / 100.0)) + addDamage) - reduceDamage) * (1 - (reduceDamagePercent / 100.0)) * chanceToHappen);

            if (minDamage < 0)
            {
                minDamage = 0;
            }
            if (maxDamage < 0)
            {
                maxDamage = 0;
            }


            if (negativ)           // or IsFriend
            {
                minDamage *= -1.5; // High penalty for firing on friends
                maxDamage *= -1.5; // High penalty for firing on friends
            }
            switch (category)
            {
            case SpellCategory.DamagesNeutral:
                damages.MinNeutral += minDamage;
                damages.MaxNeutral += maxDamage;
                break;

            case SpellCategory.DamagesFire:
                damages.MinFire += minDamage;
                damages.MaxAir  += maxDamage;
                break;

            case SpellCategory.DamagesAir:
                damages.MinAir += minDamage;
                damages.MaxAir += maxDamage;
                break;

            case SpellCategory.DamagesWater:
                damages.MinWater += minDamage;
                damages.MaxWater += maxDamage;
                break;

            case SpellCategory.DamagesEarth:
                damages.MinEarth += minDamage;
                damages.MaxEarth += maxDamage;
                break;

            case SpellCategory.Healing:
                damages.MinHeal += minDamage;
                damages.MaxHeal += maxDamage;
                break;
            }
        }
 public CategoryFilter(SpellCategory category)
 {
     this.category = category;
 }
Exemple #33
0
 public void AnalysePossibilities()
 {
     this.Possibilities = new System.Collections.Generic.List <SpellCastInformations>();
     foreach (Spell current in this.Fighter.Spells.Values)
     {
         SpellCategory         spellCategories       = SpellIdentifier.GetSpellCategories(current);
         SpellLevelTemplate    currentSpellLevel     = current.CurrentSpellLevel;
         SpellCastInformations spellCastInformations = new SpellCastInformations(current);
         if ((long)this.Fighter.AP >= (long)((ulong)currentSpellLevel.ApCost) && !currentSpellLevel.StatesForbidden.Any(new Func <int, bool>(this.Fighter.HasState)))
         {
             if (!currentSpellLevel.StatesRequired.Any((int state) => !this.Fighter.HasState(state)) && this.Fighter.SpellHistory.CanCastSpell(current.CurrentSpellLevel))
             {
                 if ((spellCategories & SpellCategory.Summoning) != SpellCategory.None && this.Fighter.CanSummon())
                 {
                     Cell freeAdjacentCell = this.m_environment.GetFreeAdjacentCell();
                     if (freeAdjacentCell == null)
                     {
                         continue;
                     }
                     spellCastInformations.IsSummoningSpell = true;
                     spellCastInformations.SummonCell       = freeAdjacentCell;
                 }
                 else
                 {
                     foreach (FightActor current2 in
                              from fighter in this.Fighter.Fight.Fighters
                              where fighter.IsAlive() && fighter.IsVisibleFor(this.Fighter)
                              select fighter)
                     {
                         int mPToUse;
                         if (this.CanReach(current2, current, out mPToUse) && this.Fighter.SpellHistory.CanCastSpell(current.CurrentSpellLevel, current2.Cell))
                         {
                             spellCastInformations.MPToUse = mPToUse;
                             SpellTarget spellTarget = this.ComputeSpellImpact(current, current2);
                             if (spellTarget != null)
                             {
                                 spellTarget.Target = current2;
                                 if (spellTarget.Damage >= 0.0)
                                 {
                                     spellCastInformations.Impacts.Add(spellTarget);
                                 }
                             }
                         }
                     }
                 }
                 this.Possibilities.Add(spellCastInformations);
             }
         }
     }
     if (Brain.Brain.DebugMode)
     {
         Debug.WriteLine(this.Fighter.Name);
         using (System.Collections.Generic.Dictionary <int, Spell> .ValueCollection.Enumerator enumerator = this.Fighter.Spells.Values.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 Spell spell = enumerator.Current;
                 Debug.WriteLine("Spell {0} ({1}) :: {2}", new object[]
                 {
                     spell.Template.Name,
                     spell.Id,
                     SpellIdentifier.GetSpellCategories(spell)
                 });
                 System.Collections.Generic.IEnumerable <SpellCastInformations> arg_2C4_0 = this.Possibilities;
                 Func <SpellCastInformations, bool> predicate = (SpellCastInformations x) => x.Spell == spell;
                 SpellCastInformations spellCastInformations2 = arg_2C4_0.FirstOrDefault(predicate);
                 if (spellCastInformations2 != null)
                 {
                     if (spellCastInformations2.IsSummoningSpell)
                     {
                         Debug.WriteLine("\tSummon Spell");
                     }
                     else
                     {
                         ObjectDumper objectDumper = new ObjectDumper(8);
                         objectDumper.MemberPredicate = ((System.Reflection.MemberInfo member) => !member.Name.Contains("Target"));
                         ObjectDumper objectDumper2 = objectDumper;
                         Debug.WriteLine("\t{0} Targets", new object[]
                         {
                             spellCastInformations2.Impacts.Count
                         });
                         foreach (SpellTarget spellTarget in spellCastInformations2.Impacts)
                         {
                             Debug.Write(objectDumper2.DumpElement(spellTarget));
                             if (spellTarget.Target != null)
                             {
                                 Debug.WriteLine("\t\tTarget = " + spellTarget.Target + spellTarget.Target.Id.ToString());
                             }
                         }
                     }
                 }
             }
         }
         Debug.WriteLine("");
     }
 }
 public SpellFilterChain FilterByCategory(SpellCategory category)
 {
     return(Filter(new CategoryFilter(category)));
 }
Exemple #35
0
     private static void AdjustDamage(SpellImpact damages, uint damage1, uint damage2, SpellCategory category, double chanceToHappen, int addDamage, int addDamagePercent, int reduceDamage, int reduceDamagePercent, bool negativ)
     {
         DamageType minDamage = damage1;
         DamageType maxDamage = damage1 >= damage2 ? damage1 : damage2;
         if (reduceDamagePercent >= 100)
             return; // No damage
         minDamage = (DamageType)(((minDamage * (1 + (addDamagePercent / 100.0)) + addDamage) - reduceDamage) * (1 - (reduceDamagePercent / 100.0)) * chanceToHappen);
         maxDamage = (DamageType)(((maxDamage * (1 + (addDamagePercent / 100.0)) + addDamage) - reduceDamage) * (1 - (reduceDamagePercent / 100.0)) * chanceToHappen);
         
         if (minDamage < 0) minDamage = 0;
         if (maxDamage < 0) maxDamage = 0;
     
 
         if (negativ) // or IsFriend
         {
             minDamage *= -1.5; // High penalty for firing on friends
             maxDamage *= -1.5; // High penalty for firing on friends
         }
         switch (category)
         {
             case SpellCategory.DamagesNeutral:
                 damages.MinNeutral += minDamage;
                 damages.MaxNeutral += maxDamage;
                 break;
             case SpellCategory.DamagesFire:
                 damages.MinFire += minDamage;
                 damages.MaxAir += maxDamage;
                 break;
             case SpellCategory.DamagesAir:
                 damages.MinAir += minDamage;
                 damages.MaxAir += maxDamage;
                 break;
             case SpellCategory.DamagesWater:
                 damages.MinWater += minDamage;
                 damages.MaxWater += maxDamage;
                 break;
             case SpellCategory.DamagesEarth:
                 damages.MinEarth += minDamage;
                 damages.MaxEarth += maxDamage;
                 break;
             case SpellCategory.Healing:
                 damages.MinHeal += minDamage;
                 damages.MaxHeal += maxDamage;
                 break;
         }
     }
Exemple #36
0
        public static List <PropertiesEnchantmentRegistry> GetEnchantmentsByCategory(this ICollection <PropertiesEnchantmentRegistry> value, SpellCategory spellCategory, ReaderWriterLockSlim rwLock)
        {
            if (value == null)
            {
                return(null);
            }

            rwLock.EnterReadLock();
            try
            {
                return(value.Where(e => e.SpellCategory == spellCategory).ToList());
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
Exemple #37
0
        public List <Cards> MenuEditaCarta(List <Cards> cartas)
        {
            Console.Clear();
            Console.WriteLine("EDITAR CARTA");
            Console.Write("Nome: ");
            string pesquisa = Console.ReadLine();

            Cards edit = cartas.Find(x => x.Nome == pesquisa);

            if (edit.Nome != "")
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Essa carta ainda não foi adicionada a base de dados!");
                Console.ResetColor();
            }
            else
            {
                if (edit.GetType().Equals(new MonsterCard().GetType()))
                {
                    Console.WriteLine("Insira as Novas Informações");
                    Console.Write("Nome: ");
                    string novoNome = Console.ReadLine();
                    Console.Write("Ataque: ");
                    int novoAtk = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Defesa: ");
                    int novoDef = Convert.ToInt32(Console.ReadLine());

                    MonsterCard monstro = new MonsterCard(novoNome, novoAtk, novoDef);
                    cartas.Remove(edit);
                    cartas.Add(monstro);

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Dados do Monstro Foram Atualizados!");
                    Console.ResetColor();
                    Console.ReadKey();
                    Console.Clear();
                }
                else if (edit.GetType().Equals(new SpellCard().GetType()))
                {
                    Console.WriteLine("Insira as Novas Informações");
                    Console.Write("Nome: ");
                    string novoNome = Console.ReadLine();

                    Console.WriteLine("Categoria:");
                    Console.WriteLine("1 - Normal");
                    Console.WriteLine("2 - Contínua");
                    Console.WriteLine("3 - Jogo Rápido");
                    Console.WriteLine("4 - Equipamento");
                    Console.WriteLine("5 - Campo");
                    Console.WriteLine("6 - Ritual");

                    SpellCategory novaCategoria = (SpellCategory)Convert.ToInt32(Console.ReadLine());

                    Console.Write("Efeito: ");
                    string novoEfeito = Console.ReadLine();

                    SpellCard spell = new SpellCard(novoNome, novoEfeito, novaCategoria);
                    cartas.Remove(edit);
                    cartas.Add(spell);

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Dados da Magia Foram Atualizados!");
                    Console.ResetColor();
                    Console.ReadKey();
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine("Insira as Novas Informações");
                    Console.Write("Nome: ");
                    string novoNome = Console.ReadLine();

                    Console.WriteLine("Escolha a Categoria da Carta Armadilha:");
                    Console.WriteLine("1 - Normal");
                    Console.WriteLine("2 - Contínua");
                    Console.WriteLine("3 - Resposta");

                    TrapCategory categoria = (TrapCategory)Convert.ToInt32(Console.ReadLine());

                    Console.Write("Efeito: ");
                    string novoEfeito = Console.ReadLine();

                    TrapCard trap = new TrapCard(novoNome, novoEfeito, categoria);
                    cartas.Remove(edit);
                    cartas.Add(trap);

                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine("Dados da Foram Atualizados!");
                    Console.ResetColor();
                    Console.ReadKey();
                    Console.Clear();
                }
            }

            return(cartas);
        }
Exemple #38
0
        private bool TryToCastSpell(SpellTarget target, SpellCategory category, bool checkCastState)
        {
            try
            {
                //if (checkCastState && _localPlayerCharacterView.IsCasting())
                //    return true;

                if (checkCastState && _localPlayerCharacterView.IsCasting())
                {
                    return(false);
                }



                var spells = _combatSpells.Target(target).Category(category);
                // Core.Log($"{_localPlayerCharacterView.IsCasting()}");

                SpellSlot spellToCast;
                if (spells.Count() > 1)
                {
                    Random random = new Random(DateTime.Now.Millisecond);
                    spellToCast = spells.ElementAt(random.Next(0, spells.Count()));
                }
                else
                {
                    //var spellToCast = spells.Any() ? spells.First() : null;
                    spellToCast = spells.Any() ? spells.First() : null;
                }


                if (spellToCast == null)
                {
                    return(false);
                }

                var spellName = "Unknown";
                try
                {
                    spellName = spellToCast.GetSpellDescriptor().TryGetName();
                    Core.Log($"[Casting {spellName}]");

                    var spellSlot = spellToCast.Slot;

                    castStart1 = _localPlayerCharacterView.GetCastStartTime();
                    castStart2 = _localPlayerCharacterView.GetChannelingStartTimeStamp();

                    castEnd  = _localPlayerCharacterView.GetCastEndTime();
                    castEnd2 = _localPlayerCharacterView.GetCastFinishedEndTimeStamp();

                    switch (target)
                    {
                    case (SpellTarget.Self):
                        _localPlayerCharacterView.CastOnSelf(spellSlot);
                        break;

                    case (SpellTarget.Enemy):
                        _localPlayerCharacterView.CastOn(spellSlot, _combatTarget);
                        break;

                    case (SpellTarget.Ground):
                        _localPlayerCharacterView.CastAt(spellSlot, _combatTarget.GetPosition());
                        break;

                    default:
                        Core.Log($"[SpellTarget {target} is not supported. Spell skipped]");
                        return(false);
                    }

                    _combatCooldown = 0.1f;
                    return(true);
                }
                catch (Exception e)
                {
                    Core.Log($"[Error while casting {spellName} ({target}/{category}/{checkCastState})]");
                    Core.Log(e);
                    return(false);
                }
            }
            catch (Exception e)
            {
                Core.Log($"[Generic casting error ({target}/{category}/{checkCastState})]");
                Core.Log(e);
                return(false);
            }
        }
Exemple #39
0
 public SpellException(SpellCategory category)
 {
     Category = category;
 }