public void RecalculateSpellForAllStaves(SpellMetadata spell) { foreach (var staff in staves.Values) { RecalculateSpell(staff, spell); } }
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); } }
public SpellMetadataEventArgs(SpellMetadata spell) { if (spell == null) { throw new ArgumentNullException("spell"); } this.spell = spell; }
void OnSpellRemoved(SpellMetadata spell) { var handler = this.SpellRemoved; if (handler != null) { handler(this, new SpellMetadataEventArgs(spell)); } }
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; }
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)); }
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 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); }