Skip to content

Commit 822262b

Browse files
mcagnionclaude
andcommitted
refactor(trade): rename influence filter cost to count
"Cost" was the only occurrence of the term in this file: the rest of the filter-budget path uses num_extra as the running count of structural filter slots consumed before weighted mods fill the remainder. Align with that convention: getInfluenceFilterCost becomes countInfluenceFilters and the intermediate influenceFilterCost variable is dropped in favour of a direct assignment to num_extra. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8f42814 commit 822262b

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

spec/System/TestTradeQueryGenerator_spec.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ describe("TradeQueryGenerator", function()
4444
local SHAPER = ANY + 1 -- 4
4545
local ELDER = ANY + 2 -- 5
4646
local resolve = mock_queryGen._resolveInfluenceQueryState
47-
local cost = mock_queryGen._getInfluenceFilterCost
47+
local count = mock_queryGen._countInfluenceFilters
4848
local needs = mock_queryGen._needsHasInfluenceFilter
4949

5050
-- None: uses pseudo_has_influence=0 (1 slot instead of 6-slot NOT filter)
5151
it("None uses 1-slot pseudo_has_influence=0", function()
5252
local state = resolve(NONE, IGNORE)
5353
assert.are.equal(state.exactCount, 0)
5454
assert.is_true(state.hasNoneConstraint)
55-
assert.are.equal(cost(state), 1)
55+
assert.are.equal(count(state), 1)
5656
assert.is_true(needs(state))
5757
end)
5858

@@ -62,7 +62,7 @@ describe("TradeQueryGenerator", function()
6262
assert.are.equal(state.exactCount, 1)
6363
assert.is_true(state.hasNoneConstraint)
6464
assert.are.equal(#state.specificInfluenceModIds, 1)
65-
assert.are.equal(cost(state), 2)
65+
assert.are.equal(count(state), 2)
6666
assert.is_true(needs(state))
6767
end)
6868

@@ -72,7 +72,7 @@ describe("TradeQueryGenerator", function()
7272
assert.are.equal(state.exactCount, 2)
7373
assert.is_false(state.hasNoneConstraint)
7474
assert.are.equal(#state.specificInfluenceModIds, 2)
75-
assert.are.equal(cost(state), 2)
75+
assert.are.equal(count(state), 2)
7676
assert.is_false(needs(state))
7777
end)
7878

@@ -81,7 +81,7 @@ describe("TradeQueryGenerator", function()
8181
local state = resolve(ANY, IGNORE)
8282
assert.are.equal(state.minCount, 1)
8383
assert.are.equal(state.exactCount, nil)
84-
assert.are.equal(cost(state), 1)
84+
assert.are.equal(count(state), 1)
8585
assert.is_true(needs(state))
8686
end)
8787

@@ -91,7 +91,7 @@ describe("TradeQueryGenerator", function()
9191
assert.are.equal(state.exactCount, 2)
9292
assert.is_false(state.hasNoneConstraint)
9393
assert.are.equal(#state.specificInfluenceModIds, 1)
94-
assert.are.equal(cost(state), 2)
94+
assert.are.equal(count(state), 2)
9595
assert.is_true(needs(state))
9696
end)
9797

@@ -112,7 +112,7 @@ describe("TradeQueryGenerator", function()
112112
assert.are.equal(dup.hasNoneConstraint, paired.hasNoneConstraint)
113113
assert.are.equal(#dup.specificInfluenceModIds, #paired.specificInfluenceModIds)
114114
assert.are.equal(dup.specificInfluenceModIds[1], paired.specificInfluenceModIds[1])
115-
assert.are.equal(cost(dup), cost(paired))
115+
assert.are.equal(count(dup), count(paired))
116116
assert.are.equal(needs(dup), needs(paired))
117117
end)
118118

src/Classes/TradeQueryGenerator.lua

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ local function needsHasInfluenceFilter(influenceState)
192192
return influenceState.minCount ~= nil
193193
end
194194

195-
local function getInfluenceFilterCost(influenceState)
195+
local function countInfluenceFilters(influenceState)
196196
local cost = #influenceState.specificInfluenceModIds
197197
if needsHasInfluenceFilter(influenceState) then
198198
cost = cost + 1
@@ -1082,9 +1082,7 @@ function TradeQueryGeneratorClass:FinishQuery()
10821082

10831083
local options = self.calcContext.options
10841084
local influenceState = resolveInfluenceQueryState(options.influence1, options.influence2)
1085-
local influenceFilterCost = getInfluenceFilterCost(influenceState)
1086-
1087-
local num_extra = influenceFilterCost
1085+
local num_extra = countInfluenceFilters(influenceState)
10881086
if not options.includeMirrored then
10891087
num_extra = num_extra + 1
10901088
end
@@ -1226,7 +1224,7 @@ end
12261224

12271225
-- Test accessors for influence query state logic (not used in production paths)
12281226
TradeQueryGeneratorClass._resolveInfluenceQueryState = resolveInfluenceQueryState
1229-
TradeQueryGeneratorClass._getInfluenceFilterCost = getInfluenceFilterCost
1227+
TradeQueryGeneratorClass._countInfluenceFilters = countInfluenceFilters
12301228
TradeQueryGeneratorClass._needsHasInfluenceFilter = needsHasInfluenceFilter
12311229
TradeQueryGeneratorClass._hasAnyInfluenceModId = hasAnyInfluenceModId
12321230
TradeQueryGeneratorClass._INFLUENCE_IGNORE_INDEX = INFLUENCE_IGNORE_INDEX

0 commit comments

Comments
 (0)