Skip to content

Commit a9057d5

Browse files
committed
Automatically Purchase Reshii Wraps talents (11.2.0 feature)
1 parent b931cdf commit a9057d5

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
@@ -8,6 +8,7 @@ local L = TTT.L;
88
local SKYRIDING_TREE_ID = Constants.MountDynamicFlightConsts and Constants.MountDynamicFlightConsts.TREE_ID or 672;
99
local HORRIFIC_VISIONS_TREE_ID = 1057;
1010
local OVERCHARGED_TITAN_CONSOLE_TREE_ID = 1061;
11+
local RESHII_WRAPS_TREE_ID = 1115;
1112

1213
local CHOICE_NODE_OPTION_1 = 1;
1314
local CHOICE_NODE_OPTION_2 = 2;
@@ -45,13 +46,19 @@ function Module:OnInitialize()
4546
configID == self.skyridingConfigID
4647
or configID == self.horrificVisionsConfigID
4748
or configID == self.overchargedTitanConsoleConfigID
49+
or configID == self.reshiiWrapsConfigID
4850
then
4951
self.disabledByRefund = true;
5052
end
5153
end);
5254
hooksecurefunc(C_Traits, 'SetSelection', function(configID, nodeID, entryID)
5355
if
54-
(configID == self.skyridingConfigID or configID == self.horrificVisionsConfigID or configID == self.overchargedTitanConsoleConfigID)
56+
(
57+
configID == self.skyridingConfigID
58+
or configID == self.horrificVisionsConfigID
59+
or configID == self.overchargedTitanConsoleConfigID
60+
or configID == self.reshiiWrapsConfigID
61+
)
5562
and entryID == nil
5663
then
5764
self.disabledByRefund = true;
@@ -98,6 +105,7 @@ function Module:GetOptions(defaultOptionsTable, db)
98105
surgeCache = {},
99106
horrificVisionsEnabled = true,
100107
overchargedTitanConsoleEnabled = true,
108+
reshiiWrapsEnabled = true,
101109
};
102110
for k, v in pairs(defaults) do
103111
if self.db[k] == nil then
@@ -109,6 +117,7 @@ function Module:GetOptions(defaultOptionsTable, db)
109117
[SKYRIDING_TREE_ID] = self.db.skyridingEnabled or nil,
110118
[HORRIFIC_VISIONS_TREE_ID] = self.db.horrificVisionsEnabled or nil,
111119
[OVERCHARGED_TITAN_CONSOLE_TREE_ID] = self.db.overchargedTitanConsoleEnabled or nil,
120+
[RESHII_WRAPS_TREE_ID] = self.db.reshiiWrapsEnabled or nil,
112121
};
113122
end
114123
setEnabledTreeIDs();
@@ -130,11 +139,13 @@ function Module:GetOptions(defaultOptionsTable, db)
130139
get = get,
131140
set = set,
132141
};
142+
local GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE = GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE or "Reshii Wraps (added in 11.2.0)"
133143

134144
function Module:BuildOptionsTable()
135145
local isSkyridingLoaded = not not self.skyridingConfigID;
136146
local isHorrificVisionsLoaded = not not self.horrificVisionsConfigID;
137147
local isOverchargedTitanConsoleLoaded = not not self.overchargedTitanConsoleConfigID;
148+
local isRishiiWrapsLoaded = not not self.reshiiWrapsConfigID;
138149

139150
defaultOptionsTable.args.skyRiding = {
140151
type = 'group',
@@ -278,6 +289,36 @@ function Module:GetOptions(defaultOptionsTable, db)
278289
},
279290
},
280291
};
292+
defaultOptionsTable.args.reshiiWraps = {
293+
type = 'group',
294+
inline = true,
295+
name = GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE,
296+
order = increment(),
297+
args = {
298+
loading = {
299+
type = 'description',
300+
name = L['Loading...'] .. '\n' .. L['You have not unlocked the %s system on this character yet.']:format(GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE),
301+
order = increment(),
302+
hidden = isRishiiWrapsLoaded,
303+
},
304+
reshiiWrapsEnabled = {
305+
type = 'toggle',
306+
name = L['Enable'],
307+
desc = L['Automatically purchase %s talents when you have enough currency.']:format(GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE),
308+
order = increment(),
309+
get = get,
310+
set = set,
311+
},
312+
openUI = {
313+
type = 'execute',
314+
name = L['Toggle %s UI']:format(GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE),
315+
desc = L['Toggle the %s UI to view and adjust talents.']:format(GENERIC_TRAIT_FRAME_RESHII_WRAPS_TITLE),
316+
order = increment(),
317+
func = function() self:ToggleTreeUI(RESHII_WRAPS_TREE_ID); end,
318+
disabled = not isRishiiWrapsLoaded,
319+
},
320+
},
321+
};
281322
end
282323
self:BuildOptionsTable();
283324

@@ -313,10 +354,12 @@ function Module:CheckConfig()
313354
self.skyridingConfigID = C_Traits.GetConfigIDByTreeID(SKYRIDING_TREE_ID);
314355
self.horrificVisionsConfigID = C_Traits.GetConfigIDByTreeID(HORRIFIC_VISIONS_TREE_ID);
315356
self.overchargedTitanConsoleConfigID = C_Traits.GetConfigIDByTreeID(OVERCHARGED_TITAN_CONSOLE_TREE_ID);
357+
self.reshiiWrapsConfigID = C_Traits.GetConfigIDByTreeID(RESHII_WRAPS_TREE_ID);
316358
if
317359
not self.skyridingConfigID
318360
and not self.horrificVisionsConfigID
319361
and not self.overchargedTitanConsoleConfigID
362+
and not self.reshiiWrapsConfigID
320363
then return; end
321364

322365
self:BuildOptionsTable();
@@ -329,6 +372,7 @@ function Module:CheckConfig()
329372
self.skyridingConfigID
330373
and self.horrificVisionsConfigID
331374
and self.overchargedTitanConsoleConfigID
375+
and self.reshiiWrapsConfigID
332376
then
333377
for _, event in pairs(self.checkConfigEvents) do
334378
self:UnregisterEvent(event);
@@ -385,6 +429,9 @@ function Module:PurchaseTalents()
385429
if self.db.overchargedTitanConsoleEnabled then
386430
self:PurchaseOverchargedTitanConsoleTalents();
387431
end
432+
if self.db.reshiiWrapsEnabled then
433+
self:PurchaseRishiiWrapsTalents();
434+
end
388435
end
389436

390437
function Module:PurchaseSkyridingTalents()
@@ -420,6 +467,15 @@ function Module:PurchaseOverchargedTitanConsoleTalents()
420467
self:DoPurchase(configID, treeID, ignoredNodeIDs);
421468
end
422469

470+
function Module:PurchaseRishiiWrapsTalents()
471+
if not self.reshiiWrapsConfigID then return; end
472+
473+
local ignoredNodeIDs = {};
474+
local configID = self.reshiiWrapsConfigID;
475+
local treeID = RESHII_WRAPS_TREE_ID;
476+
self:DoPurchase(configID, treeID, ignoredNodeIDs);
477+
end
478+
423479
function Module:DoPurchase(configID, treeID, ignoredNodeIDs)
424480
if self.purchasing or self.disabledByRefund then
425481
-- Already purchasing or disabled by refund

0 commit comments

Comments
 (0)