public void RemoveModifier(string id) { for (int i = 0; i < modifiers.Count; i++) { if (modifiers[i].id == id) { IntModifier prev = modifiers[i]; flatBonus -= prev.flatBonus; percentBonus -= prev.percentBonus; BaseValue = BaseValue; break; } } }
public void ClearModifier(string id) { modifiers = modifiers ?? new List <IntModifier>(); for (int i = 0; i < modifiers.Count; i++) { if (modifiers[i].id == id) { IntModifier prev = modifiers[i]; flatBonus -= prev.flatBonus; percentBonus -= prev.percentBonus; modifiers.RemoveAt(i); break; } } }
public void SetModifier(string id, IntModifier modifier) { modifier = new IntModifier(id, modifier); for (int i = 0; i < modifiers.Count; i++) { if (modifiers[i].id == id) { IntModifier prev = modifiers[i]; flatBonus -= prev.flatBonus; percentBonus -= prev.percentBonus; break; } } modifiers.Add(modifier); flatBonus += modifier.flatBonus; percentBonus += modifier.percentBonus; }