Skip to content

Commit 0f94ff1

Browse files
committed
Automatically purchase the final artifact talent in Legion Remix
1 parent f05c82a commit 0f94ff1

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

modules/autoPurchaseGenericTalents.lua

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ local SKYRIDING_TREE_ID = Constants.MountDynamicFlightConsts and Constants.Mount
1111
local HORRIFIC_VISIONS_TREE_ID = 1057;
1212
local OVERCHARGED_TITAN_CONSOLE_TREE_ID = 1061;
1313
local RESHII_WRAPS_TREE_ID = 1115;
14+
local LEMIX_TREE_ID = 1161;
1415

1516
local RESHII_QUEST_ID = 89561;
1617

@@ -29,6 +30,9 @@ local SURGE_ENTRY_IDS = {
2930
[CHOICE_NODE_OPTION_1] = 123787,
3031
[CHOICE_NODE_OPTION_2] = 123786,
3132
};
33+
local LIMITS_UNBOUND_NODE_ID = 108700;
34+
35+
local IS_LEMIX = PlayerGetTimerunningSeasonID() == 2;
3236

3337
local GetSpellLink = C_Spell.GetSpellLink;
3438

@@ -54,6 +58,7 @@ function Module:OnInitialize()
5458
or configID == self.horrificVisionsConfigID
5559
or configID == self.overchargedTitanConsoleConfigID
5660
or configID == self.reshiiWrapsConfigID
61+
or configID == self.lemixConfigID
5762
then
5863
self.disabledByRefund = true;
5964
end
@@ -65,6 +70,7 @@ function Module:OnInitialize()
6570
or configID == self.horrificVisionsConfigID
6671
or configID == self.overchargedTitanConsoleConfigID
6772
or configID == self.reshiiWrapsConfigID
73+
or configID == self.lemixConfigID
6874
)
6975
and entryID == nil
7076
then
@@ -131,6 +137,7 @@ function Module:GetOptions(defaultOptionsTable, db)
131137
horrificVisionsEnabled = true,
132138
overchargedTitanConsoleEnabled = true,
133139
reshiiWrapsEnabled = true,
140+
lemixLimitsUnboundEnabled = true,
134141
};
135142
for k, v in pairs(defaults) do
136143
if self.db[k] == nil then
@@ -143,6 +150,7 @@ function Module:GetOptions(defaultOptionsTable, db)
143150
[HORRIFIC_VISIONS_TREE_ID] = self.db.horrificVisionsEnabled or nil,
144151
[OVERCHARGED_TITAN_CONSOLE_TREE_ID] = self.db.overchargedTitanConsoleEnabled or nil,
145152
[RESHII_WRAPS_TREE_ID] = self.db.reshiiWrapsEnabled or nil,
153+
[LEMIX_TREE_ID] = IS_LEMIX and self.db.lemixLimitsUnboundEnabled or nil,
146154
};
147155
end
148156
setEnabledTreeIDs();
@@ -171,6 +179,7 @@ function Module:GetOptions(defaultOptionsTable, db)
171179
local isHorrificVisionsLoaded = not not self.horrificVisionsConfigID;
172180
local isOverchargedTitanConsoleLoaded = not not self.overchargedTitanConsoleConfigID;
173181
local isRishiiWrapsLoaded = not not self.reshiiWrapsConfigID;
182+
local isLemixLoaded = not not self.lemixConfigID;
174183

