public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, DiceStoppedRollingData dice = null) { ExpectingArguments(args, 4); string tableName = evaluator.Evaluate <string>(args[0]); string fieldLookup = evaluator.Evaluate <string>(args[1]); string matchColumn = evaluator.Evaluate <string>(args[2]); object matchValue = evaluator.Evaluate(Expressions.Clean(args[3])); return(AllTables.GetData(tableName, fieldLookup, matchColumn, matchValue)); }
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); }