Llamar como
addon:GetConditionUnitLevel(unit, cache)
Disponible directamente a través de addon; no se necesita ninguna dependencia.
Qué hace
Resuelve un nivel de unidad en bruto legible para evaluar condiciones. Una ausencia conocida devuelve false; las observaciones no disponibles devuelven nil con un motivo. Guarda en caché las observaciones dentro de la pasada de evaluación proporcionada. Solo los niveles de jugador válidos se conservan entre pasadas hasta una actualización de habilidad, perfil o nivel.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
self | RMAddon | Instancia del addon Rotation Master (implícita en las llamadas con dos puntos). |
unit | string | Token de unidad cuyo nivel en bruto se debe resolver. |
cache | table | nil | Caché de evaluación compartida; con nil se observa directamente sin caché por pasada. |
Retornos
| 1 | number | boolean | nil | Nivel entero positivo, false si se sabe que la unidad está ausente o nil si no está disponible. |
|---|---|---|
| 2 | string | nil | Motivo de disponibilidad o de validación de la consulta para un nivel nil. |
Ediciones
Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar usa una alternativa o devuelve nil con un motivo.
No lee directamente ninguna API del juego.
Valores secretos (Retail y Forever)
En Retail y Forever, el juego les entrega a los addons valores secretos. Esta función auxiliar verifica lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.
Cómo la llama el addon
Código fuente
Core/level_conditions.lua, línea 21. Solo lectura en el juego; Duplicar crea una copia editable.
Core.level_conditions.GetConditionUnitLevel(self, unit, cache)
if not self.Platform:CanReadValue(unit) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if self.Platform:GetClientFamily()=='unknown' then return nil,'unsupported-client' end
local longterm=self.longtermCache
if unit=='player' and type(longterm)=='table' then
local level=longterm.conditionPlayerLevel
if not self.Platform:CanReadValue(level) then return nil,'restricted-value' end
if level~=nil then
if type(level)~='number' or level~=level or level<=0 or level==math.huge or level%1~=0 then return nil,'invalid-api-result' end
return level
end
end
local record,reason=addon.Functions.cache.getCached(cache,self.Platform.GetUnitLevelObservation,self.Platform,unit)
if not record then return nil,reason end
if not record.exists then return false end
if unit=='player' and type(longterm)=='table' then longterm.conditionPlayerLevel=record.level end
return record.level