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
88 changes: 88 additions & 0 deletions spec/System/TestItemsTab_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,92 @@ describe("TestItemsTab", function()
end)
end)
end)

describe("TestMartialArtistRunes", function()
before_each(function()
newBuild()
end)

local function enableSlots()
build.configTab.input.customMods = "Can tattoo runes onto your body, gaining"
build.configTab:BuildModList()
build.buildFlag = true
runCallback("OnFrame")
end

local function selectRune(slotName, runeName)
local slot = build.itemsTab.runeSlots[slotName]
slot:SelByValue(runeName, "name")
enableSlots()
return slot
end


it("creates the expected character rune slots", function()
local expected = {
"Helmet Rune #1",
"Body Armour Rune #1",
"Body Armour Rune #2",
"Gloves Rune #1",
"Boots Rune #1",
}
for _, slotName in ipairs(expected) do
assert.is_not_nil(build.itemsTab.runeSlots[slotName])
end
end)

it("only lists global (non-local) runes and defaults to None", function()
local slot = build.itemsTab.runeSlots["Helmet Rune #1"]
assert.are.equals("None", slot.list[1].label)
for _, rune in ipairs(slot.list) do
assert.is_not_nil(rune.mods)
end
end)

it("applies a global armour rune's mods to the character", function()
local baseFireRes = build.calcsTab.mainOutput.FireResistTotal
selectRune("Helmet Rune #1", "Desert Rune")
assert.are.equals(baseFireRes + 14, build.calcsTab.mainOutput.FireResistTotal)
end)

it("selecting None applies no rune mods", function()
local baseFireRes = build.calcsTab.mainOutput.FireResistTotal
selectRune("Helmet Rune #1", "Desert Rune")
assert.are.equals(baseFireRes + 14, build.calcsTab.mainOutput.FireResistTotal)
selectRune("Helmet Rune #1", nil)
assert.are.equals(baseFireRes, build.calcsTab.mainOutput.FireResistTotal)
end)

it("stacks runes from independent character slots", function()
local baseFireRes = build.calcsTab.mainOutput.FireResistTotal
build.itemsTab.runeSlots["Helmet Rune #1"]:SelByValue("Desert Rune", "name")
build.itemsTab.runeSlots["Boots Rune #1"]:SelByValue("Desert Rune", "name")
enableSlots()
assert.are.equals(baseFireRes + 28, build.calcsTab.mainOutput.FireResistTotal)
end)

it("sets the SocketRunesOnCharacter flag when granted by a mod", function()
assert.is_nil(build.calcsTab.mainEnv.modDB:Flag(nil, "SocketRunesOnCharacter"))

build.configTab.input.customMods = "Can tattoo runes onto your body, gaining"
build.configTab:BuildModList()
build.buildFlag = true
runCallback("OnFrame")

assert.truthy(build.calcsTab.mainEnv.modDB:Flag(nil, "SocketRunesOnCharacter"))
end)

it("warns when a limited rune exceeds its augment limit", function()
build.itemsTab.runeSlots["Body Armour Rune #1"]:SelByValue("Craiceann's Rune of Warding", "name")
build.itemsTab.runeSlots["Body Armour Rune #2"]:SelByValue("Craiceann's Rune of Warding", "name")
build.configTab.input.customMods = "Can tattoo runes onto your body, gaining"
build.configTab:BuildModList()
build.buildFlag = true
runCallback("OnFrame")

local warnings = build.controls.warnings.lines
assert.is_not_nil(warnings)
assert.equal("You are exceeding augment limit with: Craiceann's Rune of Warding", warnings[1])
end)
end)
end)
8 changes: 7 additions & 1 deletion src/Classes/DropDownControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,22 @@ function DropDownClass:DrawSearchHighlights(label, searchInfo, x, y, width, heig
end


function DropDownClass:SelByValue(value, key)
function DropDownClass:SelByValue(value, key, callSelFunc)
for index, listVal in ipairs(self.list) do
if type(listVal) == "table" then
if listVal[key] == value then
self.selIndex = index
if callSelFunc and self.selFunc then
self.selFunc(index, self.list[index])
end
return
end
else
if listVal == value then
self.selIndex = index
if callSelFunc and self.selFunc then
self.selFunc(index, self.list[index])
end
return
end
end
Expand Down
21 changes: 20 additions & 1 deletion src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1145,12 +1145,31 @@ function ImportTabClass:ImportItemsAndSkills(charData)
return charData -- For the wrapper
end

function ImportTabClass:ImportChakra(slotName, runeName)
local slot = self.build.itemsTab.runeSlots[slotName]
-- note that if the rune is not in ModRunes.lua, this will not select it
if slot then
slot:SelByValue(runeName, "name", true)
end
end

local rarityMap = { [0] = "NORMAL", "MAGIC", "RARE", "UNIQUE", [9] = "RELIC", [10] = "RELIC", [13] = "RARE", [14] = "UNIQUE" }
local slotMap = { ["Weapon"] = "Weapon 1", ["Offhand"] = "Weapon 2", ["Weapon2"] = "Weapon 1 Swap", ["Offhand2"] = "Weapon 2 Swap", ["Helm"] = "Helmet", ["BodyArmour"] = "Body Armour", ["Gloves"] = "Gloves", ["Boots"] = "Boots", ["Amulet"] = "Amulet", ["Ring"] = "Ring 1", ["Ring2"] = "Ring 2", ["Ring3"] = "Ring 3", ["Belt"] = "Belt", ["IncursionArmLeft"] = "Arm 2", ["IncursionArmRight"] = "Arm 1", ["IncursionLegLeft"] = "Leg 2", ["IncursionLegRight"] = "Leg 1" }

function ImportTabClass:ImportItem(itemData, slotName)
if not slotName then
if itemData.inventoryId == "PassiveJewels" then
-- monk martial artist rune tattoos
if itemData.inventoryId == "Chakra" then
-- TODO: should probably be exported from chakra slots table
-- API doesn't have slots directly, but has an x position similar to flasks
slotMap = {"Helmet Rune #1", "Body Armour Rune #1", "Body Armour Rune #2", "Gloves Rune #1", "Boots Rune #1"}
if slotMap[itemData.x + 1] and itemData.baseType then
slotName = slotMap[itemData.x + 1]
-- runes are imported differently as they're not items located in your inventory
self:ImportChakra(slotName, itemData.baseType)
return
end
elseif itemData.inventoryId == "PassiveJewels" then
slotName = "Jewel ".. self.build.latestTree.jewelSlots[itemData.x + 1]
elseif itemData.inventoryId == "Flask" then
if itemData.x > 1 then
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
local runeData = data.itemMods.Runes[specVal]
if runeData then
for _, slotData in pairs(runeData) do
runeLevel = math.max(runeLevel, slotData.rank[1])
runeLevel = m_max(runeLevel, slotData.rank)
end
end
if runeLevel > 0 and (not self.requirements.runeLevel or runeLevel > self.requirements.runeLevel) then
Expand Down
Loading
Loading