public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            CreaturePlusModId recipient = Expressions.GetCustomData <CreaturePlusModId>(evaluator.Variables);

            if (recipient == null)
            {
                throw new Exception($"CreaturePlusModId recipient must be specified before evaluating expressions containing AddPropertyMod.");
            }

            ExpectingArguments(args, 2, 3);
            string propertyName = string.Empty;

            if (args[0] is string)
            {
                propertyName = args[0];
            }
            double offset     = Expressions.GetDouble(args[1], player, target, spell);
            double multiplier = 1;

            if (args.Count == 3)
            {
                multiplier = Expressions.GetDouble(args[2], player, target, spell);
            }

            recipient.Creature.AddPropertyMod(propertyName, recipient.ID, offset, multiplier);
            return(null);
        }
Example #2
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Character player, Target target = null, CastedSpell spell = null, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 0);
            Dictionary <DamageType, int> latestDamage = Expressions.GetCustomData <Dictionary <DamageType, int> >(evaluator.Variables);

            if (latestDamage == null)
            {
                return(null);
            }

            foreach (Creature creature in target.Creatures)
            {
                InGameCreature inGameCreature = AllInGameCreatures.GetByCreature(creature);
                inGameCreature.StartTakingDamage();
                if (inGameCreature != null)
                {
                    foreach (DamageType damageType in latestDamage.Keys)
                    {
                        // TODO: pass in AttackKind with the custom data
                        if (creature.IsVulnerableTo(damageType, AttackKind.Magical))
                        {
                            player.Game.TellDungeonMaster($"{inGameCreature.Name} is vulnerable to {damageType} damage.");
                        }
                        else if (creature.IsResistantTo(damageType, AttackKind.Magical))
                        {
                            player.Game.TellDungeonMaster($"{inGameCreature.Name} is resistant to {damageType} damage.");
                        }
                        inGameCreature.TakeSomeDamage(player, damageType, AttackKind.Magical, latestDamage[damageType]);
                    }
                }
                inGameCreature.FinishTakingDamage();
                // TODO: Also get players from the target and work with them.
            }
            return(null);
        }
Example #3
0
        public static object ApplyDamage(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, double multiplier = 1)
        {
            Dictionary <DamageType, int> latestDamage = Expressions.GetCustomData <Dictionary <DamageType, int> >(evaluator.Variables);

            if (latestDamage == null)
            {
                return(null);
            }

            foreach (Creature creature in target.Creatures)
            {
                InGameCreature inGameCreature = AllInGameCreatures.GetByCreature(creature);
                inGameCreature.StartTakingDamage();
                if (inGameCreature != null)
                {
                    foreach (DamageType damageType in latestDamage.Keys)
                    {
                        // TODO: pass in AttackKind with the custom data
                        if (creature.IsVulnerableTo(damageType, AttackKind.Magical))
                        {
                            player?.Game.TellDungeonMaster($"{inGameCreature.Name} is vulnerable to {damageType} damage.");
                        }
                        else if (creature.IsResistantTo(damageType, AttackKind.Magical))
                        {
                            player?.Game.TellDungeonMaster($"{inGameCreature.Name} is resistant to {damageType} damage.");
                        }
                        inGameCreature.TakeSomeDamage(player?.Game, damageType, AttackKind.Magical, (int)Math.Floor(latestDamage[damageType] * multiplier));
                    }
                }
                inGameCreature.FinishTakingDamage();
                // TODO: Also get players from the target and work with them.
            }
            return(null);
        }
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            ExpectingArguments(args, 0, 1);


            float secondsDelayStart = 0;

            if (args.Count > 0)
            {
                float.TryParse(args[0], out secondsDelayStart);
            }

            Magic magic = Expressions.GetCustomData <Magic>(evaluator.Variables);

            if (magic != null && target != null && target.Creatures != null && target.Creatures.Count > 0)
            {
                foreach (Creature creature in target.Creatures)
                {
                    OnClearAttached(magic.Id, creature.taleSpireId, secondsDelayStart);
                }
            }

            string spellId = evaluator.GetSpellId(spell);

            if (player == null || spellId == null)
            {
                return(null);
            }

            OnClearAttached(spellId, player.taleSpireId, secondsDelayStart);

            return(null);
        }
