Ejemplo n.º 1
0
 public void RecalculateSpellForAllStaves(SpellMetadata spell)
 {
     foreach (var staff in staves.Values)
     {
         RecalculateSpell(staff, spell);
     }
 }
Ejemplo n.º 2
0
        public void AddSpell(SpellMetadata spell)
        {
            if (spell == null)
            {
                throw new ArgumentNullException("spell");
            }

            string spellName  = spell.Name.Trim();
            bool   wasUpdated = false;

            if (spells.ContainsKey(spellName))
            {
                wasUpdated = true;
            }

            spells[spellName] = spell;

            if (wasUpdated)
            {
                OnSpellChanged(spell);
            }
            else
            {
                OnSpellAdded(spell);
            }
        }
Ejemplo n.º 3
0
        public SpellMetadataEventArgs(SpellMetadata spell)
        {
            if (spell == null)
            {
                throw new ArgumentNullException("spell");
            }

            this.spell = spell;
        }
Ejemplo n.º 4
0
        void OnSpellRemoved(SpellMetadata spell)
        {
            var handler = this.SpellRemoved;

            if (handler != null)
            {
                handler(this, new SpellMetadataEventArgs(spell));
            }
        }
Ejemplo n.º 5
0
 public void CopyTo(SpellMetadata other)
 {
     other.Name          = Name;
     other.Class         = Class;
     other.GroupName     = GroupName;
     other.ManaCost      = ManaCost;
     other.NumberOfLines = NumberOfLines;
     other.Cooldown      = Cooldown;
     other.CanImprove    = CanImprove;
 }
Ejemplo n.º 6
0
        int CalculateLinesForSpell(StaffMetadata staff, SpellMetadata spell)
        {
            var originalLines = spell.NumberOfLines;
            var lines         = spell.NumberOfLines;

            foreach (var modifiers in staff.Modifiers)
            {
                if (modifiers.MinThreshold > 0 && originalLines < modifiers.MinThreshold)
                {
                    continue;
                }

                if (modifiers.MaxThreshold > 0 && originalLines > modifiers.MaxThreshold)
                {
                    continue;
                }

                switch (modifiers.Scope)
                {
                case ModifierScope.None:
                    continue;

                case ModifierScope.Single:
                    if (!string.Equals(modifiers.ScopeName, spell.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    break;

                case ModifierScope.Group:
                    if (!string.Equals(modifiers.ScopeName, spell.GroupName, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    break;
                }

                switch (modifiers.Action)
                {
                case ModifierAction.Increase:
                    lines += modifiers.Value;
                    break;

                case ModifierAction.Decrease:
                    lines -= modifiers.Value;
                    break;

                case ModifierAction.Set:
                    lines = modifiers.Value;
                    break;
                }
            }

            return(Math.Max(0, lines));
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        public bool RenameSpell(string originalName, string newName)
        {
            SpellMetadata spell    = null;
            var           wasFound = spells.TryRemove(originalName, out spell);

            if (wasFound)
            {
                OnSpellRemoved(spell);
                spells[newName] = spell;
                OnSpellAdded(spell);
            }

            return(wasFound);
        }