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.3
. Not by 1.2 * 1.1 = 1.32
.20
and another by 10%, you should first multiply the base attack by 1.1
, then add 20
.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:
20
.You should end up with an attack of 190
.
The problem involves changing how you add and remove modifiers and how you recalculate the stat upon changing modifiers.