Example #5
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            ExpectingArguments(args, 0);

            CreaturePlusModId recipient = Expressions.GetCustomData <CreaturePlusModId>(evaluator.Variables);

            OnRequestCardReveal(new CreaturePlusModIdEventArgs(recipient));
            return(null);
        }
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            ExpectingArguments(args, 1, 6);
            string spellId = null;

            if (spell != null)
            {
                spellId = spell.ID;
            }
            else
            {
                CreaturePlusModId creaturePlusModId = Expressions.GetCustomData <CreaturePlusModId>(evaluator.Variables);
                if (creaturePlusModId != null)
                {
                    spellId = creaturePlusModId.Guid;
                }
            }
            float lifeTime        = 0;
            float shrinkTime      = 0;
            float rotationDegrees = 0;

            if (player != null && spellId != null)
            {
                string effectName        = Expressions.GetStr(args[0]);
                float  secondsDelayStart = 0;
                float  enlargeTime       = 0;
                if (args.Count > 1)
                {
                    float.TryParse(args[1], out secondsDelayStart);
                    if (args.Count > 2)
                    {
                        float.TryParse(args[2], out enlargeTime);
                        if (args.Count > 3)
                        {
                            float.TryParse(args[3], out lifeTime);
                            if (args.Count > 4)
                            {
                                float.TryParse(args[4], out shrinkTime);
                                if (args.Count > 5)
                                {
                                    float.TryParse(args[5], out rotationDegrees);
                                }
                            }
                        }
                    }
                }

                OnAttachChargingEffect(effectName, spellId, player.taleSpireId, secondsDelayStart, enlargeTime, lifeTime, shrinkTime, rotationDegrees);
            }

            return(null);
        }
Example #7
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            CreaturePlusModId recipient = Expressions.GetCustomData <CreaturePlusModId>(evaluator.Variables);

            if (recipient == null)
            {
                throw new Exception($"CreaturePlusModId recipient must be specified before evaluating expressions containing RemovePropertyMod.");
            }

            ExpectingArguments(args, 0);

            recipient.Creature.RemoveVantageMod(recipient.ID);
            return(null);
        }
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            Creature modOwner = Expressions.GetCustomData <Creature>(evaluator.Variables);

            if (modOwner == null)
            {
                throw new Exception($"Creature mod owner must be specified before evaluating expressions containing RemovePropertyMod.");
            }

            ExpectingArguments(args, 2);
            string propertyName = Expressions.GetStr(args[0], player, target, spell);
            string id           = Expressions.GetStr(args[1], player, target, spell);

            modOwner.RemovePropertyMod(propertyName, id);
            return(null);
        }
Example #9
0
        public static string GetSpellId(this ExpressionEvaluator evaluator, CastedSpell spell)
        {
            string spellId = null;

            if (spell != null)
            {
                spellId = spell.ID;
            }
            else
            {
                CreaturePlusModId creaturePlusModId = Expressions.GetCustomData <CreaturePlusModId>(evaluator.Variables);
                if (creaturePlusModId != null)
                {
                    spellId = creaturePlusModId.Guid;
                }
            }

            return(spellId);
        }
        public static object ApplyDamage(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, double multiplier = 1)
        {
            Dictionary <DamageType, int> latestDamage = Expressions.GetCustomData <Dictionary <DamageType, int> >(evaluator.Variables);

            if (latestDamage == null)
            {
                return(null);
            }

            foreach (Creature creature in target.Creatures)
            {
                InGameCreature inGameCreature = AllInGameCreatures.GetByCreature(creature);
                if (inGameCreature != null)
                {
                    inGameCreature.StartTakingDamage();
                    if (inGameCreature != null)
                    {
                        foreach (DamageType damageType in latestDamage.Keys)
                        {
                            // TODO: pass in AttackKind with the custom data
                            ReportOnVulnerabilitiesAndResistance(player?.Game, creature, inGameCreature.Name, damageType);
                            inGameCreature.TakeSomeDamage(player?.Game, damageType, AttackKind.Magical, (int)Math.Floor(latestDamage[damageType] * multiplier));
                        }
                    }
                    inGameCreature.FinishTakingDamage();
                }
                else
                {
                    if (creature is Character thisPlayer)
                    {
                        foreach (DamageType damageType in latestDamage.Keys)
                        {
                            // TODO: pass in AttackKind with the custom data
                            thisPlayer.TakeDamage(damageType, AttackKind.Any, latestDamage[damageType]);
                            ReportOnVulnerabilitiesAndResistance(thisPlayer.Game, creature, thisPlayer.firstName, damageType);
                        }
                    }
                }
            }
            return(null);
        }
