Esempio n. 1
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);
        }
Esempio n. 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);
        }
        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);
        }