175184
defaultOptionsTable.args.skyRiding = {
176185
type = 'group',
@@ -254,6 +263,29 @@ function Module:GetOptions(defaultOptionsTable, db)
254263
},
255264
},
256265
};
266+
defaultOptionsTable.args.lemix = {
267+
type = 'group',
268+
inline = true,
269+
name = L['Legion Remix: Limits Unbound'],
270+
order = increment(),
271+
hidden = not IS_LEMIX,
272+
args = {
273+
loading = {
274+
type = 'description',
275+
name = L['Loading...'] .. '\n' .. L['You have not unlocked Legion Remix artifact traits yet.'],
276+
order = increment(),
277+
hidden = isLemixLoaded,
278+
},
279+
lemixLimitsUnboundEnabled = {
280+
type = 'toggle',
281+
name = L['Enable'],
282+
desc = L['Automatically upgrade the final Limits Unbound talent when you have enough currency.'],
283+
order = increment(),
284+
get = get,
285+
set = set,
286+
},
287+
},
288+
};
257289
defaultOptionsTable.args.reshiiWraps = {
258290
type = 'group',
259291
inline = true,
@@ -380,11 +412,13 @@ function Module:CheckConfig()
380412
self.horrificVisionsConfigID = C_Traits.GetConfigIDByTreeID(HORRIFIC_VISIONS_TREE_ID);
381413
self.overchargedTitanConsoleConfigID = C_Traits.GetConfigIDByTreeID(OVERCHARGED_TITAN_CONSOLE_TREE_ID);
382414
self.reshiiWrapsConfigID = C_Traits.GetConfigIDByTreeID(RESHII_WRAPS_TREE_ID);
415+
self.lemixConfigID = C_Traits.GetConfigIDByTreeID(LEMIX_TREE_ID);
383416
if
384417
not self.skyridingConfigID
385418
and not self.horrificVisionsConfigID
386419
and not self.overchargedTitanConsoleConfigID
387420
and not self.reshiiWrapsConfigID
421+
and not self.lemixConfigID
388422
then return; end
389423

390424
self:BuildOptionsTable();
@@ -398,6 +432,7 @@ function Module:CheckConfig()
398432
and self.horrificVisionsConfigID
399433
and self.overchargedTitanConsoleConfigID
400434
and self.reshiiWrapsConfigID
435+
and self.lemixConfigID
401436
then
402437
for _, event in pairs(self.checkConfigEvents) do
403438
self:UnregisterEvent(event);
@@ -458,6 +493,9 @@ function Module:PurchaseTalents()
458493
if self.db.reshiiWrapsEnabled then
459494
self:PurchaseRishiiWrapsTalents();
460495
end
496+
if self.db.lemixLimitsUnboundEnabled then
497+
self:PurchaseLemixLimitsUnboundTalent();
498+
end
461499
end
462500

463501
function Module:PurchaseSkyridingTalents()
@@ -506,6 +544,16 @@ function Module:PurchaseRishiiWrapsTalents()
506544
self:DoPurchase(configID, treeID, ignoredNodeIDs, 1);
507545
end
508546

547+
function Module:PurchaseLemixLimitsUnboundTalent()
548+
if not self.lemixConfigID or not IS_LEMIX then return; end
549+
550+
local ignoredNodeIDs = { [LIMITS_UNBOUND_NODE_ID] = false };
551+
setmetatable(ignoredNodeIDs, { __index = function() return true; end }); -- ignore all other nodes
552+
local configID = self.lemixConfigID;
553+
local treeID = LEMIX_TREE_ID;
554+
self:DoPurchase(configID, treeID, ignoredNodeIDs);
555+
end
556+
509557
--- @param configID number
510558
--- @param treeID number
511559
--- @param ignoredNodeIDs table<number, boolean> # [nodeID] = true to ignore
@@ -624,10 +672,18 @@ function Module:ReportPurchases(configID, entryIDs)
624672
return;
625673
end
626674
local spellLinks = {};
675+
local entryIDCount = {};
676+
for _, entryID in pairs(entryIDs) do
677+
entryIDCount[entryID] = (entryIDCount[entryID] or 0) + 1;
678+
end
627679
for _, entryID in ipairs(entryIDs) do
628680
local spellLink = self:GetSpellLinkFromEntryID(configID, entryID);
629-
if spellLink then
681+
if spellLink and entryIDCount[entryID] then
682+
if entryIDCount[entryID] > 1 then
683+
spellLink = spellLink .. ' x' .. entryIDCount[entryID];
684+
end
630685
table.insert(spellLinks, spellLink);
686+
entryIDCount[entryID] = nil; -- only add once
631687
end
632688
end
633689
self:Print(

0 commit comments

Comments
 (0)