public int?GetLinesWithStaff(string staffName, string spellName)
        {
            if (string.IsNullOrEmpty(staffName))
            {
                var metadata = SpellMetadataManager.Instance.GetSpell(spellName);
                if (metadata == null)
                {
                    return(null);
                }

                return(metadata.NumberOfLines);
            }

            staffName = staffName.Trim();
            spellName = spellName.Trim();
            ComputedSpellLines spellLines = null;

            if (!computedLines.TryGetValue(staffName, out spellLines))
            {
                return(null);
            }

            if (!SpellMetadataManager.Instance.ContainsSpell(spellName))
            {
                return(null);
            }

            return(spellLines.GetLines(spellName));
        }
        ComputedSpellLines CalculateLines(StaffMetadata staff)
        {
            var staffSpellLines = new ComputedSpellLines();

            foreach (var spell in SpellMetadataManager.Instance.Spells)
            {
                var lines = CalculateLinesForSpell(staff, spell);
                staffSpellLines.SetLines(spell.Name, lines);
            }

            return(staffSpellLines);
        }
        public void RecalculateSpell(StaffMetadata staff, SpellMetadata spell)
        {
            ComputedSpellLines allLines = null;
            var lines = CalculateLinesForSpell(staff, spell);

            if (!computedLines.TryGetValue(staff.Name, out allLines))
            {
                allLines = CalculateLines(staff);
                computedLines[staff.Name] = allLines;
            }

            allLines.SetLines(spell.Name, lines);
        }
        public bool RenameStaff(string originalName, string newName)
        {
            StaffMetadata      staff = null;
            ComputedSpellLines lines = null;

            var wasStaffFound = staves.TryRemove(originalName, out staff);
            var wasLinesFound = computedLines.TryRemove(originalName, out lines);

            if (wasLinesFound)
            {
                computedLines[newName] = lines;
            }

            if (wasStaffFound)
            {
                OnStaffRemoved(staff);
                staves[newName] = staff;
                OnStaffAdded(staff);
            }

            return(wasStaffFound);
        }
        ComputedSpellLines CalculateLines(StaffMetadata staff)
        {
            var staffSpellLines = new ComputedSpellLines();

              foreach (var spell in SpellMetadataManager.Instance.Spells)
              {
            var lines = CalculateLinesForSpell(staff, spell);
            staffSpellLines.SetLines(spell.Name, lines);
              }

              return staffSpellLines;
        }