Example #11
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Character player, Target target = null, CastedSpell spell = null, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 0);
            Dictionary <DamageType, int> latestDamage = Expressions.GetCustomData <Dictionary <DamageType, int> >(evaluator.Variables);

            if (latestDamage == null)
            {
                return(null);
            }

            foreach (Creature creature in target.Creatures)
            {
                InGameCreature inGameCreature = AllInGameCreatures.GetByCreature(creature);
                if (inGameCreature != null)
                {
                    inGameCreature.TakeHalfDamage(player, latestDamage, AttackKind.Magical);
                }
                // TODO: Also get players from the target and work with them.
            }
            return(null);
        }
Example #12
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target = null, CastedSpell spell = null, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 1, 4);
            string fillColor    = "player";
            string outlineColor = "player";
            int    delayMs      = 0;

            if (args.Count > 1)
            {
                fillColor = args[1].Trim();
                if (args.Count > 2)
                {
                    outlineColor = args[2].Trim();
                    if (args.Count > 3)
                    {
                        delayMs = Expressions.GetInt(args[3], player, target, spell, dice);
                    }
                }
            }

            CreaturePlusModId recipient = Expressions.GetCustomData <CreaturePlusModId>(evaluator.Variables);

            if (recipient != null && recipient.Creature is Character recipientPlayer)
            {
                recipientPlayer.ShowState(Expressions.GetStr(args[0], player, target, spell), fillColor, outlineColor, delayMs);
            }
            else if (player != null)
            {
                player.ShowState(Expressions.GetStr(args[0], player, target, spell), fillColor, outlineColor, delayMs);
            }
            else if (recipient.Creature != null)
            {
                recipient.Creature.ShowState(Expressions.GetStr(args[0], player, target, spell), fillColor, outlineColor, delayMs);
                // TODO: Implement FloatCreatureText
                //FloatCreatureText(recipient.Creature, args[0]);
            }
            return(null);
        }
Example #13
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Character player, Target target, CastedSpell spell, DiceStoppedRollingData dice = null)
        {
            CreaturePlusModId recipient = Expressions.GetCustomData <CreaturePlusModId>(evaluator.Variables);

            if (recipient == null)
            {
                throw new Exception($"CreaturePlusModId recipient must be specified before evaluating expressions containing AddPropertyMod.");
            }

            ExpectingArguments(args, 4);
            DiceRollType rollType = Expressions.Get <DiceRollType>(args[0], player, target, spell);
            Skills       skills   = Expressions.Get <Skills>(args[1].Trim(), player, target, spell);
            string       dieLabel = args[2].Trim();

            if (dieLabel.StartsWith("\""))
            {
                dieLabel = Expressions.GetStr(dieLabel, player, target, spell);
            }
            int vantageOffset = Expressions.GetInt(args[3], player, target, spell);

            recipient.Creature.AddVantageMod(recipient.ID, rollType, skills, dieLabel, vantageOffset);
            return(null);
        }