Skip to content

Refactor how PoB handles item types and subTypes #688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ function ImportTabClass:ImportItem(itemData, slotName)
end
item.base = self.build.data.itemBases[item.baseName]
if item.base then
item.type = item.base.type
item.category = item.base.category
else
ConPrintf("Unrecognised base in imported item: %s", item.baseName)
end
Expand All @@ -816,7 +816,7 @@ function ImportTabClass:ImportItem(itemData, slotName)
if item.name:match("Energy Blade") then
local oneHanded = false
for _, p in ipairs(itemData.properties) do
if self.build.data.weaponTypeInfo[p.name] and self.build.data.weaponTypeInfo[p.name].oneHand then
if self.build.data.weaponClassInfo[p.name] and self.build.data.weaponClassInfo[p.name].oneHand then
oneHanded = true
break
end
Expand All @@ -832,7 +832,7 @@ function ImportTabClass:ImportItem(itemData, slotName)
item.baseName = baseName
item.namePrefix = item.name:sub(1, s - 1)
item.nameSuffix = item.name:sub(e + 1)
item.type = baseData.type
item.category = baseData.category
break
end
end
Expand All @@ -843,7 +843,7 @@ function ImportTabClass:ImportItem(itemData, slotName)
item.baseName = "Two-Toned Boots (Armour/Energy Shield)"
item.namePrefix = item.name:sub(1, s - 1)
item.nameSuffix = item.name:sub(e + 1)
item.type = "Boots"
item.category = "Boots"
end
end
item.base = self.build.data.itemBases[item.baseName]
Expand Down
38 changes: 20 additions & 18 deletions src/Classes/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
self.itemSocketCount = #self.sockets
elseif specName == "Rune" then
t_insert(self.runes, specVal)
elseif specName == "Radius" and self.type == "Jewel" then
elseif specName == "Radius" and self.category == "Jewel" then
self.jewelRadiusLabel = specVal:match("^[%a ]+")
if specVal:match("^%a+") == "Variable" then
-- Jewel radius is variable and must be read from it's mods instead after they are parsed
Expand All @@ -434,7 +434,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
end
end
end
elseif specName == "Limited to" and self.type == "Jewel" then
elseif specName == "Limited to" and self.category == "Jewel" then
self.limit = specToNumber(specVal)
elseif specName == "Variant" then
if not self.variantList then
Expand Down Expand Up @@ -656,14 +656,15 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
if not (self.rarity == "NORMAL" or self.rarity == "MAGIC") then
self.title = self.name
end
self.category = base.category
self.class = base.class
self.label = base.label
self.type = base.type
self.base = base
self.charmLimit = base.charmLimit
self.spiritValue = base.spirit
self.affixes = (self.base.subType and data.itemMods[self.base.type..self.base.subType])
or data.itemMods[self.base.type]
or data.itemMods.Item
self.corruptible = self.base.type ~= "Flask" and self.base.type ~= "Charm" and self.base.type ~= "Rune" and self.base.type ~= "SoulCore"
self.affixes = data.itemMods.Item
self.corruptible = self.base.category ~= "Flask" and self.base.category ~= "Charm" and self.base.category ~= "SoulCore"
self.clusterJewel = data.clusterJewels and data.clusterJewels.jewels[self.baseName]
self.requirements.str = self.base.req.str or 0
self.requirements.dex = self.base.req.dex or 0
Expand Down Expand Up @@ -754,7 +755,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
foundExplicit = true
end
elseif mode == "GAME" then
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
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
modLine.modList = { }
modLine.extra = line
t_insert(modLines, modLine)
Expand Down Expand Up @@ -830,7 +831,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
self.affixLimit = 2
end
elseif self.rarity == "RARE" then
self.affixLimit = ((self.type == "Jewel" and not (self.base.subType == "Abyss" and self.corrupted)) and 4 or 6)
self.affixLimit = self.category == "Jewel" and 4 or 6
if self.prefixes.limit or self.suffixes.limit then
self.prefixes.limit = m_max(m_min((self.prefixes.limit or 0) + self.affixLimit / 2, self.affixLimit), 0)
self.suffixes.limit = m_max(m_min((self.suffixes.limit or 0) + self.affixLimit / 2, self.affixLimit), 0)
Expand Down Expand Up @@ -898,7 +899,7 @@ function ItemClass:NormaliseQuality()
if self.base and self.base.quality then
if not self.quality then
self.quality = 0
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.
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.
self.quality = self.base.quality
end
end
Expand Down Expand Up @@ -1210,16 +1211,16 @@ end

