public static void AddSpell(IMagic spell) { string _level = SpellLevelToString(spell.SpellLevel); if (_level == "") { throw new System.Exception("Invalid Spell level"); } //Checking if the level is already in the collection foreach (SpellLevelGroup magics in SpellsKnown) { if (magics.Level == _level) { magics.Add(spell); return; } } //Adding the level in the right spot of the collection (right before the first one greater than it) for (int i = 0; i < SpellsKnown.Count; i++) { if (LevelTextToInt(_level) < LevelTextToInt(SpellsKnown[i].Level) || i == SpellsKnown.Count - 1) { SpellsKnown.Insert(i, new SpellLevelGroup(_level, new IMagic[] { spell })); return; } } }
void learnScroll(SpellID spell) { if (Scrolls.Contains(spell)) { Scrolls.Remove(spell); SpellsKnown.Add(spell); } }
public void GainSpell(SpellID spell) { SpellsKnown.Add(spell); }