/// <summary> /// Creates an Effect which applies a Modifier to a GameValue /// </summary> /// <param name="gameValue">The GameValue to modify</param> /// <param name="Modifier">The Modifier to apply</param> public Effect(GameValue gameValue, Modifier modifier) { this.gameValue = gameValue; this.modifier = modifier; }
/// <summary> /// Applies the modifier to a GameValue /// </summary> /// <param name="GameValue">GameValue to modify</param> public void Modify(GameValue gameValue) { if (set) { gameValue.setValue(setTo); } else { if (random != null) { // applies the change with AddSubtract and RangeChange gameValue.Add((decimal)(change * Math.Pow(random.NextDouble(), rangeChange) * Math.Sign(random.NextDouble() - .5 + addSubtract))); // applies the multiplier with MultiplyDivide and RangeMultiplier gameValue.Multiply((decimal)Math.Pow((multiplier - 1) * Math.Pow(random.NextDouble(), rangeMultiplier) + 1, Math.Sign(random.NextDouble() - .5 + multiplyDivide))); if (random.NextDouble() < resetChance) { gameValue.Reset(); } } else { // applies the change gameValue.Add((decimal)(change * addSubtract)); //applies the multiplier gameValue.Multiply((decimal)Math.Pow(multiplier, multiplyDivide)); } } }
public void Modify(GameValue gameValue) { gameValue.Add((decimal)(change * Math.Pow(random.NextDouble(), rangeChange) * Math.Sign(random.NextDouble() - .5 + addSubtract))); gameValue.Multiply((decimal)Math.Pow((multiplier - 1) * Math.Pow(random.NextDouble(), rangeMultiplier) + 1, Math.Sign(random.NextDouble() - .5 + multiplyDivide))); if (random.NextDouble() < resetChance) { gameValue.Reset(); } }