コード例 #1
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 1);
            Target targetToCheck = Expressions.Get <Target>(args[0], player, target, spell);
            string result        = string.Empty;

            if (targetToCheck != null)
            {
                if (player?.Game != null)
                {
                    foreach (int playerId in targetToCheck.PlayerIds)
                    {
                        Character targetedPlayer = player.Game.GetPlayerFromId(playerId);
                        if (targetedPlayer != null)
                        {
                            result += targetedPlayer.Name + ", ";
                        }
                    }

                    foreach (Creature creature in targetToCheck.Creatures)
                    {
                        result += creature.Name + ", ";
                    }

                    result = result.EverythingBeforeLast(", ");
                }
            }

            return(result);
        }
コード例 #2
0
 public static object GetData(string arg, Creature player, Target target, CastedSpell spell)
 {
     arg = arg.Trim();
     if (arg.StartsWith("\""))
     {
         return(arg);
     }
     return(Expressions.Get(arg, player, target, spell));
 }
コード例 #3
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 3);
            string           dungeonMasterMessage = Expressions.GetStr(args[0], player, target, spell, dice);
            string           floatText            = Expressions.GetStr(args[1], player, target, spell, dice);
            ValidationAction validationAction     = Expressions.Get <ValidationAction>(args[2].Trim(), player, target, spell, dice);

            Validation.OnValidationFailed(dungeonMasterMessage, floatText, validationAction);
            return(null);
        }
コード例 #4
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 2);

            DamageType damageType = (DamageType)Expressions.Get(args[0], player, target, spell);
            AttackKind attackKind = (AttackKind)Expressions.Get(args[1], player, target, spell);

            player.AddDamageResistance(damageType, attackKind);
            return(null);
        }
コード例 #5
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            ExpectingArguments(args, 1);

            VantageKind vantageKind = Expressions.Get <VantageKind>(args[0], player, target, spell);

            if (player is Character characterPlayer)
            {
                player.AddVantageThisRoll(vantageKind);
            }
            return(null);
        }
コード例 #6
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature creature, Target target = null, CastedSpell spell = null, RollResults dice = null)
        {
            ExpectingArguments(args, 1);
            string spellId = evaluator.GetSpellId(spell);

            if (creature != null)
            {
                Conditions condition = Expressions.Get <Conditions>(args[0]);

                creature.AddSpellCondition(spellId, condition);
            }

            return(null);
        }
コード例 #7
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 2);

            string variableName = args[0];
            // TODO: incorrectValue:
            //object incorrectValue = evaluator.Evaluate(Expressions.Clean(args[1]));
            object value = Expressions.Get(Expressions.Clean(args[1]), player, target, spell);

            object instance     = player;
            Type   instanceType = typeof(Character);

            if (KnownQualifiers.IsSpellQualifier(variableName))
            {
                if (evaluator.Variables.ContainsKey(Expressions.STR_CastedSpell))
                {
                    instance     = evaluator.Variables[Expressions.STR_CastedSpell];
                    instanceType = typeof(CastedSpell);
                    variableName = variableName.EverythingAfter(KnownQualifiers.Spell);
                }
            }

            FieldInfo field = instanceType.GetField(variableName);

            if (field != null)
            {
                if (instance != null)
                {
                    field.SetValue(instance, value);
                }
                return(null);
            }

            PropertyInfo property = instanceType.GetProperty(variableName);

            if (property != null)
            {
                if (instance != null)
                {
                    property.SetValue(instance, value);
                }
                return(null);
            }

            player.SetState(variableName, value);

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

            Ability    ability   = Expressions.Get <Ability>(args[0].ToLower());
            Conditions condition = Expressions.Get <Conditions>(args[1]);
            string     damageDie = "";

            if (args.Count > 2)
            {
                damageDie = args[2];
            }

            OnSavingThrowForTargetsRequested(null, new SavingThrowRollEventArgs(damageDie, condition, ability, spell));

            return(null);
        }
コード例 #9
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);
        }
コード例 #10
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature creature, Target target, CastedSpell spell, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 1, 3);
            TargetStatus targetStatus = Expressions.Get <TargetStatus>(args[0], creature, target, spell, dice);

            ea = new TargetEventArgs();
            if (args.Count > 1)
            {
                ea.MinTargets = Expressions.GetInt(args[1], creature, target, spell, dice);
                if (args.Count > 2)
                {
                    ea.MaxTargets = Expressions.GetInt(args[2], creature, target, spell, dice);
                }
            }

            ea.Player = creature as Character;
            ea.Target = target;

            ea.ShowUI       = true;
            ea.TargetStatus = targetStatus;
            OnRequestSelectTarget(ea);
            return(ea.Target);
        }
