Skip to content

Commit ae98248

Browse files
committed
Classes update to use class and category
1 parent 664d6f0 commit ae98248

File tree

9 files changed

+124
-140
lines changed

9 files changed

+124
-140
lines changed

src/Classes/ImportTab.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ function ImportTabClass:ImportItem(itemData, slotName)
807807
end
808808
item.base = self.build.data.itemBases[item.baseName]
809809
if item.base then
810-
item.type = item.base.type
810+
item.category = item.base.category
811811
else
812812
ConPrintf("Unrecognised base in imported item: %s", item.baseName)
813813
end
@@ -832,7 +832,7 @@ function ImportTabClass:ImportItem(itemData, slotName)
832832
item.baseName = baseName
833833
item.namePrefix = item.name:sub(1, s - 1)
834834
item.nameSuffix = item.name:sub(e + 1)
835-
item.type = baseData.type
835+
item.category = baseData.category
836836
break
837837
end
838838
end
@@ -843,7 +843,7 @@ function ImportTabClass:ImportItem(itemData, slotName)
843843
item.baseName = "Two-Toned Boots (Armour/Energy Shield)"
844844
item.namePrefix = item.name:sub(1, s - 1)
845845
item.nameSuffix = item.name:sub(e + 1)
846-
item.type = "Boots"
846+
item.category = "Boots"
847847
end
848848
end
849849
item.base = self.build.data.itemBases[item.baseName]

src/Classes/Item.lua

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
421421
self.itemSocketCount = #self.sockets
422422
elseif specName == "Rune" then
423423
t_insert(self.runes, specVal)
424-
elseif specName == "Radius" and self.type == "Jewel" then
424+
elseif specName == "Radius" and self.category == "Jewel" then
425425
self.jewelRadiusLabel = specVal:match("^[%a ]+")
426426
if specVal:match("^%a+") == "Variable" then
427427
-- Jewel radius is variable and must be read from it's mods instead after they are parsed
@@ -434,7 +434,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
434434
end
435435
end
436436
end
437-
elseif specName == "Limited to" and self.type == "Jewel" then
437+
elseif specName == "Limited to" and self.category == "Jewel" then
438438
self.limit = specToNumber(specVal)
439439
elseif specName == "Variant" then
440440
if not self.variantList then
@@ -656,14 +656,15 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
656656
if not (self.rarity == "NORMAL" or self.rarity == "MAGIC") then
657657
self.title = self.name
658658
end
659+
self.category = base.category
660+
self.class = base.class
661+
self.label = base.label
659662
self.type = base.type
660663
self.base = base
661664
self.charmLimit = base.charmLimit
662665
self.spiritValue = base.spirit
663-
self.affixes = (self.base.subType and data.itemMods[self.base.type..self.base.subType])
664-
or data.itemMods[self.base.type]
665-
or data.itemMods.Item
666-
self.corruptible = self.base.type ~= "Flask" and self.base.type ~= "Charm" and self.base.type ~= "Rune" and self.base.type ~= "SoulCore"
666+
self.affixes = data.itemMods.Item
667+
self.corruptible = self.base.category ~= "Flask" and self.base.category ~= "Charm" and self.base.category ~= "SoulCore"
667668
self.clusterJewel = data.clusterJewels and data.clusterJewels.jewels[self.baseName]
668669
self.requirements.str = self.base.req.str or 0
669670
self.requirements.dex = self.base.req.dex or 0
@@ -754,7 +755,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
754755
foundExplicit = true
755756
end
756757
elseif mode == "GAME" then
757-
if gameModeStage == "IMPLICIT" or gameModeStage == "EXPLICIT" or (gameModeStage == "FINDIMPLICIT" and (not data.itemBases[line]) and not (self.name == line) and not line:find("Two%-Toned") and not (self.base and (line == self.base.type or self.base.subType and line == self.base.subType .. " " .. self.base.type))) then
758+
if gameModeStage == "IMPLICIT" or gameModeStage == "EXPLICIT" or (gameModeStage == "FINDIMPLICIT" and not data.itemBases[line] and not self.name == line and not line:find("Two%-Toned") and not (self.base and line == self.base.class)) then
758759
modLine.modList = { }
759760
modLine.extra = line
760761
t_insert(modLines, modLine)
@@ -830,7 +831,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
830831
self.affixLimit = 2
831832
end
832833
elseif self.rarity == "RARE" then
833-
self.affixLimit = ((self.type == "Jewel" and not (self.base.subType == "Abyss" and self.corrupted)) and 4 or 6)
834+
self.affixLimit = self.category == "Jewel" and 4 or 6
834835
if self.prefixes.limit or self.suffixes.limit then
835836
self.prefixes.limit = m_max(m_min((self.prefixes.limit or 0) + self.affixLimit / 2, self.affixLimit), 0)
836837
self.suffixes.limit = m_max(m_min((self.suffixes.limit or 0) + self.affixLimit / 2, self.affixLimit), 0)
@@ -898,7 +899,7 @@ function ItemClass:NormaliseQuality()
898899
if self.base and self.base.quality then
899900
if not self.quality then
900901
self.quality = 0
901-
elseif not self.uniqueID and not self.corrupted and not self.mirrored and not (self.base.type == "Charm") and self.quality < self.base.quality then -- charms cannot be modified by quality currency.
902+
elseif not self.uniqueID and not self.corrupted and not self.mirrored and not (self.base.category == "Charm") and self.quality < self.base.quality then -- charms cannot be modified by quality currency.
902903
self.quality = self.base.quality
903904
end
904905
end
@@ -1210,16 +1211,16 @@ end
12101211

