Skip to content

Commit 64d026b

Browse files
author
LocalIdentity
committed
Merge branch 'dev' into fix_cluster-import
2 parents 1781ab2 + 4d5f815 commit 64d026b

144 files changed

Lines changed: 86953 additions & 48320 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

spec/System/TestAilments_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("TestAilments", function()
99

1010
it("maximum shock value", function()
1111
-- Shock Nova
12-
build.skillsTab:PasteSocketGroup("Slot: Weapon 1\nShock Nova 4/0 Default 1\n")
12+
build.skillsTab:PasteSocketGroup("Slot: Weapon 1\nShock Nova 4/0 1\n")
1313
runCallback("OnFrame")
1414
assert.are.equals(round(50 + 10), build.calcsTab.mainOutput.MaximumShock)
1515

@@ -23,7 +23,7 @@ describe("TestAilments", function()
2323
it("bleed is buffed by bleed chance", function()
2424
build.itemsTab:CreateDisplayItemFromRaw("New Item\nKarui Chopper")
2525
build.itemsTab:AddDisplayItem()
26-
build.skillsTab:PasteSocketGroup("Slot: Weapon 1\nHeavy Strike 1/0 Default 1\n")
26+
build.skillsTab:PasteSocketGroup("Slot: Weapon 1\nHeavy Strike 1/0 1\n")
2727
build.configTab.input.customMods = "\z
2828
attacks have 10% chance to cause bleeding\n\z
2929
"

spec/System/TestDefence_spec.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ describe("TestDefence", function()
132132
build.configTab.input.enemyIsBoss = "None"
133133
-- Petrified blood
134134
build.skillsTab:PasteSocketGroup("\z
135-
Petrified Blood 20/0 Default 1\n\z
136-
Arrogance 21/0 Default 1\n\z
135+
Petrified Blood 20/0 1\n\z
136+
Arrogance 21/0 1\n\z
137137
") -- 50% petrified effect, when exactly half of the life is reserved, should make the life pool be equivalent to no petrified effect and full life.
138138
build.skillsTab:ProcessSocketGroup(build.skillsTab.socketGroupList[1])
139139
build.configTab.input.customMods = "\z
@@ -155,8 +155,8 @@ describe("TestDefence", function()
155155
build.skillsTab.socketGroupList = {}
156156

157157
build.skillsTab:PasteSocketGroup("\z
158-
Petrified Blood 20/0 Default 1\n\z
159-
Arrogance 21/0 Default 1\n\z
158+
Petrified Blood 20/0 1\n\z
159+
Arrogance 21/0 1\n\z
160160
")
161161
build.skillsTab:ProcessSocketGroup(build.skillsTab.socketGroupList[1])
162162
build.configTab.input.customMods = "\z
@@ -180,7 +180,7 @@ describe("TestDefence", function()
180180
build.skillsTab.socketGroupList = {}
181181

182182
build.skillsTab:PasteSocketGroup("\z
183-
Petrified Blood 20/0 Default 1\n\z
183+
Petrified Blood 20/0 1\n\z
184184
") -- 80% petrified effect, starting from full life, should make the life pool be equivalent to 0.5 * life (unprotected upper half) and then 5 * 0.5 * life (protected lower half), making it 3* bigger in total
185185
build.skillsTab:ProcessSocketGroup(build.skillsTab.socketGroupList[1])
186186
build.configTab.input.customMods = "\z
@@ -238,8 +238,8 @@ describe("TestDefence", function()
238238

239239
-- Progenesis + petrified blood
240240
build.skillsTab:PasteSocketGroup("\z
241-
Petrified Blood 20/0 Default 1\n\z
242-
Arrogance 21/0 Default 1\n\z
241+
Petrified Blood 20/0 1\n\z
242+
Arrogance 21/0 1\n\z
243243
")
244244
build.skillsTab:ProcessSocketGroup(build.skillsTab.socketGroupList[1])
245245
build.configTab.input.customMods = "\z
@@ -263,7 +263,7 @@ describe("TestDefence", function()
263263
build.skillsTab.socketGroupList = {}
264264

265265
build.skillsTab:PasteSocketGroup("\z
266-
Petrified Blood 20/0 Default 1\n\z
266+
Petrified Blood 20/0 1\n\z
267267
")
268268
build.skillsTab:ProcessSocketGroup(build.skillsTab.socketGroupList[1])
269269
build.configTab.input.customMods = "\z
@@ -286,7 +286,7 @@ describe("TestDefence", function()
286286
build.skillsTab.socketGroupList = {}
287287

288288
build.skillsTab:PasteSocketGroup("\z
289-
Petrified Blood 20/0 Default 1\n\z
289+
Petrified Blood 20/0 1\n\z
290290
")
291291
build.skillsTab:ProcessSocketGroup(build.skillsTab.socketGroupList[1])
292292
build.configTab.input.customMods = "\z
@@ -315,7 +315,7 @@ describe("TestDefence", function()
315315
assert.are.equals(20, poolsRemaining.LifeBelowHalfLossLostOverTime)
316316

317317
build.skillsTab:PasteSocketGroup("\z
318-
Petrified Blood 20/0 Default 1\n\z
318+
Petrified Blood 20/0 1\n\z
319319
")
320320
build.skillsTab:ProcessSocketGroup(build.skillsTab.socketGroupList[1])
321321
build.configTab.input.customMods = "\z

spec/System/TestImpale_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ describe("TestAttacks", function()
286286

287287
it("impale dual wield simultaneous attack", function()
288288
newBuild()
289-
build.skillsTab:PasteSocketGroup("Cleave 20/0 Default 1\n")
289+
build.skillsTab:PasteSocketGroup("Cleave 20/0 1\n")
290290
-- exactly 100
291291
build.itemsTab:CreateDisplayItemFromRaw("New Item\nVaal Blade\nQuality: 0\nAdds 54 to 14 physical damage\n50% chance to Impale Enemies on Hit with Attacks")
292292
build.itemsTab:AddDisplayItem()
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
describe("TestImportReimport", function()
2+
local dkjson = require "dkjson"
3+
local DEFAULT_CHARACTER_LEVEL = 12
4+
local DEFAULT_ITEM_LEVEL = 10
5+
local TEST_IMPORT_ITEM_ID = "test-import-item-1"
6+
local DEFAULT_SOCKET_COLOR = "R"
7+
8+
before_each(function()
9+
newBuild()
10+
end)
11+
12+
local function makeGemProperties(level)
13+
return {
14+
{ name = "Level", values = { { tostring(level), 0 } } },
15+
{ name = "Quality", values = { { "+0%", 0 } } },
16+
}
17+
end
18+
19+
local function makeSocketedGemEntry(socket, support, typeLine, level)
20+
return {
21+
socket = socket,
22+
support = support,
23+
typeLine = typeLine,
24+
properties = makeGemProperties(level),
25+
}
26+
end
27+
28+
-- Build a minimal import item so the tests stay focused on state, not fixture noise.
29+
local function makeImportItem(itemTypeLine, inventoryId, socketedItems, itemId)
30+
local maxSocketIndex = 0
31+
for _, socketedItem in ipairs(socketedItems) do
32+
maxSocketIndex = math.max(maxSocketIndex, socketedItem.socket + 1)
33+
end
34+
local sockets = {}
35+
for index = 1, maxSocketIndex do
36+
sockets[index] = { group = 0, sColour = DEFAULT_SOCKET_COLOR }
37+
end
38+
return {
39+
id = itemId or TEST_IMPORT_ITEM_ID,
40+
frameType = 0,
41+
name = "",
42+
typeLine = itemTypeLine,
43+
inventoryId = inventoryId,
44+
ilvl = DEFAULT_ITEM_LEVEL,
45+
properties = {},
46+
sockets = sockets,
47+
socketedItems = socketedItems,
48+
}
49+
end
50+
51+
-- Build a minimal import payload so the tests stay focused on state, not fixture noise.
52+
local function buildImportPayload(items)
53+
return dkjson.encode({
54+
character = { level = DEFAULT_CHARACTER_LEVEL },
55+
items = items,
56+
})
57+
end
58+
59+
local function reimportSocketedItemsWithOptions(itemTypeLine, inventoryId, socketedItems, clearItems)
60+
build.importTab.controls.charImportItemsClearSkills.state = true
61+
build.importTab.controls.charImportItemsClearItems.state = clearItems
62+
build.importTab:ImportItemsAndSkills(buildImportPayload({
63+
makeImportItem(itemTypeLine, inventoryId, socketedItems),
64+
}))
65+
runCallback("OnFrame")
66+
end
67+
68+
local function reimportSingleSocketedGemWithOptions(itemTypeLine, inventoryId, gemName, clearItems)
69+
reimportSocketedItemsWithOptions(itemTypeLine, inventoryId, {
70+
makeSocketedGemEntry(0, false, gemName, 20),
71+
}, clearItems)
72+
end
73+
74+
local function reimportSingleSocketedGem(itemTypeLine, inventoryId, gemName)
75+
reimportSingleSocketedGemWithOptions(itemTypeLine, inventoryId, gemName, false)
76+
end
77+
78+
local function assertReimportPreservesSkillSubstate(slotName, itemTypeLine, inventoryId, gemName, fieldName, fieldValue)
79+
build.skillsTab:PasteSocketGroup(string.format([[
80+
Slot: %s
81+
%s 20/0 1
82+
]], slotName, gemName))
83+
runCallback("OnFrame")
84+
85+
local socketGroup = build.skillsTab.socketGroupList[1]
86+
local srcInstance = socketGroup.displaySkillList[1].activeEffect.srcInstance
87+
srcInstance[fieldName] = fieldValue
88+
srcInstance[fieldName.."Calcs"] = fieldValue
89+
build.modFlag = true
90+
build.buildFlag = true
91+
runCallback("OnFrame")
92+
93+
reimportSingleSocketedGem(itemTypeLine, inventoryId, gemName)
94+
95+
socketGroup = build.skillsTab.socketGroupList[1]
96+
srcInstance = socketGroup.displaySkillList[1].activeEffect.srcInstance
97+
assert.are.equal(fieldValue, srcInstance[fieldName])
98+
assert.are.equal(fieldValue, srcInstance[fieldName.."Calcs"])
99+
end
100+
101+
it("preserves full DPS state and manually disabled gems when reimporting items and skills", function()
102+
build.skillsTab:PasteSocketGroup([[
103+
Slot: Helmet
104+
Cleave 1/0 1
105+
Heavy Strike 1/0 1
106+
Added Fire Damage 1/0 DISABLED 1
107+
]])
108+
runCallback("OnFrame")
109+
110+
local socketGroup = build.skillsTab.socketGroupList[1]
111+
socketGroup.includeInFullDPS = true
112+
socketGroup.mainActiveSkill = 2
113+
runCallback("OnFrame")
114+
115+
build.importTab.controls.charImportItemsClearSkills.state = true
116+
build.importTab.controls.charImportItemsClearItems.state = false
117+
build.importTab:ImportItemsAndSkills(buildImportPayload({
118+
makeImportItem("Iron Hat", "Helm", {
119+
makeSocketedGemEntry(0, false, "Cleave", 1),
120+
makeSocketedGemEntry(1, false, "Heavy Strike", 1),
121+
makeSocketedGemEntry(2, true, "Added Fire Damage Support", 2),
122+
}),
123+
}))
124+
runCallback("OnFrame")
125+
126+
socketGroup = build.skillsTab.socketGroupList[1]
127+
assert.are.equal("Helmet", socketGroup.slot)
128+
assert.is_true(socketGroup.includeInFullDPS)
129+
assert.are.equal(2, socketGroup.mainActiveSkill)
130+
assert.are.equal(2, socketGroup.gemList[3].level)
131+
assert.is_false(socketGroup.gemList[3].enabled)
132+
end)
133+
134+
it("preserves full DPS state and disabled gems when reimporting with deleted equipment", function()
135+
build.skillsTab:PasteSocketGroup([[
136+
Slot: Helmet
137+
Cleave 1/0 1
138+
Heavy Strike 1/0 1
139+
Added Fire Damage 1/0 DISABLED 1
140+
]])
141+
runCallback("OnFrame")
142+
143+
local socketGroup = build.skillsTab.socketGroupList[1]
144+
socketGroup.includeInFullDPS = true
145+
socketGroup.mainActiveSkill = 2
146+
runCallback("OnFrame")
147+
148+
reimportSocketedItemsWithOptions("Iron Hat", "Helm", {
149+
makeSocketedGemEntry(0, false, "Cleave", 1),
150+
makeSocketedGemEntry(1, false, "Heavy Strike", 1),
151+
makeSocketedGemEntry(2, true, "Added Fire Damage Support", 2),
152+
}, true)
153+
154+
socketGroup = build.skillsTab.socketGroupList[1]
155+
assert.are.equal("Helmet", socketGroup.slot)
156+
assert.is_true(socketGroup.includeInFullDPS)
157+
assert.are.equal(2, socketGroup.mainActiveSkill)
158+
assert.are.equal(2, socketGroup.gemList[3].level)
159+
assert.is_false(socketGroup.gemList[3].enabled)
160+
end)
161+
162+
it("preserves two socket groups when reimporting items and skills", function()
163+
build.skillsTab:PasteSocketGroup([[
164+
Slot: Helmet
165+
Cleave 1/0 1
166+
Heavy Strike 1/0 1
167+
Added Fire Damage 1/0 DISABLED 1
168+
]])
169+
runCallback("OnFrame")
170+
171+
build.skillsTab:PasteSocketGroup([[
172+
Slot: Gloves
173+
Blight 20/0 1
174+
]])
175+
runCallback("OnFrame")
176+
177+
local helmetGroup = build.skillsTab.socketGroupList[1]
178+
helmetGroup.includeInFullDPS = true
179+
helmetGroup.mainActiveSkill = 2
180+
local glovesGroup = build.skillsTab.socketGroupList[2]
181+
glovesGroup.enabled = false
182+
runCallback("OnFrame")
183+
184+
build.importTab.controls.charImportItemsClearSkills.state = true
185+
build.importTab.controls.charImportItemsClearItems.state = false
186+
build.importTab:ImportItemsAndSkills(buildImportPayload({
187+
makeImportItem("Iron Hat", "Helm", {
188+
makeSocketedGemEntry(0, false, "Cleave", 1),
189+
makeSocketedGemEntry(1, false, "Heavy Strike", 1),
190+
makeSocketedGemEntry(2, true, "Added Fire Damage Support", 2),
191+
}, "test-import-item-helmet"),
192+
makeImportItem("Rawhide Gloves", "Gloves", {
193+
makeSocketedGemEntry(0, false, "Blight", 20),
194+
}, "test-import-item-gloves"),
195+
}))
196+
runCallback("OnFrame")
197+
198+
local groupsBySlot = {}
199+
for _, socketGroup in ipairs(build.skillsTab.socketGroupList) do
200+
groupsBySlot[socketGroup.slot] = socketGroup
201+
end
202+
203+
assert.are.equal(2, #build.skillsTab.socketGroupList)
204+
assert.is_not_nil(groupsBySlot.Helmet)
205+
assert.is_not_nil(groupsBySlot.Gloves)
206+
assert.is_true(groupsBySlot.Helmet.includeInFullDPS)
207+
assert.are.equal(2, groupsBySlot.Helmet.mainActiveSkill)
208+
assert.is_false(groupsBySlot.Gloves.enabled)
209+
end)
210+
211+
it("preserves skill part selection when reimporting items and skills", function()
212+
assertReimportPreservesSkillSubstate("Helmet", "Iron Hat", "Helm", "Blight", "skillPart", 2)
213+
end)
214+
215+
it("preserves stage count when reimporting items and skills", function()
216+
assertReimportPreservesSkillSubstate("Weapon 1", "Driftwood Wand", "Weapon", "Scorching Ray", "skillStageCount", 8)
217+
end)
218+
219+
it("preserves mine count when reimporting items and skills", function()
220+
assertReimportPreservesSkillSubstate("Gloves", "Rawhide Gloves", "Gloves", "Pyroclast Mine", "skillMineCount", 12)
221+
end)
222+
223+
it("preserves minion skill when reimporting items and skills", function()
224+
assertReimportPreservesSkillSubstate("Gloves", "Rawhide Gloves", "Gloves", "Summon Chaos Golem", "skillMinionSkill", 3)
225+
end)
226+
end)

0 commit comments

Comments
 (0)