-
Notifications
You must be signed in to change notification settings - Fork 403
Expand file tree
/
Copy pathTestImportTab_spec.lua
More file actions
238 lines (211 loc) · 8.39 KB
/
Copy pathTestImportTab_spec.lua
File metadata and controls
238 lines (211 loc) · 8.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
describe("ImportTab", function()
before_each(function()
newBuild()
end)
it("builds character lists for private Ruthless league names without a Ruthless tree", function()
local importTab = build.importTab
importTab.lastCharList = {
{
name = "PrivateLeagueCharacter",
class = "Amazon",
level = 90,
league = "My Private Ruthless League",
},
}
local ok, err = pcall(function()
importTab:BuildCharacterList(nil)
end)
assert.True(ok, err)
assert.are.equals(1, #importTab.controls.charSelect.list)
assert.are.equals("PrivateLeagueCharacter", importTab.controls.charSelect.list[1].label)
assert.True(importTab.controls.charSelect.list[1].detail:match("Amazon") ~= nil)
end)
it("falls back to the default class color for unknown character classes", function()
local importTab = build.importTab
importTab.lastCharList = {
{
name = "UnknownClassCharacter",
class = "Future Ascendancy",
level = 1,
league = "My Private Ruthless League",
},
}
local ok, err = pcall(function()
importTab:BuildCharacterList(nil)
end)
assert.True(ok, err)
assert.are.equals(1, #importTab.controls.charSelect.list)
assert.True(importTab.controls.charSelect.list[1].detail:match("Future Ascendancy") ~= nil)
end)
it("imports Split Personality alternate class start from character JSON", function()
local spec = build.spec
local socketNode = spec.nodes[60735]
local templarStartPassive = spec.nodes[13855]
assert.is_not_nil(socketNode)
assert.is_not_nil(templarStartPassive)
assert.is_nil(spec.tree.classNameMap.Templar)
assert.are.equals(61525, spec.tree.classStartNodeNameMap.Templar)
local hashes = { socketNode.id, templarStartPassive.id }
for _, pathNode in ipairs(socketNode.path or { }) do
table.insert(hashes, pathNode.id)
end
build.importTab:ImportPassiveTreeAndJewels({
name = "Split Import Test",
class = "Witch2",
league = "Test",
level = 90,
jewels = {
{
id = "split-personality-test",
frameType = 3,
name = "Split Personality",
typeLine = "Ruby",
inventoryId = "PassiveJewels",
x = 4,
ilvl = 84,
properties = { },
explicitMods = {
"Can Allocate Passive Skills from the Templar's starting point",
},
},
},
passives = {
hashes = hashes,
specialisations = { },
skill_overrides = { },
jewel_data = { },
quest_stats = { },
},
})
local importedSpec = build.spec
local importedJewel = build.itemsTab.items[importedSpec.jewels[socketNode.id]]
assert.are.equals("Templar", importedJewel.jewelData.alternateClassStart)
assert.are.equals(0, importedSpec.nodes[spec.tree.classStartNodeNameMap.Templar].pathDist)
assert.True(importedSpec.nodes[templarStartPassive.id].alloc)
assert.True(importedSpec.nodes[templarStartPassive.id].connectedToStart)
end)
end)
describe("ImportTab quest reward import", function()
before_each(function()
newBuild()
end)
local function findQuest(info)
for _, quest in ipairs(data.questRewards) do
if quest.Info == info then
return "quest" .. quest.Description .. quest.Area .. quest.Info, quest
end
end
error("quest reward not found for Info: " .. info)
end
local function importStats(questStats)
build.importTab:ImportQuestRewardConfig(questStats)
return build.configTab.input
end
it("decomposes 0.5 rolled-up totals across the contributing quests", function()
local input = importStats({
"+20 to maximum Life",
"+60 to [Spirit|Spirit]",
"+15% to [Resistances|Cold Resistance]",
"+15% to [Resistances|Fire Resistance]",
"+15% to [Resistances|Lightning Resistance]",
})
assert.is_true(input[(findQuest("Candlemass"))])
assert.is_true(input[(findQuest("King In The Mists"))])
assert.is_true(input[(findQuest("Ignagduk"))])
assert.is_true(input[(findQuest("Beira"))])
assert.is_true(input[(findQuest("Blackjaw"))])
assert.is_true(input[(findQuest("Sisters of Garukhan Shrine"))])
local tasalioVar, tasalio = findQuest("Tasalio's Test")
assert.are.equals(tasalio.Options[2], input[tasalioVar])
local ngamahuVar, ngamahu = findQuest("Ngamahu's Test")
assert.are.equals(ngamahu.Options[2], input[ngamahuVar])
local tawhoaVar, tawhoa = findQuest("Tawhoa's Test")
assert.are.equals(tawhoa.Options[2], input[tawhoaVar])
assert.is_false(input[(findQuest("Lythara"))])
end)
it("sums duplicate 0.4 per-line Spirit rewards the same as the 0.5 summed total", function()
local input = importStats({
"+30 to [Spirit|Spirit]",
"+30 to [Spirit|Spirit]",
"+40 to [Spirit|Spirit]",
})
assert.is_true(input[(findQuest("King In The Mists"))])
assert.is_true(input[(findQuest("Ignagduk"))])
assert.is_true(input[(findQuest("Lythara"))])
end)
it("ticks exactly one of the interchangeable +30 Spirit quests when only one is claimed", function()
local input = importStats({ "+30 to [Spirit|Spirit]" })
local king = input[(findQuest("King In The Mists"))]
local ignagduk = input[(findQuest("Ignagduk"))]
assert.is_false(input[(findQuest("Lythara"))])
assert.are.equals(1, (king and 1 or 0) + (ignagduk and 1 or 0))
end)
it("disambiguates Spirit total 70 to one +30 plus Lythara, not 30+30", function()
local input = importStats({ "+70 to [Spirit|Spirit]" })
assert.is_true(input[(findQuest("Lythara"))])
local king = input[(findQuest("King In The Mists"))]
local ignagduk = input[(findQuest("Ignagduk"))]
assert.are.equals(1, (king and 1 or 0) + (ignagduk and 1 or 0))
end)
it("disambiguates Spirit total 40 to Lythara alone, not a +30", function()
local input = importStats({ "+40 to [Spirit|Spirit]" })
assert.is_true(input[(findQuest("Lythara"))])
assert.is_false(input[(findQuest("King In The Mists"))])
assert.is_false(input[(findQuest("Ignagduk"))])
end)
it("selects the correct multi-line option and leaves unclaimed option quests at None", function()
local medallionVar, medallion = findQuest("Medallion")
local input = importStats({
"30% increased [Charm] Effect Duration",
"+1 [Charm] Slot",
})
assert.are.equals(medallion.Options[2], input[medallionVar])
assert.are.equals("None", input[(findQuest("Seven Pillars"))])
assert.is_false(input[(findQuest("Beira"))])
end)
it("credits Tribal Medicine's Kaom option, not Seven Pillars which shares the stat at 15%", function()
local tribalVar, tribal = findQuest("Tribal Medicine")
local input = importStats({ "30% increased Global [Armour], [Evasion] and [EnergyShield|Energy Shield]" })
assert.are.equals(tribal.Options[1], input[tribalVar])
assert.are.equals("None", input[(findQuest("Seven Pillars"))])
end)
it("selects Tribal Medicine's Rakiata multi-stat option", function()
local tribalVar, tribal = findQuest("Tribal Medicine")
local input = importStats({
"+15% of [Armour|Armour] also applies to [ElementalDamage|Elemental Damage]",
"Gain [Deflect|Deflection Rating] equal to 12% of [Evasion|Evasion Rating]",
"12% [FasterESRechargeStart|faster start of Energy Shield Recharge]",
})
assert.are.equals(tribal.Options[2], input[tribalVar])
end)
it("decomposes Global Armour, Evasion and Energy Shield shared by Tribal Medicine (30%) and Seven Pillars (15%)", function()
local tribalVar, tribal = findQuest("Tribal Medicine")
local sevenVar, seven = findQuest("Seven Pillars")
local input = importStats({ "45% increased Global [Armour], [Evasion] and [EnergyShield|Energy Shield]" })
assert.are.equals(tribal.Options[1], input[tribalVar])
assert.are.equals(seven.Options[3], input[sevenVar])
end)
it("imports Boss's Faces Broken without affecting quest reward matching", function()
local sevenVar, seven = findQuest("Seven Pillars")
local input = importStats({
"+20 to maximum Life",
"5% increased maximum Life",
"5% increased maximum Mana",
"+100 to [Spirit|Spirit]",
"30% increased [Charm] Effect Duration",
"+5% to [Resistances|Fire Resistance]",
"+15% to [Resistances|Cold Resistance]",
"+15% to [Resistances|Lightning Resistance]",
"30% increased Life Recovery from [Flask|Flasks]",
"45% increased Global [Armour], [Evasion] and [EnergyShield|Energy Shield]",
"25% increased [StunThreshold|Stun Threshold]",
"+1 [Charm] Slot",
"58 [BrokenFace|Broken Boss Faces]",
})
assert.is_nil(input.configBossFaceBroken)
assert.are.equals(58, build.configTab.placeholder.configBossFaceBroken)
assert.are.equals(seven.Options[3], input[sevenVar])
runCallback("OnFrame")
assert.is_false(build.configTab.varControls.configBossFaceBroken.shown())
end)
end)