12111212
-- Return the name of the slot this item is equipped in
12121213
function ItemClass:GetPrimarySlot()
1213-
if self.base.weapon or self.base.type == "Wand" or self.base.type == "Sceptre" or self.base.type == "Staff" then
1214+
if self.base.tags.onehand or self.base.tags.twohand then
12141215
return "Weapon 1"
1215-
elseif self.type == "Quiver" or self.type == "Shield" then
1216+
elseif self.category == "Quiver" or self.category == "Shield" or self.category == "Focus" then
12161217
return "Weapon 2"
1217-
elseif self.type == "Ring" then
1218+
elseif self.category == "Ring" then
12181219
return "Ring 1"
1219-
elseif self.type == "Flask" then
1220+
elseif self.category == "Flask" then
12201221
return "Flask 1"
12211222
else
1222-
return self.type
1223+
return self.category
12231224
end
12241225
end
12251226

@@ -1306,7 +1307,7 @@ function ItemClass:BuildModListForSlotNum(baseList, slotNum)
13061307
if self.base.weapon then
13071308
local weaponData = { }
13081309
self.weaponData[slotNum] = weaponData
1309-
weaponData.type = self.base.type
1310+
weaponData.category = self.base.category
13101311
weaponData.name = self.name
13111312
weaponData.AttackSpeedInc = calcLocal(modList, "Speed", "INC", ModFlag.Attack) + m_floor(self.quality / 8 * calcLocal(modList, "AlternateQualityLocalAttackSpeedPer8Quality", "INC", 0))
13121313
weaponData.AttackRate = round(self.base.weapon.AttackRateBase * (1 + weaponData.AttackSpeedInc / 100), 2)
@@ -1444,7 +1445,7 @@ function ItemClass:BuildModListForSlotNum(baseList, slotNum)
14441445
for _, value in ipairs(modList:List(nil, "CharmData")) do
14451446
charmData[value.key] = value.value
14461447
end
1447-
elseif self.type == "Jewel" then
1448+
elseif self.category == "Jewel" then
14481449
if self.name:find("Grand Spectrum") then
14491450
local spectrumMod = modLib.createMod("Multiplier:GrandSpectrum", "BASE", 1, self.name)
14501451
modList:AddMod(spectrumMod)
@@ -1512,7 +1513,7 @@ function ItemClass:BuildModList()
15121513
elseif self.base.charm then
15131514
self.charmData = { }
15141515
self.buffModList = { }
1515-
elseif self.type == "Jewel" then
1516+
elseif self.category == "Jewel" then
15161517
self.jewelData = { }
15171518
end
15181519
self.baseModList = baseList
@@ -1613,7 +1614,7 @@ function ItemClass:BuildModList()
16131614
self.sockets = newSockets
16141615
end
16151616
self.socketedJewelEffectModifier = 1 + calcLocal(baseList, "SocketedJewelEffect", "INC", 0) / 100
1616-
if self.base.weapon or self.base.type == "Wand" or self.base.type == "Sceptre" or self.base.type == "Staff" or self.type == "Ring" then
1617+
if self.base.tags.onehand or self.base.tags.twohand or self.category == "Ring" then
16171618
self.slotModList = { }
16181619
for i = 1, 2 do
16191620
self.slotModList[i] = self:BuildModListForSlotNum(baseList, i)

