Add SpellFieldKey class for managing spell and aura keys

- Introduced a new class `SpellFieldKey` to encapsulate constants and methods related to spell and aura identifiers.
- Added methods for generating keys for spells and auras, including parsing functionality for spell and aura strings.
- Implemented utility methods for stripping prefixes and canonicalizing aura IDs.
This commit is contained in:
waynebian01
2026-08-30 10:22:51 +08:00
parent 9b9127c90c
commit 232fa91aa2
42 changed files with 9620 additions and 3981 deletions

View File

@@ -10,6 +10,7 @@ public sealed class KeymapService : IKeymapResolver
private readonly Dictionary<(int Unit, string Spell, string MacroCondition), string> _hotkeys = new();
private readonly Dictionary<(int Unit, string Spell), string> _fallbackHotkeys = new();
private readonly Dictionary<long, int> _spellIndices = new();
private readonly Dictionary<long, string> _spellNames = new();
private int? _currentClassId;
private int? _currentSpecId;
@@ -36,6 +37,7 @@ public sealed class KeymapService : IKeymapResolver
_hotkeys.Clear();
_fallbackHotkeys.Clear();
_spellIndices.Clear();
_spellNames.Clear();
LoadSpellIndices(classId);
@@ -111,12 +113,17 @@ public sealed class KeymapService : IKeymapResolver
return null;
}
public IReadOnlyDictionary<int, string> GetCurrentFailedSpells()
public string? GetHotkey(int? unit, long spellId, string? macroCondition = null)
=> _spellNames.TryGetValue(spellId, out var spell)
? GetHotkey(unit, spell, macroCondition)
: null;
public IReadOnlyDictionary<int, long> GetCurrentFailedSpells()
{
return _config.GetFailedSpells(_currentClassId);
}
public IReadOnlyDictionary<int, string> GetCurrentOneKeySpells()
public IReadOnlyDictionary<int, long> GetCurrentOneKeySpells()
{
return _config.GetOneKeySpells(_currentClassId);
}
@@ -126,6 +133,11 @@ public sealed class KeymapService : IKeymapResolver
return _spellIndices;
}
public IReadOnlyDictionary<long, string> GetCurrentSpellNames()
{
return _spellNames;
}
private void LoadSpellIndices(int? classId)
{
if (classId is null)
@@ -144,6 +156,10 @@ public sealed class KeymapService : IKeymapResolver
foreach (var spell in document.SpellsList.Where(spell => spell.SpellId > 0))
{
_spellIndices.TryAdd(spell.SpellId, spell.Index);
if (!string.IsNullOrWhiteSpace(spell.Name))
{
_spellNames.TryAdd(spell.SpellId, spell.Name.Trim());
}
}
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException