Пример #1
0
        public ValueModifier(ValueModifierOperator op, int amount, bool throwException)
        {
            switch (op)
            {
                case ValueModifierOperator.Add:
                    break;
                case ValueModifierOperator.Multiply:
                    if (amount <= 0)
                    {
                        if (throwException)
                        {
                            throw new ArgumentOutOfRangeException("amount", "Amount should be greater than zero.");
                        }
                        else
                        {
                            amount = 1;
                        }
                    }
                    break;
                case ValueModifierOperator.DivideRoundUp:
                case ValueModifierOperator.DivideRoundDown:
                    if (amount <= 0)
                    {
                        if (throwException)
                        {
                            throw new ArgumentOutOfRangeException("amount", "Amount should be greater than zero.");
                        }
                        else
                        {
                            amount = 1;
                        }
                    }
                    break;
                default:
                    throw new ArgumentException("Invalid value.", "op");
            }

            Operator = op;
            Amount = amount;
        }
Пример #2
0
 public ValueModifier(ValueModifierOperator op, int amount)
     : this(op, amount, true)
 { }