Skip to content
Open
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
25 changes: 25 additions & 0 deletions spec/System/TestGemSocketQuality_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,31 @@ describe("TestGemSocketQuality", function()
assert.are.equals(0, build.calcsTab.mainOutput.GemQuality)
end)

it("uses replacement item socket colours in item comparisons", function()
equipBody("R-R-R")
build.skillsTab:PasteSocketGroup("Slot: Body Armour\nFireball 20/0 1\nControlled Destruction 20/0 1\n")
runCallback("OnFrame")
assert.are.equals(0, build.calcsTab.mainOutput.GemQuality)
local baseDPS = build.calcsTab.mainOutput.CombinedDPS

build.itemsTab:CreateDisplayItemFromRaw(
"Rarity: RARE\nReplacement Robe\nSage's Robe\nQuality: 0\nSockets: B-B-B\nImplicits: 0\n")
local replacement = build.itemsTab.displayItem
build.itemsTab:AddDisplayItem(true)
runCallback("OnFrame")

local calcFunc = build.calcsTab:GetMiscCalculator()
local preview = calcFunc({ repSlotName = "Body Armour", repItem = replacement })
assert.are.equals(10, preview.GemQuality)
assert.is_true(preview.CombinedDPS > baseDPS)

build.itemsTab.slots["Body Armour"]:SetSelItemId(replacement.id)
build.buildFlag = true
runCallback("OnFrame")
assert.are.equals(preview.GemQuality, build.calcsTab.mainOutput.GemQuality)
assert.are.equals(preview.CombinedDPS, build.calcsTab.mainOutput.CombinedDPS)
end)

it("always grants the bonus with Dialla's 'always matches' mod", function()
-- Blue gem in a red socket
equipBody("R-R-R", "Gems Socketed always have the Quality bonus from Socket Colour\n")
Expand Down
5 changes: 2 additions & 3 deletions src/Modules/CalcActiveSkill.lua
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,8 @@ function calcs.buildActiveSkillModList(env, activeSkill)
skillModList:NewMod("GemLevel", "BASE", activeSkill.activeEffect.srcInstance and activeSkill.activeEffect.srcInstance.level or activeSkill.activeEffect.level, "Max Level")
skillModList:NewMod("GemQuality", "BASE", activeSkill.activeEffect.srcInstance and activeSkill.activeEffect.srcInstance.quality or activeSkill.activeEffect.quality, "Max Quality")
-- matching socket bonus
local socketMatches = activeSkill.activeEffect.srcInstance and activeSkill.activeEffect.srcInstance.matchesSocket or activeSkill.activeEffect.matchesSocket
if socketMatches then
skillModList:NewMod("GemSocketQuality", "BASE", data.misc.MatchingSocketQualityBonus, "Socket Quality")
if (activeSkill.activeEffect.socketQuality or 0) > 0 then
skillModList:NewMod("GemSocketQuality", "BASE", activeSkill.activeEffect.socketQuality, "Socket Quality")
end
for _, supportProperty in ipairs(skillModList:Tabulate("LIST", activeSkill.skillCfg, "SupportedGemProperty")) do
local value = supportProperty.value
Expand Down
36 changes: 32 additions & 4 deletions src/Modules/CalcSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ local m_min = math.min
local m_max = math.max

local tempTable1 = { }
local gemSocketColours = { "R", "G", "B" }

local function getMatchingSocketQuality(env, groupCfg, gemInstance, socketIndex)
local item = groupCfg.slotName and env.player.itemList[groupCfg.slotName]
local sockets = item and item.sockets
if not sockets then
return 0
elseif sockets.colourAlwaysMatches then
return data.misc.MatchingSocketQualityBonus
end
local grantedEffect = gemInstance.grantedEffect or (gemInstance.gemData and gemInstance.gemData.grantedEffect)
local gemColour = grantedEffect and grantedEffect.color and gemSocketColours[grantedEffect.color]
local socket = socketIndex and sockets[socketIndex]
return gemColour and socket and socket.color == gemColour and data.misc.MatchingSocketQualityBonus or 0
end

-- Initialise modifier database with stats and conditions common to all actors
function calcs.initModDB(env, modDB)
Expand Down Expand Up @@ -1600,6 +1615,17 @@ function calcs.initEnv(build, mode, override, specEnv)
local supportLists = { }
local groupCfgList = { }
local processedSockets = {}
local socketIndexByGem = {}
local slotSocketedCounts = {}
for _, group in ipairs(build.skillsTab.socketGroupList) do
if group.slot then
local socketOffset = slotSocketedCounts[group.slot] or 0
for gemIndex, gemInstance in ipairs(group.gemList) do
socketIndexByGem[gemInstance] = socketOffset + gemIndex
end
slotSocketedCounts[group.slot] = socketOffset + #group.gemList
end
end
-- Process support gems adding them to applicable support lists
for index, group in ipairs(build.skillsTab.socketGroupList) do
local slot = group.slot and build.itemsTab.slots[group.slot]
Expand Down Expand Up @@ -1677,15 +1703,16 @@ function calcs.initEnv(build, mode, override, specEnv)
if not grantedEffect or not grantedEffect.support then
return
end
local actualQuality = gemInstance.quality + (gemInstance.matchesSocket and data.misc.MatchingSocketQualityBonus or 0)
local socketQuality = getMatchingSocketQuality(env, groupCfg, gemInstance, socketIndexByGem[gemInstance])
local actualQuality = gemInstance.quality + socketQuality
local supportEffect = {
grantedEffect = grantedEffect,
level = gemInstance.level,
quality = actualQuality,
globalQuality = 0,
itemQuality = 0,
supportQuality = 0,
socketQuality = gemInstance.matchesSocket and data.misc.MatchingSocketQualityBonus or 0,
socketQuality = socketQuality,
srcInstance = gemInstance,
gemData = gemInstance.gemData,
superseded = false,
Expand Down Expand Up @@ -1754,15 +1781,16 @@ function calcs.initEnv(build, mode, override, specEnv)
for index, grantedEffect in ipairs(grantedEffectList) do
if not grantedEffect.support and not grantedEffect.unsupported and (not grantedEffect.hasGlobalEffect or gemInstance["enableGlobal"..index]) then
slotHasActiveSkill = true
local actualQuality = gemInstance.quality + (gemInstance.matchesSocket and data.misc.MatchingSocketQualityBonus or 0)
local socketQuality = getMatchingSocketQuality(env, groupCfg, gemInstance, socketIndexByGem[gemInstance])
local actualQuality = gemInstance.quality + socketQuality
local activeEffect = {
grantedEffect = grantedEffect,
level = gemInstance.level,
quality = actualQuality,
globalQuality = 0,
itemQuality = 0,
supportQuality = 0,
socketQuality = gemInstance.matchesSocket and data.misc.MatchingSocketQualityBonus or 0,
socketQuality = socketQuality,
srcInstance = gemInstance,
gemData = gemInstance.gemData,
}
Expand Down
Loading