Exemple #1
0
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate == "@start" ||
            candidate == "@pause" ||
            candidate == "@resume" ||
            candidate == "@global prepend" ||
            candidate == "@global append");
 }
Exemple #2
0
        public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
        {
            var property = candidate.Substring(1);

            return(candidate[0] == '*' &&
                   (TextWords.Contains(property) ||
                    property == "show" ||
                    property == "then"));
        }
Exemple #3
0
        public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
        {
            if (context.CurrentComponent is SceneInstructionContainer container && container.Group)
            {
                context.Components.Pop();
                return(InterpreterResult.Empty);
            }

            throw new InvalidSkillFlowDefinitionException("Invalid indentation = unable to determine group", context.LineNumber);
        }
        public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
        {
            var pieces = candidate.Split(new[] { ' ' }, 4, StringSplitOptions.RemoveEmptyEntries);

            if (pieces[2] == "to" || pieces[2] == "as")
            {
                return(new InterpreterResult(new Set(pieces[1], pieces[3])));
            }

            throw new InvalidSkillFlowDefinitionException("Invalid set command", context.LineNumber);
        }
        public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
        {
            var pieces = candidate.Split(new[] { ' ' }, 4, StringSplitOptions.RemoveEmptyEntries);

            if (pieces[2] == "to" && pieces[3][0] == '\'')
            {
                return(new InterpreterResult(new SlotAssignment(pieces[1], pieces[3].Trim('\''))));
            }

            throw new InvalidSkillFlowDefinitionException("Invalid slot assignmnet command", context.LineNumber);
        }
        public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
        {
            var pieces = candidate.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (pieces[2] == "by" && int.TryParse(pieces[3], out var value))
            {
                if (pieces[0] == "increase")
                {
                    return(new InterpreterResult(new Increase(pieces[1], value)));
                }

                return(new InterpreterResult(new Decrease(pieces[1], value)));
            }
            throw new InvalidSkillFlowDefinitionException("Invalid increment command", context.LineNumber);
        }
        public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
        {
            var splits = candidate.Split(new[] { ' ' }, 2);

            if (splits[0] == "flag")
            {
                return(new InterpreterResult(new Flag(splits[1])));
            }

            if (splits[0] == "unflag")
            {
                return(new InterpreterResult(new Unflag(splits[1])));
            }

            throw new InvalidSkillFlowDefinitionException("Invalid flag statement", context.LineNumber);
        }
        public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
        {
            var keyvalue = candidate.Split(new[] { ':' }, 2).Select(s => s.Trim()).ToArray();

            if (keyvalue.Length < 2)
            {
                throw new InvalidSkillFlowDefinitionException($"Unable to interpret visual property {candidate}", context.LineNumber);
            }

            if (!_validProperties.Contains(keyvalue[0]) || !quoters.Contains(keyvalue[1][0]) || !quoters.Contains(keyvalue[1].Last()))
            {
                throw new InvalidSkillFlowDefinitionException($"Unable to interpret visual property {keyvalue[0]}", context.LineNumber);
            }

            var property = new VisualProperty(keyvalue[0], keyvalue[1].Substring(1, keyvalue[1].Length - 2));

            return(new InterpreterResult(property));
        }
Exemple #9
0
        public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
        {
            if (context.CurrentComponent is Text)
            {
                context.Components.Pop();
            }
            var property = candidate.Substring(1);

            switch (property)
            {
            case "show":
                return(new InterpreterResult(new Visual()));

            case "then":
                return(new InterpreterResult(new SceneInstructions()));

            default:
                return(new InterpreterResult(new Text(candidate.Substring(1))));
            }
        }
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate.IndexOf(':') > -1 && candidate.IndexOfAny(quoters) > -1);
 }
Exemple #11
0
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate == "}");
 }
Exemple #12
0
 public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(new InterpreterResult(new Hear(candidate.Substring(5, candidate.Length - 6)
                                           .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()))));
 }
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate.Length > 5 && candidate.IndexOf(' ') == candidate.LastIndexOf(' ') &&
            (candidate.StartsWith("flag ") || candidate.StartsWith("unflag ")));
 }
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate.Length > 5 && candidate.StartsWith("set ") && (candidate.Contains(" to ") || candidate.Contains(" as ")));
 }
Exemple #15
0
 public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate == "||"
         ? new InterpreterResult(new Variation())
         : new InterpreterResult(new TextLine(candidate)));
 }
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate.Length > 7 &&
            candidate.IndexOf(' ') == candidate.LastIndexOf(' ') &&
            candidate.StartsWith("clear "));
 }
Exemple #17
0
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate.Length > 3 && candidate[0] == '@' &&
            candidate.Skip(1).All(c => char.IsLetterOrDigit(c) || c == ' '));
 }
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate.StartsWith("<->") || candidate.StartsWith("->"));
 }
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate.StartsWith("slot ") && candidate.Contains(" to ") && candidate.Last() == '\'');
 }
Exemple #20
0
 public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(new InterpreterResult(new Scene(candidate.Substring(1))));
 }
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate.Length > 13 && (candidate.StartsWith("increase ") || candidate.StartsWith("decrease ")) && char.IsNumber(candidate.Last()));
 }
        public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
        {
            var splits = candidate.Split(new[] { ' ' }, 2);

            return(splits[1] == "*" ? new InterpreterResult(new ClearAll()) : new InterpreterResult(new Clear(splits[1])));
        }
Exemple #23
0
        public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
        {
            var sceneName = candidate.Substring(1);

            return(new InterpreterResult(new Scene(sceneName)));
        }
Exemple #24
0
 public bool CanInterpret(string candidate, SkillFlowInterpretationContext context)
 {
     return(candidate.Length > 5 && candidate.StartsWith("if ") && candidate.EndsWith("{"));
 }
 public InterpreterResult Interpret(string candidate, SkillFlowInterpretationContext context)
 {
     context.Comments.Add(candidate.Substring(2));
     return(InterpreterResult.Empty);
 }