src/Classes/ItemDBControl.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ local ItemDBClass = newClass("ItemDBControl", "ListControl", function(self, anch
2525
self.sortMode = "NAME"
2626
self.leaguesAndTypesLoaded = false
2727
self.leagueList = { "Any league", "No league" }
28-
self.typeList = { "Any type", "Armour", "Jewellery", "One Handed Melee", "Two Handed Melee" }
28+
self.categoryList = { "Any type", "Armour", "Jewellery", "One Handed Melee", "Two Handed Melee" }
2929
self.slotList = { "Any slot", "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring", "Belt", "Jewel" }
3030
local baseY = dbType == "RARE" and -22 or -62
3131
self.controls.slot = new("DropDownControl", {"BOTTOMLEFT",self,"TOPLEFT"}, {0, baseY, 179, 18}, self.slotList, function(index, value)
3232
self.listBuildFlag = true
3333
end)
34-
self.controls.type = new("DropDownControl", {"LEFT",self.controls.slot,"RIGHT"}, {2, 0, 179, 18}, self.typeList, function(index, value)
34+
self.controls.category = new("DropDownControl", {"LEFT",self.controls.slot,"RIGHT"}, {2, 0, 179, 18}, self.categoryList, function(index, value)
3535
self.listBuildFlag = true
3636
end)
3737
if dbType == "UNIQUE" then
@@ -60,20 +60,20 @@ end)
6060

6161
function ItemDBClass:LoadLeaguesAndTypes()
6262
local leagueFlag = { }
63-
local typeFlag = { }
63+
local categoryFlag = { }
6464
for _, item in pairs(self.db.list) do
6565
if item.league then
6666
for leagueName in item.league:gmatch(" ?([%w ]+),?") do
6767
leagueFlag[leagueName] = true
6868
end
6969
end
70-
typeFlag[item.type] = true
70+
categoryFlag[item.class == item.category and (item.label or item.class) or (item.category..": "..(item.label or item.class))] = true
7171
end
7272
for leagueName in pairsSortByKey(leagueFlag) do
7373
t_insert(self.leagueList, leagueName)
7474
end
75-
for type in pairsSortByKey(typeFlag) do
76-
t_insert(self.typeList, type)
75+
for type in pairsSortByKey(categoryFlag) do
76+
t_insert(self.categoryList, type)
7777
end
7878
self.leaguesAndTypesLoaded = true
7979
end
@@ -85,22 +85,22 @@ function ItemDBClass:DoesItemMatchFilters(item)
8585
return false
8686
end
8787
end
88-
local typeSel = self.controls.type.selIndex
89-
if typeSel > 1 then
90-
if typeSel == 2 then
88+
local categorySel = self.controls.category.selIndex
89+
if categorySel > 1 then
90+
if categorySel == 2 then
9191
if not item.base.armour then
9292
return false
9393
end
94-
elseif typeSel == 3 then
95-
if not (item.type == "Amulet" or item.type == "Ring" or item.type == "Belt") then
94+
elseif categorySel == 3 then
95+
if not (item.category == "Amulet" or item.category == "Ring" or item.category == "Belt") then
9696
return false
9797
end
98-
elseif typeSel == 4 or typeSel == 5 then
99-
local weaponInfo = self.itemsTab.build.data.weaponTypeInfo[item.type]
100-
if not (weaponInfo and weaponInfo.melee and ((typeSel == 4 and weaponInfo.oneHand) or (typeSel == 5 and not weaponInfo.oneHand))) then
98+
elseif categorySel == 4 or categorySel == 5 then
99+
local weaponInfo = self.itemsTab.build.data.weaponTypeInfo[item.category]
100+
if not (weaponInfo and weaponInfo.melee and ((categorySel == 4 and weaponInfo.oneHand) or (categorySel == 5 and not weaponInfo.oneHand))) then
101101
return false
102102
end
103-
elseif item.type ~= self.typeList[typeSel] then
103+
elseif (item.class == item.category and (item.label or item.class) or (item.category..": "..(item.label or item.class))) ~= self.categoryList[categorySel] then
104104
return false
105105
end
106106
end

src/Classes/ItemListControl.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ local ItemListClass = newClass("ItemListControl", "ListControl", function(self,
6868
end)
6969

7070
function ItemListClass:FindSocketedJewel(jewelId, excludeActiveSpec)
71-
if not self.itemsTab.items[jewelId] or self.itemsTab.items[jewelId].type ~= "Jewel" then
71+
if not self.itemsTab.items[jewelId] or self.itemsTab.items[jewelId].class ~= "Jewel" then
7272
return nil
7373
end
7474
local treeTab = self.itemsTab.build.treeTab

0 commit comments

Comments
 (0)