Skip to content

Commit c0a223e

Browse files
committed
Change class constructors to call the constructor directly, instead of using new() and varargs
1 parent 41d0976 commit c0a223e

67 files changed

Lines changed: 1255 additions & 1248 deletions

Some content is hidden

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

spec/System/TestItemParse_spec.lua

Lines changed: 95 additions & 95 deletions
Large diffs are not rendered by default.

spec/System/TestItemTools_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe("TestItemTools", function()
5050
if not common.classes.ItemsTab then
5151
LoadModule("Classes/ItemsTab")
5252
end
53-
local item = new("Item", [[
53+
local item = new("Item"):Item([[
5454
Rarity: Rare
5555
Dire Thread
5656
Cord Belt

spec/System/TestRadiusJewelStatDiff_spec.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ end
144144
-- parsing path: the mod sets jewelData.radiusIndex (an annular ring index, not
145145
-- the same as the full-circle index 3 that "Radius: Large" would produce).
146146
local function newThreadOfHope()
147-
return new("Item", "Rarity: UNIQUE\n" ..
147+
return new("Item"):Item("Rarity: UNIQUE\n" ..
148148
"Thread of Hope\n" ..
149149
"Crimson Jewel\n" ..
150150
"Variant: Large Ring\n" ..
@@ -156,7 +156,7 @@ local function newThreadOfHope()
156156
end
157157

158158
local function newCustomLeapJewel(name)
159-
return new("Item", "Rarity: RARE\n" ..
159+
return new("Item"):Item("Rarity: RARE\n" ..
160160
name .. "\n" ..
161161
"Crimson Jewel\n" ..
162162
"Radius: Variable\n" ..
@@ -166,7 +166,7 @@ local function newCustomLeapJewel(name)
166166
end
167167

168168
local function newPlainJewel()
169-
return new("Item", "Rarity: RARE\n" ..
169+
return new("Item"):Item("Rarity: RARE\n" ..
170170
"Plain Spark\n" ..
171171
"Crimson Jewel\n" ..
172172
"Implicits: 0\n")
@@ -176,7 +176,7 @@ end
176176
-- a specific keystone. The parser populates both impossibleEscapeKeystone
177177
-- and impossibleEscapeKeystones from the "in Radius of X" mod.
178178
local function newImpossibleEscape(keystoneName)
179-
return new("Item", "Rarity: UNIQUE\n" ..
179+
return new("Item"):Item("Rarity: UNIQUE\n" ..
180180
"Impossible Escape\n" ..
181181
"Viridian Jewel\n" ..
182182
"Radius: Small\n" ..
@@ -196,7 +196,7 @@ end
196196
-- text are intentionally omitted; the tests exercise behavior, not the parser
197197
-- against the full serialized form.
198198
local function newLethalPride()
199-
return new("Item", "Rarity: UNIQUE\n" ..
199+
return new("Item"):Item("Rarity: UNIQUE\n" ..
200200
"Lethal Pride\n" ..
201201
"Timeless Jewel\n" ..
202202
"Radius: Large\n" ..
@@ -211,7 +211,7 @@ end
211211
-- will reset the modList back to the original tree node modList.
212212
local function simulateKaruiConquest(node)
213213
node.conqueredBy = { id = 10000, conqueror = { id = 1, type = "karui" } }
214-
node.modList = new("ModList")
214+
node.modList = new("ModList"):ModList()
215215
node.modList:NewMod("Life", "BASE", 100, "Timeless Jewel")
216216
end
217217

@@ -220,7 +220,7 @@ local function overrideNodeWithLife(spec, node, life)
220220
override.id = node.id
221221
override.dn = node.dn
222222
override.sd = { "+" .. life .. " to maximum Life" }
223-
override.modList = new("ModList")
223+
override.modList = new("ModList"):ModList()
224224
override.modList:NewMod("Life", "BASE", life, "Test")
225225
spec.hashOverrides[node.id] = override
226226
end
@@ -456,7 +456,7 @@ describe("TestRadiusJewelStatDiff", function()
456456

457457
local plainJewel = newPlainJewel()
458458
build.itemsTab:AddItem(plainJewel, true)
459-
local tooltip = new("Tooltip")
459+
local tooltip = new("Tooltip"):Tooltip()
460460
build.itemsTab:AddItemTooltip(tooltip, plainJewel, slot)
461461

462462
assert.is_true(tooltipContains(tooltip, "Equipping this item in"),
@@ -515,7 +515,7 @@ describe("TestRadiusJewelStatDiff", function()
515515
assert.are.equals(2, #targetNode.intuitiveLeapLikesAffecting,
516516
"Allocated overlap node should still be supported by both radius jewels")
517517

518-
local tooltip = new("Tooltip")
518+
local tooltip = new("Tooltip"):Tooltip()
519519
build.itemsTab:AddItemTooltip(tooltip, itemA, slotA)
520520

521521
assert.is_false(tooltipContainsNegativeStat(tooltip, "Total Life"),
@@ -590,7 +590,7 @@ describe("TestRadiusJewelStatDiff", function()
590590
assert.is_true(#nodesInRadius > 0, "Should have allocated nodes in jewel radius")
591591
simulateKaruiConquest(nodesInRadius[1])
592592

593-
local tooltip = new("Tooltip")
593+
local tooltip = new("Tooltip"):Tooltip()
594594
build.itemsTab:AddItemTooltip(tooltip, item, slot)
595595

596596
assert.is_true(tooltipContains(tooltip, "Removing this item"),

spec/System/TestTradeQueryCurrency_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ describe("TradeQuery Currency Conversion", function()
22
local mock_tradeQuery
33

44
before_each(function()
5-
mock_tradeQuery = new("TradeQuery", { itemsTab = {} })
5+
mock_tradeQuery = new("TradeQuery"):TradeQuery({ itemsTab = {} })
66
end)
77

88
-- test case for commit: "Skip callback on errors to prevent incomplete conversions"

spec/System/TestTradeQueryGenerator_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
describe("TradeQueryGenerator", function()
2-
local mock_queryGen = new("TradeQueryGenerator", { itemsTab = {} })
2+
local mock_queryGen = new("TradeQueryGenerator"):TradeQueryGenerator({ itemsTab = {} })
33

44
describe("ProcessMod", function()
55
-- Pass: Mod line maps correctly to trade stat entry without error

spec/System/TestTradeQueryRateLimiter_spec.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ describe("TradeQueryRateLimiter", function()
33
-- Pass: Extracts keys/values correctly
44
-- Fail: Nil/malformed values, indicating regex failure, breaking policy updates from API
55
it("parses basic headers", function()
6-
local limiter = new("TradeQueryRateLimiter")
6+
local limiter = new("TradeQueryRateLimiter"):TradeQueryRateLimiter()
77
local headers = limiter:ParseHeader("X-Rate-Limit-Policy: test\nRetry-After: 5\nContent-Type: json")
88
assert.are.equal(headers["x-rate-limit-policy"], "test")
99
assert.are.equal(headers["retry-after"], "5")
@@ -15,7 +15,7 @@ describe("TradeQueryRateLimiter", function()
1515
-- Pass: Extracts rules/limits/states accurately
1616
-- Fail: Wrong buckets/windows, indicating parsing bug, enforcing incorrect rates
1717
it("parses full policy", function()
18-
local limiter = new("TradeQueryRateLimiter")
18+
local limiter = new("TradeQueryRateLimiter"):TradeQueryRateLimiter()
1919
local header = "X-Rate-Limit-Policy: trade-search-request-limit\nX-Rate-Limit-Rules: Ip,Account\nX-Rate-Limit-Ip: 8:10:60,15:60:120\nX-Rate-Limit-Ip-State: 7:10:60,14:60:120\nX-Rate-Limit-Account: 2:5:60\nX-Rate-Limit-Account-State: 1:5:60\nRetry-After: 10"
2020
local policies = limiter:ParsePolicy(header)
2121
local policy = policies["trade-search-request-limit"]
@@ -30,7 +30,7 @@ describe("TradeQueryRateLimiter", function()
3030
-- Pass: Reduces limits (e.g., 5 -> 4)
3131
-- Fail: Unchanged limits, indicating margin ignored, risking user over-requests
3232
it("applies margin to limits", function()
33-
local limiter = new("TradeQueryRateLimiter")
33+
local limiter = new("TradeQueryRateLimiter"):TradeQueryRateLimiter()
3434
limiter.limitMargin = 1
3535
local header = "X-Rate-Limit-Policy: test\nX-Rate-Limit-Rules: Ip\nX-Rate-Limit-Ip: 5:10:60\nX-Rate-Limit-Ip-State: 4:10:60"
3636
limiter:UpdateFromHeader(header)
@@ -42,7 +42,7 @@ describe("TradeQueryRateLimiter", function()
4242
-- Pass: Delays past timestamp
4343
-- Fail: Allows immediate request, indicating ignored cooldowns, causing 429 errors
4444
it("blocks on retry-after", function()
45-
local limiter = new("TradeQueryRateLimiter")
45+
local limiter = new("TradeQueryRateLimiter"):TradeQueryRateLimiter()
4646
local now = os.time()
4747
limiter.policies["test"] = {}
4848
limiter.retryAfter["test"] = now + 10
@@ -53,7 +53,7 @@ describe("TradeQueryRateLimiter", function()
5353
-- Pass: Calculates delay from timestamps
5454
-- Fail: Allows request in limit, indicating state misread, over-throttling or bans
5555
it("blocks on window limit", function()
56-
local limiter = new("TradeQueryRateLimiter")
56+
local limiter = new("TradeQueryRateLimiter"):TradeQueryRateLimiter()
5757
local now = os.time()
5858
limiter.policies["test"] = { ["ip"] = { ["limits"] = { ["10"] = { ["request"] = 1, ["timeout"] = 60 } }, ["state"] = { ["10"] = { ["request"] = 1, ["timeout"] = 0 } } } }
5959
limiter.requestHistory["test"] = { timestamps = {now - 5} }
@@ -67,7 +67,7 @@ describe("TradeQueryRateLimiter", function()
6767
-- Pass: Removes old stamps, decrements to 1
6868
-- Fail: Stale data persists, indicating aging bug, perpetual blocking
6969
it("cleans up timestamps and decrements", function()
70-
local limiter = new("TradeQueryRateLimiter")
70+
local limiter = new("TradeQueryRateLimiter"):TradeQueryRateLimiter()
7171
limiter.policies["test"] = { ["ip"] = { ["state"] = { ["10"] = { ["request"] = 2, ["timeout"] = 0, ["decremented"] = nil } } } }
7272
limiter.requestHistory["test"] = { timestamps = {os.time() - 15, os.time() - 5}, maxWindow=10, lastCheck=os.time() - 10 }
7373
limiter:AgeOutRequests("test", os.time())

spec/System/TestTradeQueryRequests_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe("TradeQueryRequests", function()
1212
return key
1313
end
1414
}
15-
local requests = new("TradeQueryRequests", mock_limiter)
15+
local requests = new("TradeQueryRequests"):TradeQueryRequests(mock_limiter)
1616

1717
local function simulateRetry(requests, mock_limiter, policy, current_time)
1818
local now = current_time

spec/System/TestTradeQuery_spec.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("TradeQuery", function()
77
-- lives behind a callback we never trigger, or is already initialized
88
-- by the TradeQuery constructor.
99
local function newTradeQuery(state)
10-
local tq = new("TradeQuery", { itemsTab = {} })
10+
local tq = new("TradeQuery"):TradeQuery({ itemsTab = {} })
1111
tq.itemsTab.activeItemSet = {}
1212
tq.itemsTab.slots = {}
1313
tq.slotTables[1] = { slotName = "Ring 1" }
@@ -27,7 +27,7 @@ describe("TradeQuery", function()
2727
-- No sorted results at all -> first guard must short-circuit.
2828
local tq = newTradeQuery({})
2929
local dropdown = buildRow1Dropdown(tq)
30-
local tooltip = new("Tooltip")
30+
local tooltip = new("Tooltip"):Tooltip()
3131

3232
assert.has_no.errors(function()
3333
dropdown.tooltipFunc(tooltip, "DROP", 1, nil)
@@ -46,7 +46,7 @@ describe("TradeQuery", function()
4646
})
4747
local dropdown = buildRow1Dropdown(tq)
4848
tq.resultTbl[1] = {}
49-
local tooltip = new("Tooltip")
49+
local tooltip = new("Tooltip"):Tooltip()
5050

5151
assert.has_no.errors(function()
5252
dropdown.tooltipFunc(tooltip, "DROP", 1, nil)

src/Classes/BuildListControl.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function BuildListClass:BuildListControl(anchor, rect, listMode)
1717
{ },
1818
}
1919
self.showRowSeparators = true
20-
self.controls.path = new("PathControl", {"BOTTOM",self,"TOP"}, {0, -2, self.width, 24}, main.buildPath, listMode.subPath, function(subPath)
20+
self.controls.path = new("PathControl"):PathControl({"BOTTOM",self,"TOP"}, {0, -2, self.width, 24}, main.buildPath, listMode.subPath, function(subPath)
2121
listMode.subPath = subPath
2222
listMode:BuildList()
2323
self.selIndex = nil
@@ -44,7 +44,7 @@ function BuildListClass:BuildListControl(anchor, rect, listMode)
4444
end
4545
end
4646
self.dragTargetList = { self.controls.path, self }
47-
self.controls.path.width = function ()
47+
self.controls.path.width = function()
4848
return self.width()
4949
end
5050
end
@@ -77,8 +77,8 @@ end
7777

7878
function BuildListClass:RenameBuild(build, copyOnName)
7979
local controls = { }
80-
controls.label = new("LabelControl", nil, {0, 20, 0, 16}, "^7Enter the new name for this "..(build.folderName and "folder:" or "build:"))
81-
controls.edit = new("EditControl", nil, {0, 40, 350, 20}, build.folderName or build.buildName, nil, "\\/:%*%?\"<>|%c", 100, function(buf)
80+
controls.label = new("LabelControl"):LabelControl(nil, {0, 20, 0, 16}, "^7Enter the new name for this "..(build.folderName and "folder:" or "build:"))
81+
controls.edit = new("EditControl"):EditControl(nil, {0, 40, 350, 20}, build.folderName or build.buildName, nil, "\\/:%*%?\"<>|%c", 100, function(buf)
8282
controls.save.enabled = false
8383
if build.folderName then
8484
if buf:match("%S") then
@@ -100,7 +100,7 @@ function BuildListClass:RenameBuild(build, copyOnName)
100100
end
101101
end
102102
end)
103-
controls.save = new("ButtonControl", nil, {-45, 70, 80, 20}, "Save", function()
103+
controls.save = new("ButtonControl"):ButtonControl(nil, {-45, 70, 80, 20}, "Save", function()
104104
local newBuildName = controls.edit.buf
105105
if build.folderName then
106106
if copyOnName then
@@ -135,7 +135,7 @@ function BuildListClass:RenameBuild(build, copyOnName)
135135
self.listMode:SelectControl(self)
136136
end)
137137
controls.save.enabled = false
138-
controls.cancel = new("ButtonControl", nil, {45, 70, 80, 20}, "Cancel", function()
138+
controls.cancel = new("ButtonControl"):ButtonControl(nil, {45, 70, 80, 20}, "Cancel", function()
139139
main:ClosePopup()
140140
self.listMode:SelectControl(self)
141141
end)

src/Classes/CalcBreakdownControl.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ function CalcBreakdownClass:CalcBreakdownControl(calcsTab)
2121
self:ControlHost()
2222
self.calcsTab = calcsTab
2323
self.shown = false
24-
self.tooltip = new("Tooltip")
25-
self.nodeViewer = new("PassiveTreeView")
24+
self.tooltip = new("Tooltip"):Tooltip()
25+
self.nodeViewer = new("PassiveTreeView"):PassiveTreeView()
2626
self.rangeGuide = NewImageHandle()
2727
self.rangeGuide:Load("Assets/range_guide.png")
2828
self.uiOverlay = NewImageHandle()
2929
self.uiOverlay:Load("Assets/game_ui_small.png")
30-
self.controls.scrollBar = new("ScrollBarControl", {"RIGHT",self,"RIGHT"}, {-2, 0, 18, 0}, 80, "VERTICAL", true)
30+
self.controls.scrollBar = new("ScrollBarControl"):ScrollBarControl({"RIGHT",self,"RIGHT"}, {-2, 0, 18, 0}, 80, "VERTICAL", true)
3131
end
3232

3333
function CalcBreakdownClass:IsMouseOver()

0 commit comments

Comments
 (0)