Ejemplo n.º 1
0
 /// <summary>
 /// Validates if the correct target type was given for the stat check.
 /// Throws an exception if invalid.
 /// </summary>
 /// <param name="targetType">The type of the current target.</param>
 private void CheckValidStatTarget(TargetToken.Type targetType)
 {
     if (targetType != TargetToken.Type.CHAR || targetType != TargetToken.Type.PARTY)
     {
         throw new LexingException(
                   "Attempted to parse a stat condition with invalid target type " + currentTargetType.ToString()
                   + ". Only Character and Party targets can have stat checks."
                   );
     }
 }
Ejemplo n.º 2
0
    private bool Parse(ExpressionNode node)
    {
        if (node is PhraseExpression)
        {
            var phraseExp = node as PhraseExpression;
            return(EvaluatePhrase(phraseExp));
        }
        else if (node is BoolExpression)
        {
            var boolExp = node as BoolExpression;
            return(EvaluateBool(boolExp));
        }
        else if (node is TargetExpression)
        {
            var targetExp = node as TargetExpression;
            // For use by PhraseExpressions
            currentTargetType = targetExp.target.value;

            // If the target is a character, evaluate the branch until one character returns true
            if (currentTargetType == TargetToken.Type.CHAR)
            {
                foreach (var character in gameData.Characters)
                {
                    currentCharacter = character;
                    if (Parse(targetExp.expression))
                    {
                        return(true);
                    }
                }
            }
            else
            {
                return(Parse(targetExp.expression));
            }
        }
        return(false);
    }