Exemplo n.º 1
0
        public void TestUnderflowComplex(string input, string expected, string expectedSerialized)
        {
            var tokenizer = Tokenizer.CreateTokenizer(input);
            var expr      = ExpressionBase.Parse(new PositionalTokenizer(tokenizer));

            var scope = new InterpreterScope(RATools.Parser.AchievementScriptInterpreter.GetGlobalScope());

            scope.Context = new RATools.Parser.TriggerBuilderContext();

            ExpressionBase result;

            if (!expr.ReplaceVariables(scope, out result))
            {
                Assert.That(result, Is.InstanceOf <ParseErrorExpression>());
            }

            var builder = new StringBuilder();

            result.AppendString(builder);
            Assert.That(builder.ToString(), Is.EqualTo(expected));

            var achievementBuilder = new RATools.Parser.ScriptInterpreterAchievementBuilder();

            achievementBuilder.PopulateFromExpression(result);
            var serialized = achievementBuilder.SerializeRequirements();

            Assert.That(serialized, Is.EqualTo(expectedSerialized));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a serialized string for determining if memory matches the provided expression.
        /// </summary>
        /// <param name="expression">The expression to process.</param>
        /// <param name="scope">The scope.</param>
        /// <param name="result">[out] The error if not successful.</param>
        /// <returns><c>true</c> if successful, <c>false</c> if not.</returns>
        public static string GetConditionString(ExpressionBase expression, InterpreterScope scope, out ExpressionBase result)
        {
            var achievement = new ScriptInterpreterAchievementBuilder();

            if (!ProcessAchievementConditions(achievement, expression, scope, out result))
            {
                return(null);
            }

            return(achievement.SerializeRequirements());
        }