public bool equals(Ongoing x) { if (x.key == this.key) { return true; } else return false; }
/*find effect based on its type in a character's effects array /***not sure if works** /* * Quick version of how this works: * Find goes through List<Ongoing> effects, and looks at each object in the list. * It runs the object through a predicate to get a boolean. If the boolean is true, it returns * the object that satisfied the predicate. The predicate in this case is * a method (a delegate) which is passed the Ongoing object in effects being * looked at. The method then compares the type variable of the object (provided by getType()) * to the type specified in the original method call. If that object's type matches the type * it was looking for, the predicate returns true, and Find returns that object. */ public Ongoing FindEffect(Ongoing.EffectType type) { Ongoing result = effects.Find(delegate(Ongoing item) { return item.Type == type; } ); if (result != null) { return result; } else { return null; } }
// remove an effect from the character's effects list // depends on a modified equals() method in Ongoing // maybe use get_effect instead if that works public void RemoveEffect(Ongoing.Keyword key) { Ongoing x = new Ongoing(key, Ongoing.EffectType.NULL, 0, 0); effects.Remove(x); }
// add an effect to the character's effects list public void ApplyEffect(Ongoing.Keyword key, Ongoing.EffectType type, int mod, int dur) { Ongoing new_effect; new_effect = new Ongoing(key, type, mod, dur); effects.Add(new_effect); }