@@ -30,6 +30,7 @@ br.api.cast = function(self, spell, id)
3030 if cast .safe == nil then cast .safe = {} end
3131 if cast .time == nil then cast .time = {} end
3232 if cast .timeSinceLast == nil then cast .timeSinceLast = {} end
33+ local resolvedID = type (id ) == " table" and (br .functions .spell and br .functions .spell .getHighestKnownRank and br .functions .spell :getHighestKnownRank (id ) or id [1 ]) or id
3334
3435 --- Cast a spell based on various parameters.
3536 -- The function name is dynamically generated based on the spell name.
@@ -59,6 +60,7 @@ br.api.cast = function(self, spell, id)
5960 -- @tab enemies A table of enemy units that the spell should be cast on.
6061 -- @treturn boolean
6162 cast .id = function (spellID , thisUnit , castType , minUnits , effectRng , predict , predictPad , enemies )
63+ if type (spellID ) == " table" then spellID = (br .functions .spell and br .functions .spell .getHighestKnownRank and br .functions .spell :getHighestKnownRank (spellID )) or spellID [1 ] end
6264 return br .functions .cast :createCastFunction (thisUnit , castType , minUnits , effectRng , spellID , spell , predict , predictPad ,
6365 enemies )
6466 end
@@ -136,14 +138,14 @@ br.api.cast = function(self, spell, id)
136138 -- @treturn boolean
137139 cast .active [spell ] = function (thisUnit )
138140 if thisUnit == nil then thisUnit = " player" end
139- return br .functions .cast :isCastingSpell (id , thisUnit )
141+ return br .functions .cast :isCastingSpell (resolvedID , thisUnit )
140142 end
141143
142144 --- Checks if the spell is set to auto-repeat or if it's the current spell being cast.
143145 -- @function cast.auto.spell
144146 -- @treturn boolean
145147 cast .auto [spell ] = function ()
146- return br ._G .C_Spell .IsAutoRepeatSpell (br .api .wow .GetSpellInfo (id )) or br ._G .C_Spell .IsCurrentSpell (id )
148+ return br ._G .C_Spell .IsAutoRepeatSpell (br .api .wow .GetSpellInfo (resolvedID )) or br ._G .C_Spell .IsCurrentSpell (resolvedID )
147149 end
148150
149151 --- Cancels the current spell being cast if it matches the specified spell.
@@ -165,9 +167,9 @@ br.api.cast = function(self, spell, id)
165167 cast .cost [spell ] = function (altPower )
166168 if altPower == nil then altPower = false end
167169 if altPower then
168- return select (2 , br .functions .power :getSpellCost (id ))
170+ return select (2 , br .functions .power :getSpellCost (resolvedID ))
169171 else
170- return select (1 , br .functions .power :getSpellCost (id ))
172+ return select (1 , br .functions .power :getSpellCost (resolvedID ))
171173 end
172174 end
173175
@@ -177,7 +179,7 @@ br.api.cast = function(self, spell, id)
177179 -- @treturn boolean
178180 cast .current [spell ] = function (thisUnit )
179181 if thisUnit == nil then thisUnit = " player" end
180- return br .functions .cast :isCastingSpell (id , thisUnit )
182+ return br .functions .cast :isCastingSpell (resolvedID , thisUnit )
181183 end
182184
183185 --- Gets the spell id of the current (or previously) cast spell by the API.
@@ -193,14 +195,14 @@ br.api.cast = function(self, spell, id)
193195 -- @treturn boolean
194196 cast .dispel [spell ] = function (thisUnit )
195197 if thisUnit == nil then thisUnit = " target" end
196- return br .functions .aura :canDispel (thisUnit , id ) or false
198+ return br .functions .aura :canDispel (thisUnit , resolvedID ) or false
197199 end
198200
199201 --- Gets current empowered rank of the spell or 0 if not empowered.
200202 -- @function cast.empowered.spell
201203 -- @treturn number
202204 cast .empowered [spell ] = function ()
203- return br .functions .spell :getEmpoweredRank (id )
205+ return br .functions .spell :getEmpoweredRank (resolvedID )
204206 end
205207
206208 --- Casts the form corresponding to the provided formIndex number.
@@ -218,15 +220,15 @@ br.api.cast = function(self, spell, id)
218220 -- @treturn boolean
219221 cast .inFlight [spell ] = function (thisUnit )
220222 if thisUnit == nil then thisUnit = " target" end
221- return br .functions .InFlight :Check (id , thisUnit )
223+ return br .functions .InFlight :Check (resolvedID , thisUnit )
222224 end
223225
224226 --- Gets time remaining on a spell in flight to the target.
225227 -- @function cast.inFlightRemain.spell
226228 -- @string thisUnit The target unit to check for the spell in flight.
227229 -- @treturn number
228230 cast .inFlightRemain [spell ] = function (thisUnit )
229- return br .functions .InFlight :Remain (id , thisUnit )
231+ return br .functions .InFlight :Remain (resolvedID , thisUnit )
230232 end
231233
232234 --- Checks if the spell was the last one cast or not.
@@ -236,15 +238,15 @@ br.api.cast = function(self, spell, id)
236238 cast .last [spell ] = function (index )
237239 local tracker = br .functions .lastCast .lastCastTable .tracker
238240 index = index or 1
239- return tracker [index ] and tracker [index ] == id
241+ return tracker [index ] and tracker [index ] == resolvedID
240242 end
241243
242244 --- Gets the GetTime() value the last cast of this spell occurred.
243245 -- @function cast.last.time.spell
244246 -- @treturn number
245247 cast .last .time [spell ] = function ()
246- if br .functions .lastCast .lastCastTable .castTime [id ] == nil then br .functions .lastCast .lastCastTable .castTime [id ] = br ._G .GetTime () end
247- return br .functions .lastCast .lastCastTable .castTime [id ]
248+ if br .functions .lastCast .lastCastTable .castTime [resolvedID ] == nil then br .functions .lastCast .lastCastTable .castTime [resolvedID ] = br ._G .GetTime () end
249+ return br .functions .lastCast .lastCastTable .castTime [resolvedID ]
248250 end
249251
250252 --- Runs the macro text passed to it.
@@ -260,7 +262,7 @@ br.api.cast = function(self, spell, id)
260262 -- @function cast.noControl.spell
261263 -- @treturn boolean
262264 cast .noControl [spell ] = function ()
263- return br .functions .combat :hasNoControl (id )
265+ return br .functions .combat :hasNoControl (resolvedID )
264266 end
265267
266268 --- Casts special opener condition spell.
@@ -305,14 +307,14 @@ br.api.cast = function(self, spell, id)
305307 -- @function cast.range.spell
306308 -- @treturn number
307309 cast .range [spell ] = function ()
308- return br .functions .spell :getSpellRange (id )
310+ return br .functions .spell :getSpellRange (resolvedID )
309311 end
310312
311313 --- Gets the amount of power spell will generate when cast.
312314 -- @function cast.regen.spell
313315 -- @treturn number
314316 cast .regen [spell ] = function ()
315- return br .functions .spell :getCastingRegen (id )
317+ return br .functions .spell :getCastingRegen (resolvedID )
316318 end
317319
318320 --- Checks if safe to cast specified aoe spell on unit given the aoe dimensions.
@@ -323,14 +325,14 @@ br.api.cast = function(self, spell, id)
323325 -- @number effectRng Specify the AoE's effect range to determine units hit by it.
324326 -- @treturn boolean
325327 cast .safe [spell ] = function (thisUnit , aoeType , minUnits , effectRng )
326- return br .functions .range :isSafeToAoE (id , thisUnit , effectRng , minUnits , aoeType )
328+ return br .functions .range :isSafeToAoE (resolvedID , thisUnit , effectRng , minUnits , aoeType )
327329 end
328330
329331 --- Gets the cast time of player's spell. If the spell has no cast time, it returns the global cooldown.
330332 -- @function cast.time.spell
331333 -- @treturn number
332334 cast .time [spell ] = function ()
333- local castTime = br .functions .cast :getCastTime (id )
335+ local castTime = br .functions .cast :getCastTime (resolvedID )
334336 return castTime > 0 and castTime or br .functions .spell :getGlobalCD (true )
335337 end
336338
@@ -347,8 +349,8 @@ br.api.cast = function(self, spell, id)
347349 -- @function cast.timeSinceLast.spell
348350 -- @treturn number
349351 cast .timeSinceLast [spell ] = function ()
350- if br .functions .lastCast .lastCastTable .castTime [id ] == nil then br .functions .lastCast .lastCastTable .castTime [id ] = br ._G .GetTime () end
351- return br ._G .GetTime () - br .functions .lastCast .lastCastTable .castTime [id ]
352+ if br .functions .lastCast .lastCastTable .castTime [resolvedID ] == nil then br .functions .lastCast .lastCastTable .castTime [resolvedID ] = br ._G .GetTime () end
353+ return br ._G .GetTime () - br .functions .lastCast .lastCastTable .castTime [resolvedID ]
352354 end
353355
354356 --- Checks if the provided condition is true else it waits for 0.1sec.
0 commit comments