All Questions

Community

Mathew Carnaby

Remove modifier

Since reworking the addition of modifiers into sub-arrays for "value" and "rate" variants, I expect the remove_modifier function also needs updating as the ID alone doesn't distinguish what type or sublist to remove it from. Something like:


func remove_stat_modifier(stat_name: String, is_value_modifier: bool,  id: int) -> void:
if is_value_modifier:
assert(id in _stat_modifiers[stat_name]["value"], "Stat value modifier id " + String(id) + " not found for " + stat_name + ".")
_stat_modifiers[stat_name]["value"].erase(id)
else: # is rate modifier
assert(id in _stat_modifiers[stat_name]["rate"], "Stat rate modifier id " + String(id) + " not found for " + stat_name + ".")
_stat_modifiers[stat_name]["rate"].erase(id)
_recalculate(stat_name)


  • Nathan Lovato replied

    In a game, absolutely, you should add the remove counterpart to adding the feature.

    Here, the assignment had that specific requirement of only implementing the ability to add multipliers. That's why the solution is also just that. As not everyone does assignments, we don't rely on them in the course, and the final game demo doesn't depend on this optional feature.

    Thanks for sharing your solution.