Repository navigation
Expand file tree
/
Copy pathRunLabels.lua
More file actions
421 lines (373 loc) · 14.1 KB
/
Copy pathRunLabels.lua
File metadata and controls
421 lines (373 loc) · 14.1 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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
-- Exact run-label profiles. Labels are derived from current rules only.
local SC = Softcore
local DISALLOWED_OUTCOME = "WARNING"
local RUN_SUFFIX = " Run"
local ECONOMY_RULE_KEYS = { "auctionHouse", "mailbox", "trade", "bank", "warbandBank", "guildBank" }
local MOVEMENT_RULE_KEYS = { "mounts", "flying", "flightPaths" }
local BOOST_RULE_KEYS = { "heirlooms", "enchants", "consumables" }
local SEVERITY_RULE_KEYS = {
auctionHouse = true,
mailbox = true,
trade = true,
mounts = true,
flying = true,
flightPaths = true,
unsyncedMembers = true,
instanceWithUnsyncedPlayers = true,
maxLevelGap = true,
dungeonRepeat = true,
heirlooms = true,
enchants = true,
bank = true,
warbandBank = true,
guildBank = true,
consumables = true,
instancedPvP = true,
actionCam = true,
explorerMode = true,
}
local RUN_LABEL_RULE_KEYS = {
"groupingMode",
"unsyncedMembers",
"instanceWithUnsyncedPlayers",
"auctionHouse",
"mailbox",
"trade",
"bank",
"warbandBank",
"guildBank",
"mounts",
"flying",
"flightPaths",
"maxLevelGap",
"dungeonRepeat",
"gearQuality",
"selfCraftedGearAllowed",
"heirlooms",
"enchants",
"consumables",
"instancedPvP",
"actionCam",
"explorerMode",
}
local function CopyTable(source)
if type(source) ~= "table" then
return source
end
local copy = {}
for key, value in pairs(source) do
copy[key] = CopyTable(value)
end
return copy
end
local function ApplyGroupingRules(rules)
if SC.ApplyGroupingMode then
return SC:ApplyGroupingMode(rules)
end
return rules
end
local function GetBaseRuleset()
if SC.GetDefaultRuleset then
return SC:GetDefaultRuleset()
end
return {}
end
local function SetRules(rules, keys, value)
for _, key in ipairs(keys) do
rules[key] = value
end
end
local function SetUnsyncedPartyAllowed(rules, allowed)
rules.unsyncedMembers = allowed and "ALLOWED" or DISALLOWED_OUTCOME
rules.instanceWithUnsyncedPlayers = allowed and "ALLOWED" or DISALLOWED_OUTCOME
end
local function ApplyPresetProfile(rules, preset)
preset = SC.NormalizePresetKey and SC:NormalizePresetKey(preset) or preset
local bronzeman = preset == "BRONZEMAN" or preset == "BRONZE_VIGIL"
local bronzeVigil = preset == "BRONZE_VIGIL"
local chef = preset == "CHEF_SPECIAL"
local headChef = preset == "HEAD_CHEF_SPECIAL"
local chefFamily = chef or headChef
local selectedCameraMode = nil
rules.groupingMode = bronzeman and "SOLO_SELF_FOUND" or "SYNCED_GROUP_ALLOWED"
rules.gearQuality = (bronzeman or chefFamily) and "WHITE_GRAY_ONLY" or "ALLOWED"
if bronzeman then
rules.selfCraftedGearAllowed = false
elseif chefFamily then
rules.selfCraftedGearAllowed = true
else
rules.selfCraftedGearAllowed = false
end
rules.maxLevelGap = "ALLOWED"
rules.maxLevelGapValue = 3
rules.heirlooms = DISALLOWED_OUTCOME
rules.enchants = bronzeman and DISALLOWED_OUTCOME or "ALLOWED"
rules.dungeonRepeat = bronzeman and DISALLOWED_OUTCOME or "ALLOWED"
SetUnsyncedPartyAllowed(rules, preset == "CASUAL")
SetRules(rules, ECONOMY_RULE_KEYS, DISALLOWED_OUTCOME)
SetRules(rules, MOVEMENT_RULE_KEYS, bronzeman and DISALLOWED_OUTCOME or "ALLOWED")
if bronzeman then
rules.flightPaths = "ALLOWED"
end
if bronzeVigil then
rules.flightPaths = DISALLOWED_OUTCOME
end
rules.consumables = bronzeman and DISALLOWED_OUTCOME or "ALLOWED"
rules.instancedPvP = DISALLOWED_OUTCOME
rules.actionCam = "ALLOWED"
rules.explorerMode = "ALLOWED"
if chefFamily then
rules.auctionHouse = DISALLOWED_OUTCOME
rules.mailbox = DISALLOWED_OUTCOME
rules.trade = DISALLOWED_OUTCOME
rules.bank = "ALLOWED"
rules.warbandBank = DISALLOWED_OUTCOME
rules.guildBank = DISALLOWED_OUTCOME
rules.mounts = "ALLOWED"
rules.flying = DISALLOWED_OUTCOME
rules.flightPaths = "ALLOWED"
rules.heirlooms = DISALLOWED_OUTCOME
rules.enchants = "ALLOWED"
rules.consumables = "ALLOWED"
rules.dungeonRepeat = "ALLOWED"
rules.instancedPvP = DISALLOWED_OUTCOME
rules.actionCam = DISALLOWED_OUTCOME
selectedCameraMode = "CINEMATIC"
if headChef then
rules.explorerMode = DISALLOWED_OUTCOME
end
elseif not bronzeman then
SetRules(rules, ECONOMY_RULE_KEYS, "ALLOWED")
rules.heirlooms = "ALLOWED"
rules.selfCraftedGearAllowed = false
end
if bronzeVigil then
rules.actionCam = DISALLOWED_OUTCOME
rules.explorerMode = DISALLOWED_OUTCOME
selectedCameraMode = "CINEMATIC"
end
rules.maxDeaths = false
rules.maxDeathsValue = 3
rules.achievementPreset = preset
ApplyGroupingRules(rules)
return selectedCameraMode
end
function SC:ConfigureRulesetForPreset(rules, preset)
if type(rules) ~= "table" then
return nil
end
for key in pairs(rules) do
rules[key] = nil
end
for key, value in pairs(GetBaseRuleset()) do
rules[key] = CopyTable(value)
end
return ApplyPresetProfile(rules, preset)
end
local function BuildPresetRuleset(preset)
local rules = GetBaseRuleset()
ApplyPresetProfile(rules, preset)
return rules
end
local function BuildCasualVariant(overrides)
local rules = BuildPresetRuleset("CASUAL")
for key, value in pairs(overrides or {}) do
rules[key] = value
end
ApplyGroupingRules(rules)
rules.achievementPreset = nil
return rules
end
local function BuildAllRestrictionsRuleset()
local rules = BuildCasualVariant({
gearQuality = "WHITE_GRAY_ONLY",
selfCraftedGearAllowed = false,
maxLevelGap = DISALLOWED_OUTCOME,
dungeonRepeat = DISALLOWED_OUTCOME,
instanceWithUnsyncedPlayers = DISALLOWED_OUTCOME,
unsyncedMembers = DISALLOWED_OUTCOME,
instancedPvP = DISALLOWED_OUTCOME,
actionCam = DISALLOWED_OUTCOME,
explorerMode = DISALLOWED_OUTCOME,
})
SetRules(rules, ECONOMY_RULE_KEYS, DISALLOWED_OUTCOME)
SetRules(rules, MOVEMENT_RULE_KEYS, DISALLOWED_OUTCOME)
SetRules(rules, BOOST_RULE_KEYS, DISALLOWED_OUTCOME)
ApplyGroupingRules(rules)
return rules
end
local RUN_LABEL_SPECS = {
{ label = "Casual", preset = "CASUAL", rules = BuildPresetRuleset("CASUAL") },
{ label = "Chef's Special", preset = "CHEF_SPECIAL", rules = BuildPresetRuleset("CHEF_SPECIAL") },
{ label = "Head Chef's Special", preset = "HEAD_CHEF_SPECIAL", rules = BuildPresetRuleset("HEAD_CHEF_SPECIAL") },
{ label = "Bronzeman", preset = "BRONZEMAN", rules = BuildPresetRuleset("BRONZEMAN") },
{ label = "Bronze Vigil", preset = "BRONZE_VIGIL", rules = BuildPresetRuleset("BRONZE_VIGIL") },
{ label = "Party Animal", rules = BuildCasualVariant({ instancedPvP = "ALLOWED" }) },
{ label = "Mind the Gap", rules = BuildCasualVariant({ maxLevelGap = DISALLOWED_OUTCOME }) },
{ label = "Green Machine", rules = BuildCasualVariant({ gearQuality = "GREEN_OR_LOWER" }) },
{ label = "Blue Period", rules = BuildCasualVariant({ gearQuality = "BLUE_OR_LOWER" }) },
{ label = "White Knuckles", rules = BuildCasualVariant({ gearQuality = "WHITE_GRAY_ONLY", selfCraftedGearAllowed = false }) },
{ label = "Self-Forged", rules = BuildCasualVariant({ gearQuality = "WHITE_GRAY_ONLY", selfCraftedGearAllowed = true }) },
{ label = "No Heir Today", rules = BuildCasualVariant({ heirlooms = DISALLOWED_OUTCOME }) },
{ label = "No Enchant Intended", rules = BuildCasualVariant({ enchants = DISALLOWED_OUTCOME }) },
{ label = "Flaskless Gordon", rules = BuildCasualVariant({ consumables = DISALLOWED_OUTCOME }) },
{ label = "Dungeon Monogamist", rules = BuildCasualVariant({ dungeonRepeat = DISALLOWED_OUTCOME }) },
{ label = "Camera Shy", rules = BuildCasualVariant({ actionCam = DISALLOWED_OUTCOME }) },
{ label = "No Fly Zone", rules = BuildCasualVariant({ flying = DISALLOWED_OUTCOME }) },
{ label = "Flight Pathological", rules = BuildCasualVariant({ flightPaths = DISALLOWED_OUTCOME }) },
{ label = "Mount Rushless", rules = BuildCasualVariant({ mounts = DISALLOWED_OUTCOME }) },
{ label = "Walking Simulator", rules = BuildCasualVariant({ mounts = DISALLOWED_OUTCOME, flying = DISALLOWED_OUTCOME, flightPaths = DISALLOWED_OUTCOME }) },
{ label = "Auction House Arrest", rules = BuildCasualVariant({ auctionHouse = DISALLOWED_OUTCOME }) },
{ label = "Mailbox Hermit", rules = BuildCasualVariant({ mailbox = DISALLOWED_OUTCOME }) },
{ label = "Trade Chat Survivor", rules = BuildCasualVariant({ trade = DISALLOWED_OUTCOME }) },
{ label = "Bank Vault", rules = BuildCasualVariant({ bank = DISALLOWED_OUTCOME, warbandBank = DISALLOWED_OUTCOME, guildBank = DISALLOWED_OUTCOME }) },
{ label = "Warband Lockbox", rules = BuildCasualVariant({ warbandBank = DISALLOWED_OUTCOME }) },
{ label = "Guildless Wanderer", rules = BuildCasualVariant({ guildBank = DISALLOWED_OUTCOME }) },
{ label = "Market Goblin", rules = BuildCasualVariant({ gearQuality = "GREEN_OR_LOWER", selfCraftedGearAllowed = true }) },
{ label = "Solo Yolo", rules = BuildCasualVariant({ groupingMode = "SOLO_SELF_FOUND" }) },
{
label = "Alone Ranger",
rules = BuildCasualVariant({
groupingMode = "SOLO_SELF_FOUND",
auctionHouse = DISALLOWED_OUTCOME,
mailbox = DISALLOWED_OUTCOME,
trade = DISALLOWED_OUTCOME,
bank = DISALLOWED_OUTCOME,
warbandBank = DISALLOWED_OUTCOME,
guildBank = DISALLOWED_OUTCOME,
}),
},
{ label = "Oops All Restrictions", rules = BuildAllRestrictionsRuleset() },
}
local function NormalizeRulesetForRunLabel(ruleset)
if type(ruleset) ~= "table" then
return nil
end
local normalized = GetBaseRuleset()
for key, value in pairs(ruleset) do
normalized[key] = CopyTable(value)
end
ApplyGroupingRules(normalized)
return normalized
end
local function CanonicalSeverityValue(value)
if value == "ALLOWED" or value == "LOG_ONLY" then
return "ALLOWED"
end
if value == nil or value == false then
return "ALLOWED"
end
return "RESTRICTED"
end
local function CanonicalRunLabelValue(ruleset, key)
if key == "selfCraftedGearAllowed" then
if not ruleset or ruleset.gearQuality == nil or ruleset.gearQuality == "ALLOWED" then
return "IGNORED"
end
return ruleset.selfCraftedGearAllowed == true
end
if key == "maxLevelGapValue" then
if CanonicalSeverityValue(ruleset and ruleset.maxLevelGap) == "ALLOWED" then
return "IGNORED"
end
local value = tonumber(ruleset and ruleset.maxLevelGapValue)
return value or tostring(ruleset and ruleset.maxLevelGapValue)
end
if SEVERITY_RULE_KEYS[key] then
return CanonicalSeverityValue(ruleset and ruleset[key])
end
return ruleset and ruleset[key]
end
local function RulesetsMatch(a, b)
if not a or not b then
return false
end
for _, key in ipairs(RUN_LABEL_RULE_KEYS) do
if CanonicalRunLabelValue(a, key) ~= CanonicalRunLabelValue(b, key) then
return false
end
end
return true
end
local function FormatRunLabel(label)
label = tostring(label or "Custom")
if string.sub(label, -#RUN_SUFFIX) == RUN_SUFFIX then
return label
end
return label .. RUN_SUFFIX
end
local function FormatDebugValue(value)
if value == nil then
return "nil"
end
return tostring(value)
end
function SC:GetRunLabelDebugLines(ruleset)
local lines = {}
local label, preset = self:GetRunLabelForRuleset(ruleset)
table.insert(lines, "run label: " .. tostring(label or "Custom Run") .. " preset=" .. tostring(preset or "CUSTOM") .. " source=RunLabels.lua")
local normalized = NormalizeRulesetForRunLabel(ruleset)
if not normalized then
table.insert(lines, "no ruleset table available")
return lines
end
for index = 1, 5 do
local spec = RUN_LABEL_SPECS[index]
if spec then
local mismatches = {}
for _, key in ipairs(RUN_LABEL_RULE_KEYS) do
local actual = CanonicalRunLabelValue(normalized, key)
local expected = CanonicalRunLabelValue(spec.rules, key)
if actual ~= expected then
table.insert(mismatches, key .. "=" .. FormatDebugValue(actual) .. " expected " .. FormatDebugValue(expected))
end
end
if #mismatches == 0 then
table.insert(lines, FormatRunLabel(spec.label) .. ": match")
elseif not preset then
local preview = {}
for i = 1, math.min(#mismatches, 6) do
preview[i] = mismatches[i]
end
table.insert(lines, FormatRunLabel(spec.label) .. ": " .. tostring(#mismatches) .. " mismatch(es): " .. table.concat(preview, "; "))
end
end
end
return lines
end
function SC:GetRunLabelForRuleset(ruleset)
local normalized = NormalizeRulesetForRunLabel(ruleset)
if not normalized then
return nil
end
for _, spec in ipairs(RUN_LABEL_SPECS) do
if RulesetsMatch(normalized, spec.rules) then
return FormatRunLabel(spec.label), spec.preset
end
end
return nil
end
function SC:DetectRulesetPreset(ruleset)
local _, preset = self:GetRunLabelForRuleset(ruleset)
return preset
end
function SC:GetPresetRunLabel(preset)
preset = self.NormalizePresetKey and self:NormalizePresetKey(preset) or preset
for _, spec in ipairs(RUN_LABEL_SPECS) do
if spec.preset == preset then
return FormatRunLabel(spec.label)
end
end
return nil
end
function SC:GetRunDisplayName(run, fallback)
local ruleset = run and run.ruleset
local label = self:GetRunLabelForRuleset(ruleset)
if label then
return label
end
if type(ruleset) == "table" then
return "Custom Run"
end
return fallback or "Custom Run"
end