-- Return the name of the slot this item is equipped in
function ItemClass:GetPrimarySlot()
if self.base.weapon or self.base.type == "Wand" or self.base.type == "Sceptre" or self.base.type == "Staff" then
if self.base.tags.onehand or self.base.tags.twohand then
return "Weapon 1"
elseif self.type == "Quiver" or self.type == "Shield" then
elseif self.category == "Quiver" or self.category == "Shield" or self.category == "Focus" then
return "Weapon 2"
elseif self.type == "Ring" then
elseif self.category == "Ring" then
return "Ring 1"
elseif self.type == "Flask" then
elseif self.category == "Flask" then
return "Flask 1"
else
return self.type
return self.category
end
end

Expand Down Expand Up @@ -1306,7 +1307,8 @@ function ItemClass:BuildModListForSlotNum(baseList, slotNum)
if self.base.weapon then
local weaponData = { }
self.weaponData[slotNum] = weaponData
weaponData.type = self.base.type
weaponData.class = self.base.class
weaponData.category = self.base.category
weaponData.name = self.name
weaponData.AttackSpeedInc = calcLocal(modList, "Speed", "INC", ModFlag.Attack) + m_floor(self.quality / 8 * calcLocal(modList, "AlternateQualityLocalAttackSpeedPer8Quality", "INC", 0))
weaponData.AttackRate = round(self.base.weapon.AttackRateBase * (1 + weaponData.AttackSpeedInc / 100), 2)
Expand Down Expand Up @@ -1444,7 +1446,7 @@ function ItemClass:BuildModListForSlotNum(baseList, slotNum)
for _, value in ipairs(modList:List(nil, "CharmData")) do
charmData[value.key] = value.value
end
elseif self.type == "Jewel" then
elseif self.category == "Jewel" then
if self.name:find("Grand Spectrum") then
local spectrumMod = modLib.createMod("Multiplier:GrandSpectrum", "BASE", 1, self.name)
modList:AddMod(spectrumMod)
Expand Down Expand Up @@ -1512,7 +1514,7 @@ function ItemClass:BuildModList()
elseif self.base.charm then
self.charmData = { }
self.buffModList = { }
elseif self.type == "Jewel" then
elseif self.category == "Jewel" then
self.jewelData = { }
end
self.baseModList = baseList
Expand Down Expand Up @@ -1613,7 +1615,7 @@ function ItemClass:BuildModList()
self.sockets = newSockets
end
self.socketedJewelEffectModifier = 1 + calcLocal(baseList, "SocketedJewelEffect", "INC", 0) / 100
if self.base.weapon or self.base.type == "Wand" or self.base.type == "Sceptre" or self.base.type == "Staff" or self.type == "Ring" then
if self.base.tags.onehand or self.base.tags.twohand or self.category == "Ring" then
self.slotModList = { }
for i = 1, 2 do
self.slotModList[i] = self:BuildModListForSlotNum(baseList, i)
Expand Down
30 changes: 15 additions & 15 deletions src/Classes/ItemDBControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ local ItemDBClass = newClass("ItemDBControl", "ListControl", function(self, anch
self.sortMode = "NAME"
self.leaguesAndTypesLoaded = false
self.leagueList = { "Any league", "No league" }
self.typeList = { "Any type", "Armour", "Jewellery", "One Handed Melee", "Two Handed Melee" }
self.categoryList = { "Any type", "Armour", "Jewellery", "One Handed Melee", "Two Handed Melee" }
self.slotList = { "Any slot", "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring", "Belt", "Jewel" }
local baseY = dbType == "RARE" and -22 or -62
self.controls.slot = new("DropDownControl", {"BOTTOMLEFT",self,"TOPLEFT"}, {0, baseY, 179, 18}, self.slotList, function(index, value)
self.listBuildFlag = true
end)
self.controls.type = new("DropDownControl", {"LEFT",self.controls.slot,"RIGHT"}, {2, 0, 179, 18}, self.typeList, function(index, value)
self.controls.category = new("DropDownControl", {"LEFT",self.controls.slot,"RIGHT"}, {2, 0, 179, 18}, self.categoryList, function(index, value)
self.listBuildFlag = true
end)
if dbType == "UNIQUE" then
Expand Down Expand Up @@ -60,20 +60,20 @@ end)

function ItemDBClass:LoadLeaguesAndTypes()
local leagueFlag = { }
local typeFlag = { }
local categoryFlag = { }
for _, item in pairs(self.db.list) do
if item.league then
for leagueName in item.league:gmatch(" ?([%w ]+),?") do
leagueFlag[leagueName] = true
end
end
typeFlag[item.type] = true
categoryFlag[(item.label or item.category)..(item.class ~= item.category and ": "..item.class:gsub("([a-z])([A-Z])", "%1 %2") or "")] = true
end
for leagueName in pairsSortByKey(leagueFlag) do
t_insert(self.leagueList, leagueName)
end
for type in pairsSortByKey(typeFlag) do
t_insert(self.typeList, type)
for type in pairsSortByKey(categoryFlag) do
t_insert(self.categoryList, type)
end
self.leaguesAndTypesLoaded = true
end
Expand All @@ -85,22 +85,22 @@ function ItemDBClass:DoesItemMatchFilters(item)
return false
end
end
local typeSel = self.controls.type.selIndex
if typeSel > 1 then
if typeSel == 2 then
local categorySel = self.controls.category.selIndex
if categorySel > 1 then
if categorySel == 2 then
if not item.base.armour then
return false
end
elseif typeSel == 3 then
if not (item.type == "Amulet" or item.type == "Ring" or item.type == "Belt") then
elseif categorySel == 3 then
if not (item.category == "Amulet" or item.category == "Ring" or item.category == "Belt") then
return false
end
elseif typeSel == 4 or typeSel == 5 then
local weaponInfo = self.itemsTab.build.data.weaponTypeInfo[item.type]
if not (weaponInfo and weaponInfo.melee and ((typeSel == 4 and weaponInfo.oneHand) or (typeSel == 5 and not weaponInfo.oneHand))) then
elseif categorySel == 4 or categorySel == 5 then
local weaponInfo = self.itemsTab.build.data.weaponClassInfo[item.class]
if not (weaponInfo and weaponInfo.melee and ((categorySel == 4 and weaponInfo.oneHand) or (categorySel == 5 and not weaponInfo.oneHand))) then
return false
end
elseif item.type ~= self.typeList[typeSel] then
elseif ((item.label or item.category)..(item.class ~= item.category and ": "..item.class:gsub("([a-z])([A-Z])", "%1 %2") or "")) ~= self.categoryList[categorySel] then
return false
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/ItemListControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ local ItemListClass = newClass("ItemListControl", "ListControl", function(self,
end)

function ItemListClass:FindSocketedJewel(jewelId, excludeActiveSpec)
if not self.itemsTab.items[jewelId] or self.itemsTab.items[jewelId].type ~= "Jewel" then
if not self.itemsTab.items[jewelId] or self.itemsTab.items[jewelId].class ~= "Jewel" then
return nil
end
local treeTab = self.itemsTab.build.treeTab
Expand Down
Loading