Challenge: stat multipliers

Imagine you want a ring to give its holder a 20% attack bonus. Or a massive sword to give you a 10% hit chance penalty.

Our current stat system doesn’t support that. Your task is to solve this problem by adding support for multiplier-based modifiers. They should:

  1. Be summed and apply all at once. If two pieces of equipment add respectively 20% and 10% attack, together, they should multiply attack by 1.3. Not by 1.2 * 1.1 = 1.32.
  2. Be applied before any value-based upgrade. If you have equipment that increases attack by 20 and another by 10%, you should first multiply the base attack by 1.1, then add 20.
  3. Stats should be rounded to avoid decimal values with many numbers.

To ensure that your code works as expected, create a BattlerStats resource with a base_attack of 100. Via code, apply three modifiers to it that:

  1. Increase attack by 20.
  2. Increases attack by 50%.
  3. Increases attack by 20%.

You should end up with an attack of 190.

Hints

The problem involves changing how you add and remove modifiers and how you recalculate the stat upon changing modifiers.