コード例 #11
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            if (player == null)
            {
                return(null);
            }

            ExpectingArguments(args, 2);

            string variableName = args[0];
            object rawValue     = Expressions.Get <object>(args[1], player, target, spell);
            double valueDouble;

            if (rawValue == null)
            {
                valueDouble = 0;
            }
            else
            {
                valueDouble = MathUtils.GetDouble(rawValue.ToString());
            }
            int valueInt = (int)Math.Round(valueDouble);

            // TODO: Wil says Convert.ConvertTo() can simplify this.

            FieldInfo field = typeof(Character).GetField(variableName);

            if (field != null)
            {
                if (field.FieldType.FullName == "System.Int32")
                {
                    field.SetValue(player, MathUtils.GetInt(field.GetValue(player).ToString()) + valueInt);
                }
                else
                {
                    field.SetValue(player, MathUtils.GetDouble(field.GetValue(player).ToString()) + valueDouble);
                }
                return(null);
            }

            PropertyInfo property = typeof(Character).GetProperty(variableName);

            if (property != null)
            {
                if (property.PropertyType.FullName == "System.Int32")
                {
                    property.SetValue(player, MathUtils.GetInt(property.GetValue(player).ToString()) + valueInt);
                }
                else
                {
                    property.SetValue(player, MathUtils.GetDouble(property.GetValue(player).ToString()) + valueDouble);
                }
                return(null);
            }

            object existingValueRaw = player.GetState(variableName);

            if (existingValueRaw != null)
            {
                if (existingValueRaw is int)
                {
                    player.SetState(variableName, MathUtils.GetInt(existingValueRaw.ToString()) + valueInt);
                }
                else
                {
                    player.SetState(variableName, MathUtils.GetDouble(existingValueRaw.ToString()) + valueDouble);
                }
                return(null);
            }

            throw new Exception($"Variable \"{variableName}\" not found.");
        }
コード例 #12
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, DiceStoppedRollingData dice = null)
        {
            if (target == null)
            {
                return(null);
            }
            ExpectingArguments(args, 1, 8);              // up to seven optional parameters of any data type.

            string spellName = Expressions.GetStr(args[0], player, target, spell);
            object data1     = null;
            object data2     = null;
            object data3     = null;
            object data4     = null;
            object data5     = null;
            object data6     = null;
            object data7     = null;

            if (args.Count > 1)
            {
                data1 = Expressions.Get(args[1], player, target, spell);
            }
            if (args.Count > 2)
            {
                data2 = Expressions.Get(args[2], player, target, spell);
            }
            if (args.Count > 3)
            {
                data3 = Expressions.Get(args[3], player, target, spell);
            }
            if (args.Count > 4)
            {
                data4 = Expressions.Get(args[4], player, target, spell);
            }
            if (args.Count > 5)
            {
                data5 = Expressions.Get(args[5], player, target, spell);
            }
            if (args.Count > 6)
            {
                data6 = Expressions.Get(args[6], player, target, spell);
            }
            if (args.Count > 7)
            {
                data7 = Expressions.Get(args[7], player, target, spell);
            }

            if (target == null || player.Game == null)
            {
                return(null);
            }

            foreach (int playerId in target.PlayerIds)
            {
                Character recipient = player.Game.GetPlayerFromId(playerId);
                if (recipient == null)
                {
                    break;
                }
                KnownSpell knownSpell = new KnownSpell();
                knownSpell.SpellName = spellName;
                knownSpell.Player    = recipient;
                recipient.GiveSpell(knownSpell, data1, data2, data3, data4, data5, data6, data7);
            }

            return(null);
        }
コード例 #13
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target = null, CastedSpell spell = null, DiceStoppedRollingData dice = null)
        {
            ExpectingArguments(args, 2, 10);
            if (player != null)
            {
                if (target == null)
                {
                    target = Expressions.Get <Target>(args[0]);
                }

                string magicItemName = Expressions.GetStr(args[1]);

                object data1 = null;
                object data2 = null;
                object data3 = null;
                object data4 = null;
                object data5 = null;
                object data6 = null;
                object data7 = null;
                object data8 = null;

                if (args.Count > 2)
                {
                    data1 = Expressions.Get(args[2], player, target, spell);
                }
                if (args.Count > 3)
                {
                    data2 = Expressions.Get(args[3], player, target, spell);
                }
                if (args.Count > 4)
                {
                    data3 = Expressions.Get(args[4], player, target, spell);
                }
                if (args.Count > 5)
                {
                    data4 = Expressions.Get(args[5], player, target, spell);
                }
                if (args.Count > 6)
                {
                    data5 = Expressions.Get(args[6], player, target, spell);
                }
                if (args.Count > 7)
                {
                    data6 = Expressions.Get(args[7], player, target, spell);
                }
                if (args.Count > 8)
                {
                    data7 = Expressions.Get(args[8], player, target, spell);
                }
                if (args.Count > 9)
                {
                    data8 = Expressions.Get(args[9], player, target, spell);
                }


                //if (target == null)
                //	target = player.ActiveTarget;
                // TODO: consider passing in the spell name as well for unique id (if castedSpell is valid).
                player.GiveMagic(magicItemName, spell, target, data1, data2, data3, data4, data5, data6, data7, data8);
            }

            return(null);
        }
