Exemplo n.º 1
0
        private static void ExpressionEvaluator_EvaluateFunction(object sender, FunctionEvaluationEventArg e)
        {
            Character   player      = GetPlayer(e.Evaluator.Variables);
            CastedSpell castedSpell = GetCastedSpell(e.Evaluator.Variables);
            Creature    target      = GetTargetCreature(e.Evaluator.Variables);
            DndFunction function    = functions.FirstOrDefault(x => x.Handles(e.Name, player, castedSpell));

            if (function != null)
            {
                e.Value = function.Evaluate(e.Args, e.Evaluator, player, target, castedSpell);
                Log($"  {e.Name}({GetArgsStr(e.Args)}) => {GetValueStr(e.Value)}");
            }
        }
Exemplo n.º 2
0
        private static void ExpressionEvaluator_EvaluateFunction(object sender, FunctionEvaluationEventArg e)
        {
            Creature    player      = GetPlayer(e.Evaluator.Variables);
            CastedSpell castedSpell = GetCastedSpell(e.Evaluator.Variables);
            Target      target      = GetTargetCreature(e.Evaluator.Variables);
            RollResults dice        = GetDiceStoppedRollingData(e.Evaluator.Variables);
            DndFunction function    = functions.FirstOrDefault(x => x.Handles(e.Name, player, castedSpell));

            if (function != null)
            {
                try
                {
                    e.Value = function.Evaluate(e.Args, e.Evaluator, player, target, castedSpell, dice);
                    Log($"  {e.Name}({GetArgsStr(e.Args)}) => {GetValueStr(e.Value)}");
                }
                catch                 //(Exception ex)
                {
                    e.Value = null;
                    Log($"  Exception thrown trying to evaluate {e.Name}({GetArgsStr(e.Args)})");
                }
            }
        }
Exemplo n.º 3
0
 public static void AddFunction(DndFunction function)
 {
     functions.Add(function);
 }