예제 #1
0
 public override decimal evalPercent(EvaluationContext context)
 {
     decimal operandValue = operand.evalPercent(context);
     switch (operator_.text)
     {
         case "-": return -operandValue;
     }
     throw null;
 }
예제 #2
0
 public override decimal evalPercent(EvaluationContext context)
 {
     return value.value;
 }
예제 #3
0
 public override int evalInt(EvaluationContext context)
 {
     int operandValue = operand.evalInt(context);
     switch (operator_.text)
     {
         case "-": return -operandValue;
     }
     throw null;
 }
예제 #4
0
 public override int evalInt(EvaluationContext context)
 {
     return context.evalInt(token.text);
 }
예제 #5
0
 public override int evalInt(EvaluationContext context)
 {
     return value.value;
 }
예제 #6
0
 public override decimal evalPercent(EvaluationContext context)
 {
     if (condition.evalBoolean(context))
         return thenPart.evalPercent(context);
     else
         return operand.evalPercent(context);
 }
예제 #7
0
 public override bool evalBoolean(EvaluationContext context)
 {
     return context.evalBoolean(token.text);
 }
예제 #8
0
 public override decimal evalPercent(EvaluationContext context)
 {
     if (left.ToString().Contains("level"))
         return left.evalInt(context) * right.evalPercent(context);
     else
         return left.evalPercent(context) * right.evalInt(context);
 }
예제 #9
0
 public override bool evalBoolean(EvaluationContext context)
 {
     return value.value;
 }
예제 #10
0
 public override bool evalBoolean(EvaluationContext context)
 {
     switch (operator_.text)
     {
         case "<=": return left.evalInt(context) <= right.evalInt(context);
         case "<": return left.evalInt(context) < right.evalInt(context);
         case ">=": return left.evalInt(context) >= right.evalInt(context);
         case ">": return left.evalInt(context) > right.evalInt(context);
         case "AND": return left.evalBoolean(context) && right.evalBoolean(context);
         case "OR": return left.evalBoolean(context) || right.evalBoolean(context);
     }
     throw null;
 }
예제 #11
0
 public override int evalInt(EvaluationContext context)
 {
     int leftValue = left.evalInt(context);
     int rightValue = right.evalInt(context);
     switch (operator_.text)
     {
         case "*": return leftValue * rightValue;
         case "/": return leftValue / rightValue;
         case "+": return leftValue + rightValue;
         case "-": return leftValue - rightValue;
     }
     throw null;
 }
예제 #12
0
 public virtual decimal evalPercent(EvaluationContext context)
 {
     throw new NotImplementedException();
 }
예제 #13
0
 public virtual int evalInt(EvaluationContext context)
 {
     throw new NotImplementedException();
 }
예제 #14
0
 public virtual bool evalBoolean(EvaluationContext context)
 {
     throw new NotImplementedException();
 }
예제 #15
0
 private int getUnmodifiedCost()
 {
     EvaluationContext context = new EvaluationContext(character, this, purchasedLevels);
     if (property is Advantage)
         return ((Advantage)property).costFormula.evalInt(context);
     if (property is AbstractSkill)
     {
         // purchased: 0, 1, 2, 3, 4, ... +1
         // cost:      0, 1, 2, 4, 8, ... +4
         return purchasedLevels < 3 ? purchasedLevels : 4 * (purchasedLevels - 2);
     }
     if (property is AttributeFunction)
         return 0;
     throw null;
 }
예제 #16
0
 public int getCost()
 {
     int cost = getUnmodifiedCost();
     decimal discountPercent = 0;
     decimal extraCostPercent = 0;
     foreach (CostModifier effect in from x in property.effectedBy where x is CostModifier select x)
     {
         PurchasedProperty otherPurchasedProperty = character.getPurchasedProperty(effect.owner.name);
         if (!otherPurchasedProperty.nonDefault)
             continue;
         EvaluationContext context = new EvaluationContext(character, otherPurchasedProperty, otherPurchasedProperty.getLevel());
         if (effect.parsedThing.declarationOperator == "-=")
             discountPercent += effect.formula.evalPercent(context);
         else if (effect.parsedThing.declarationOperator == "+=")
             extraCostPercent += effect.formula.evalPercent(context);
         else
             throw null;
     }
     // TODO enhancement/limitation cost modifiers go here
     // cap discount at -80%
     discountPercent = Math.Min(discountPercent, 0.80m);
     int costEffect = (int)Math.Floor(cost * (extraCostPercent - discountPercent));
     cost += costEffect;
     return cost;
 }