コード例 #14
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            ExpectingArguments(args, 3, 11);
            if (player == null || spell == null)
            {
                return(null);
            }
            string               effectName               = Expressions.GetStr(args[0]);
            ProjectileKind       projectileKind           = ProjectileKind.EachTarget;
            int                  projectileCount          = 1;
            float                speed                    = 20;
            FireCollisionEventOn fireCollisionEventOn     = FireCollisionEventOn.EachImpact;
            float                launchTimeVariance       = 0;
            float                targetVariance           = 0;
            ProjectileSizeOption projectileSize           = ProjectileSizeOption.ConstantSize;
            float                projectileSizeMultiplier = 1;
            float                bezierPathMultiplier     = 1;

            if (args.Count > 1)
            {
                projectileKind = Expressions.Get <ProjectileKind>(args[1]);
                if (args.Count > 2)
                {
                    int.TryParse(args[2], out projectileCount);
                    if (args.Count > 3)
                    {
                        float.TryParse(args[3], out speed);

                        if (args.Count > 4)
                        {
                            fireCollisionEventOn = Expressions.Get <FireCollisionEventOn>(args[4]);
                            if (args.Count > 5)
                            {
                                float.TryParse(args[5], out launchTimeVariance);
                                if (args.Count > 6)
                                {
                                    float.TryParse(args[6], out targetVariance);
                                    if (args.Count > 7)
                                    {
                                        projectileSize = Expressions.Get <ProjectileSizeOption>(args[7]);
                                        if (args.Count > 8)
                                        {
                                            float.TryParse(args[8], out projectileSizeMultiplier);
                                            if (args.Count > 9)
                                            {
                                                float.TryParse(args[9], out bezierPathMultiplier);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            ProjectileEffectEventArgs ea = new ProjectileEffectEventArgs(effectName, spell.ID, player.taleSpireId, speed, projectileCount, projectileKind, fireCollisionEventOn, launchTimeVariance, targetVariance, target, projectileSize, projectileSizeMultiplier, bezierPathMultiplier);

            LaunchProjectile?.Invoke(null, ea);

            return(null);
        }
コード例 #15
0
        public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null)
        {
            ExpectingArguments(args, 1, 9);
            if (player == null)
            {
                return(null);
            }

            string spellId;

            if (spell == null)
            {
                spellId = Guid.NewGuid().ToString();
            }
            else
            {
                spellId = spell.ID;
            }

            string         effectName        = Expressions.GetStr(args[0]);
            float          lifeTime          = 0;
            float          secondsDelayStart = 0;
            float          enlargeTime       = 0;
            float          shrinkTime        = 0;
            float          rotation          = 0;
            float          wallLength        = 0;
            float          distanceBetweenWallEffectsFeet = 2.5f;
            EffectLocation effectLocation = EffectLocation.CreatureBase;

            if (args.Count > 1)
            {
                lifeTime = (float)Expressions.GetDouble(args[1]);
                if (args.Count > 2)
                {
                    effectLocation = Expressions.Get <EffectLocation>(args[2]);
                    if (args.Count > 3)
                    {
                        secondsDelayStart = Expressions.GetFloat(args[3]);
                        if (args.Count > 4)
                        {
                            enlargeTime = Expressions.GetFloat(args[4]);
                            if (args.Count > 5)
                            {
                                shrinkTime = Expressions.GetFloat(args[5]);
                                if (args.Count > 6)
                                {
                                    rotation = Expressions.GetFloat(args[6]);
                                    if (args.Count > 7)
                                    {
                                        wallLength = Expressions.GetFloat(args[7]);
                                        if (args.Count > 8)
                                        {
                                            distanceBetweenWallEffectsFeet = Expressions.GetFloat(args[8]);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            OnPlayKnownEffect(effectName, spellId, player.taleSpireId, lifeTime, effectLocation, secondsDelayStart, enlargeTime, shrinkTime, rotation, wallLength, distanceBetweenWallEffectsFeet);

            return(null);
        }