Référence › Référence des fonctions › Platform

Platform.actions.GetSpellRangeState

publique

Appel

addon.Platform:GetSpellRangeState(id, unit, bank)

Disponible directement via addon ; aucune dépendance n'est nécessaire.

Ce qu'elle fait

Lit la portée propre à un sort pour une unité à l'aide de l'API client appropriée ou de l'emplacement du grimoire. Un sort sans restriction de portée renvoie applicable=false ; sinon applicable=true et inRange indique si l'unité est à portée. Les observations inconnues ou inaccessibles renvoient nil avec un motif.

Arguments

NomTypeCe qu'elle fait
selfRMPlatformAdaptateur de plateforme Rotation Master. Une référence par point exige addon.Platform comme premier argument ; un appel par deux-points le fournit implicitement.
idnumberID du sort dont la portée doit être vérifiée.
unitstring | nilIdentifiant d'unité, comme target ; nil utilise target.
bankstringPortée du grimoire : spell, pet ou any.

Retours

1table | nilEnregistrement de portée avec applicable et, le cas échéant, inRange ; nil si indisponible.
2string | nilMotif de disponibilité ou de validation lorsque l'enregistrement est nil.

Éditions

Les fonctions utilitaires intégrées sont enregistrées sur toutes les éditions. Ce qui diffère, c'est l'API du jeu qu'elles lisent ; quand l'une manque, la fonction utilitaire se rabat sur une alternative ou renvoie nil avec une raison.

  • Indisponible sur cette édition (la raison figure dans l'infobulle)
  • Uniquement tant que les solutions de repli de Blizzard pour les fonctions obsolètes sont actives
API du jeuClassic EraTBC AnniversaryClassic ProgressionForeverRetail
C_Spell.IsSpellInRangeClassic EraTBC AnniversaryClassic ProgressionForeverRetail
C_Spell.SpellHasRangeClassic EraTBC AnniversaryClassic ProgressionForeverRetail
IsSpellInRangeClassic EraTBC AnniversaryClassic ProgressionForeverRetail
SpellHasRangeClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Valeurs secrètes (Retail et Forever)

Sur Retail et Forever, le jeu transmet aux addons des valeurs secrètes. Cette fonction utilitaire vérifie ce qu'elle lit (addon.Platform:CanReadValue) et renvoie nil avec une raison telle que restricted-value au lieu d'une valeur secrète qu'elle ne peut pas comparer. Traitez nil comme indisponible, pas comme false.

Exemple

local record = addon.Platform:GetSpellRangeState(value.spell, "target", "any")
if not record then return nil end
-- A spell with no range restriction can always reach the target.
return not record.applicable or record.inRange

Dépendances

Source

Platform/actions.lua, ligne 120. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.

Platform.actions.GetSpellRangeState(self, id, unit, bank)
    local valid,reason=spellID(id)
    if not valid then return nil,reason end
    if not self:CanReadValue(unit) or not self:CanReadValue(bank) then return nil,"restricted-value" end
    if unit~=nil and (type(unit)~="string" or unit=="") then return nil,"invalid-unit" end
    if bank~="spell" and bank~="pet" and bank~="any" then return nil,"invalid-spell-bank" end
    unit=unit or "target"
    local nativeRange=C_Spell and C_Spell.IsSpellInRange
    local nativeShape=C_Spell and C_Spell.SpellHasRange
    local slot,book,slotReason
    local hasRange,why,queriedShape
    if type(nativeShape)=="function" then
        queriedShape=true
        hasRange,why=call(nativeShape,id)
    elseif type(nativeRange)~="function" and type(SpellHasRange)=="function" then
        if not slot then slot,book,slotReason=findSlot(id,bank) end
        if not slot then return nil,slotReason end
        queriedShape=true
        hasRange,why=call(SpellHasRange,slot,book)
    end
    if why then return nil,why end
    if hasRange~=nil then
        if type(hasRange)~="boolean" then return nil,"invalid-api-result" end
        if not hasRange then return rangeNotApplicable end
    elseif queriedShape then return nil,"invalid-api-result" end
    local inRange
    if type(nativeRange)=="function" then
        inRange,why=call(nativeRange,id,unit)
        if why then return nil,why end
        if inRange~=nil and type(inRange)~="boolean" then return nil,"invalid-api-result" end
    else
        if type(IsSpellInRange)~="function" then return nil,"missing-api" end
        if not slot then slot,book,slotReason=findSlot(id,bank) end
        if not slot then return nil,slotReason end
        inRange,why=call(IsSpellInRange,slot,book,unit)
        if why then return nil,why end
        if inRange==0 then inRange=false elseif inRange==1 then inRange=true end
        if inRange~=nil and type(inRange)~="boolean" then return nil,"invalid-api-result" end
    end
    if inRange==nil then return nil,"invalid-range-check" end
    return inRange and rangeIn or rangeOut

Retour à Référence des fonctions