public void TestConstructor() { EffectExpression expression = new EffectExpression(); Target target = new Target(expression, TargetType.Enemy, Where.Unspecified); Assert.That(target.TargetType, Is.EqualTo(TargetType.Enemy)); Assert.That(target.Expression, Is.SameAs(expression)); Assert.That(target.Where, Is.EqualTo(Where.Unspecified)); }
/// <summary> /// Create a new <see cref="EffectConjunction"/>. /// </summary> /// <param name="expression"></param> public EffectConjunction(EffectExpression expression) { if (expression == null) { throw new ArgumentNullException("expression"); } this.Expression = expression; }
/// <summary> /// Create a new <see cref="Target"/>. /// </summary> /// <param name="expression"> /// The <see cref="EffectExpression"/> this is part of. This cannot be null. /// </param> /// <param name="targetType"> /// The actual target of the <see cref="EffectComponent"/>. /// </param> /// <param name="where"> /// Where the target is, or null if that is unspecified. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="expression"/> cannot be null. /// </exception> public Target(EffectExpression expression, TargetType targetType, Where where) { if (expression == null) { throw new ArgumentNullException("expression"); } this.Expression = expression; this.TargetType = targetType; this.Where = where; }
public void TestConstructor() { EffectExpression expression = new EffectExpression(); Dice dice = 1.D20(); Target target = new Target(expression, TargetType.Ally, Where.WithinSquares(5, Of.Target)); DiceDamageEffect effect = new DiceDamageEffect(target, dice); Assert.That(effect.Expression, Is.SameAs(expression)); Assert.That(effect.Target, Is.SameAs(target)); Assert.That(effect.Dice, Is.SameAs(dice)); }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="expression"></param> /// <returns></returns> /// <exception cref="ArgumentNullException"> /// <paramref name="expression"/> cannot be null. /// </exception> public IEnumerable<EffectSpan> Parse(Character character, EffectExpression expression) { if (character == null) { throw new ArgumentNullException("character"); } if (expression == null) { throw new ArgumentNullException("expression"); } List<List<EffectSpan>> effectSpans; List<EffectSpan> phrase; bool firstComponent; firstComponent = true; effectSpans = new List<List<EffectSpan>>(); foreach (EffectComponent component in expression.Components) { phrase = new List<EffectSpan>(); ParseEffectComponent(character, component, firstComponent, x => { if (phrase.Any()) { phrase.AddRange(new EffectSpan[] {new EffectSpan(" "), x}); } else { phrase.Add(x); } } ); effectSpans.Add(phrase); firstComponent = false; } // Clean up before returning. return effectSpans.AddConjunctions().AddTrailingPeriod().CapitalizeFirstLetter().MergeAdjacentTextSpans(); }