Skip to content

Commit

Permalink
Rename weapon validator to weaponSubclass
Browse files Browse the repository at this point in the history
  • Loading branch information
raethkcj committed Nov 28, 2024
1 parent ed3a678 commit d1c52c9
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 54 deletions.
12 changes: 6 additions & 6 deletions libs/StatLogic/Cata_Logic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2325,7 +2325,7 @@ if addon.playerRace == "Dwarf" then
[StatLogic.Stats.Expertise] = {
{
["value"] = 3,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Mace1H] = true,
[Enum.ItemWeaponSubclass.Mace2H] = true,
}
Expand All @@ -2334,7 +2334,7 @@ if addon.playerRace == "Dwarf" then
[StatLogic.Stats.RangedCrit] = {
{
["value"] = 1,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Guns] = true,
}
}
Expand All @@ -2352,7 +2352,7 @@ elseif addon.playerRace == "Gnome" then
[StatLogic.Stats.Expertise] = {
{
["value"] = 3,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Dagger] = true,
[Enum.ItemWeaponSubclass.Sword1H] = true,
}
Expand All @@ -2371,7 +2371,7 @@ elseif addon.playerRace == "Human" then
[StatLogic.Stats.Expertise] = {
{
["value"] = 3,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Mace1H] = true,
[Enum.ItemWeaponSubclass.Mace2H] = true,
[Enum.ItemWeaponSubclass.Sword1H] = true,
Expand All @@ -2385,7 +2385,7 @@ elseif addon.playerRace == "Orc" then
[StatLogic.Stats.Expertise] = {
{
["value"] = 3,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Axe1H] = true,
[Enum.ItemWeaponSubclass.Axe2H] = true,
[Enum.ItemWeaponSubclass.Unarmed] = true,
Expand Down Expand Up @@ -2413,7 +2413,7 @@ elseif addon.playerRace == "Troll" then
[StatLogic.Stats.RangedCrit] = {
{
["value"] = 1,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Bows] = true,
[Enum.ItemWeaponSubclass.Thrown] = true,
}
Expand Down
32 changes: 16 additions & 16 deletions libs/StatLogic/StatLogic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ local tocversion = select(4, GetBuildInfo())
-- metatable for stat tables
local statTableMetatable = {
__index = function(_, k)
if k ~= "subclassID" then
if k ~= "weaponSubclass" then
return 0
end
end,
Expand Down Expand Up @@ -166,7 +166,7 @@ end
---@field link string
---@field numLines integer
---@field inventoryType string
---@field subclassID Enum.ItemWeaponSubclass?
---@field weaponSubclass Enum.ItemWeaponSubclass?
---@field [Stat] number

-- New table
Expand Down Expand Up @@ -835,12 +835,12 @@ function addon.GenerateWeaponSubclassStats()
for _, modList in pairs(StatLogic.StatModTable) do
for stat, cases in pairs(modList) do
for _, case in ipairs(cases) do
if case.weapon then
for subclassID in pairs(case.weapon) do
if not addon.WeaponSubclassStats[subclassID] then
addon.WeaponSubclassStats[subclassID] = {}
if case.weaponSubclass then
for weaponSubclass in pairs(case.weaponSubclass) do
if not addon.WeaponSubclassStats[weaponSubclass] then
addon.WeaponSubclassStats[weaponSubclass] = {}
end
addon.WeaponSubclassStats[subclassID][stat] = true
addon.WeaponSubclassStats[weaponSubclass][stat] = true
end
end
end
Expand Down Expand Up @@ -1093,18 +1093,18 @@ addon.StatModValidators = {
["PLAYER_TALENT_UPDATE"] = true,
},
},
weapon = {
weaponSubclass = {
validate = function(case, _, statModContext)
local subclassID
local weaponSubclass
if statModContext then
subclassID = statModContext.overrideStats.subclassID
weaponSubclass = statModContext.overrideStats.weaponSubclass
else
local weapon = GetInventoryItemID("player", INVSLOT_MAINHAND)
if weapon then
subclassID = select(7, C_Item.GetItemInfoInstant(weapon))
weaponSubclass = select(7, C_Item.GetItemInfoInstant(weapon))
end
end
return subclassID and case.weapon[subclassID] or false
return weaponSubclass and case.weaponSubclassSubclass[weaponSubclass] or false
end,
events = {
["UNIT_INVENTORY_CHANGED"] = "player",
Expand Down Expand Up @@ -1164,7 +1164,7 @@ do
end

local function ValidateStatMod(statModName, case, statModContext)
if statModContext.overrideStats.subclassID and not case.weapon then
if statModContext.overrideStats.weaponSubclass and not case.weaponSubclass then
-- If we're passed a weapon type, we're only interested in StatMods with weapon cases
return false
end
Expand All @@ -1180,7 +1180,7 @@ local function ValidateStatMod(statModName, case, statModContext)
end
addon.StatModCacheInvalidators[key] = addon.StatModCacheInvalidators[key] or {}
table.insert(addon.StatModCacheInvalidators[key], statModName)
if case.weapon then
if case.weaponSubclass then
WeaponSubclassInvalidators[key] = true
end
end
Expand Down Expand Up @@ -1861,7 +1861,7 @@ do
if not statModContext then
statModContext = StatLogic:NewStatModContext()
end
statModContext.overrideStats["subclassID"] = itemSubclass
statModContext.overrideStats["weaponSubclass"] = itemSubclass
local statMods = addon.WeaponSubclassStats[itemSubclass]
if statMods then
for statMod in pairs(statMods) do
Expand All @@ -1870,7 +1870,7 @@ do
end
end
-- Unset afterwards to prevent interference with ValidateStatMod
statModContext.overrideStats["subclassID"] = nil
statModContext.overrideStats["weaponSubclass"] = nil
end

log(link)
Expand Down
14 changes: 7 additions & 7 deletions libs/StatLogic/TBC_Logic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ elseif addon.class == "ROGUE" then
["rank"] = {
1, 2, 3, 4, 5,
},
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Dagger] = true,
},
},
Expand All @@ -1164,7 +1164,7 @@ elseif addon.class == "ROGUE" then
["rank"] = {
1, 2, 3, 4, 5,
},
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Unarmed] = true,
},
},
Expand Down Expand Up @@ -1543,7 +1543,7 @@ elseif addon.class == "WARRIOR" then
["rank"] = {
1, 2, 3, 4, 5,
},
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Axe1H] = true,
[Enum.ItemWeaponSubclass.Axe2H] = true,
[Enum.ItemWeaponSubclass.Polearm] = true,
Expand All @@ -1558,7 +1558,7 @@ if addon.playerRace == "Dwarf" then
[StatLogic.Stats.RangedCrit] = {
{
["value"] = 1,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Guns] = true,
}
}
Expand Down Expand Up @@ -1606,7 +1606,7 @@ elseif addon.playerRace == "Human" then
[StatLogic.Stats.Expertise] = {
{
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Mace1H] = true,
[Enum.ItemWeaponSubclass.Mace2H] = true,
[Enum.ItemWeaponSubclass.Sword1H] = true,
Expand All @@ -1620,7 +1620,7 @@ elseif addon.playerRace == "Orc" then
[StatLogic.Stats.Expertise] = {
{
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Axe1H] = true,
[Enum.ItemWeaponSubclass.Axe2H] = true,
}
Expand All @@ -1647,7 +1647,7 @@ elseif addon.playerRace == "Troll" then
[StatLogic.Stats.RangedCrit] = {
{
["value"] = 1,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Bows] = true,
[Enum.ItemWeaponSubclass.Thrown] = true,
}
Expand Down
36 changes: 18 additions & 18 deletions libs/StatLogic/Vanilla_Logic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ elseif addon.class == "ROGUE" then
["rank"] = {
1, 2, 3, 4, 5,
},
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Dagger] = true,
},
},
Expand All @@ -907,7 +907,7 @@ elseif addon.class == "ROGUE" then
["rank"] = {
1, 2, 3, 4, 5,
},
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Unarmed] = true,
},
},
Expand All @@ -916,7 +916,7 @@ elseif addon.class == "ROGUE" then
["set"] = 1829,
["pieces"] = 3,
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Dagger] = true,
},
},
Expand All @@ -929,7 +929,7 @@ elseif addon.class == "ROGUE" then
["rank"] = {
1, 2, 3, 4, 5,
},
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Mace1H] = true,
},
},
Expand All @@ -940,7 +940,7 @@ elseif addon.class == "ROGUE" then
["rank"] = {
3, 5,
},
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Sword1H] = true,
[Enum.ItemWeaponSubclass.Dagger] = true,
[Enum.ItemWeaponSubclass.Unarmed] = true,
Expand Down Expand Up @@ -1328,7 +1328,7 @@ elseif addon.class == "WARRIOR" then
["rank"] = {
1, 2, 3, 4, 5,
},
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Axe1H] = true,
[Enum.ItemWeaponSubclass.Axe2H] = true,
},
Expand All @@ -1340,7 +1340,7 @@ elseif addon.class == "WARRIOR" then
["rank"] = {
1, 2, 3, 4, 5,
},
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Polearm] = true,
},
},
Expand Down Expand Up @@ -1379,7 +1379,7 @@ if addon.playerRace == "Dwarf" then
[StatLogic.Stats.WeaponSkill] = {
{
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Guns] = true,
},
["group"] = addon.ExclusiveGroup.WeaponRacial,
Expand Down Expand Up @@ -1418,7 +1418,7 @@ elseif addon.playerRace == "Human" then
[StatLogic.Stats.WeaponSkill] = {
{
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Mace1H] = true,
[Enum.ItemWeaponSubclass.Mace2H] = true,
[Enum.ItemWeaponSubclass.Sword1H] = true,
Expand All @@ -1433,7 +1433,7 @@ elseif addon.playerRace == "Orc" then
[StatLogic.Stats.WeaponSkill] = {
{
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Axe1H] = true,
[Enum.ItemWeaponSubclass.Axe2H] = true,
},
Expand Down Expand Up @@ -1461,7 +1461,7 @@ elseif addon.playerRace == "Troll" then
[StatLogic.Stats.WeaponSkill] = {
{
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Bows] = true,
[Enum.ItemWeaponSubclass.Thrown] = true,
},
Expand Down Expand Up @@ -1706,7 +1706,7 @@ StatLogic.StatModTable["ALL"] = {
{
["rune"] = 51232,
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Sword1H] = true,
[Enum.ItemWeaponSubclass.Sword2H] = true,
},
Expand All @@ -1716,7 +1716,7 @@ StatLogic.StatModTable["ALL"] = {
{
["rune"] = 51233,
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Axe1H] = true,
[Enum.ItemWeaponSubclass.Axe2H] = true,
},
Expand All @@ -1726,7 +1726,7 @@ StatLogic.StatModTable["ALL"] = {
{
["rune"] = 51234,
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Mace1H] = true,
[Enum.ItemWeaponSubclass.Mace2H] = true,
},
Expand All @@ -1736,7 +1736,7 @@ StatLogic.StatModTable["ALL"] = {
{
["rune"] = 51235,
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Dagger] = true,
},
["group"] = addon.ExclusiveGroup.WeaponRacial,
Expand All @@ -1745,7 +1745,7 @@ StatLogic.StatModTable["ALL"] = {
{
["rune"] = 51236,
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Unarmed] = true,
},
["group"] = addon.ExclusiveGroup.WeaponRacial,
Expand All @@ -1754,7 +1754,7 @@ StatLogic.StatModTable["ALL"] = {
{
["rune"] = 51237,
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Bows] = true,
[Enum.ItemWeaponSubclass.Guns] = true,
[Enum.ItemWeaponSubclass.Crossbow] = true,
Expand All @@ -1766,7 +1766,7 @@ StatLogic.StatModTable["ALL"] = {
{
["rune"] = 51238,
["value"] = 5,
["weapon"] = {
["weaponSubclass"] = {
[Enum.ItemWeaponSubclass.Staff] = true,
[Enum.ItemWeaponSubclass.Polearm] = true,
},
Expand Down
Loading

0 comments on commit d1c52c9

Please sign in to comment.