호출 방법
addon:GetConditionUnitLevel(unit, cache)
addon을 통해 바로 쓸 수 있으며, 의존성이 필요 없습니다.
하는 일
조건 평가를 위해 읽을 수 있는 원시 유닛 레벨을 확인합니다. 없는 것으로 알려지면 false를, 사용할 수 없는 관찰은 nil과 이유를 반환합니다. 전달된 평가 패스 안에서 관찰을 캐시합니다. 패스 간에는 기술, 프로필, 레벨이 새로 고쳐질 때까지 유효한 플레이어 레벨만 유지됩니다.
인수
| 이름 | 유형 | 하는 일 |
|---|---|---|
self | RMAddon | Rotation Master 애드온 인스턴스 (콜론 호출에서는 암묵적). |
unit | string | 원시 레벨을 확인할 유닛 토큰. |
cache | table | nil | 공유 평가 캐시. nil이면 패스별 캐시 없이 직접 관찰합니다. |
반환값
| 1 | number | boolean | nil | 양의 정수 레벨, 없는 것으로 알려진 유닛이면 false, 사용할 수 없으면 nil. |
|---|---|---|
| 2 | string | nil | nil인 레벨에 대한 사용 불가 또는 조회 검증 이유. |
버전
기본 제공 도우미는 모든 버전에 등록됩니다. 다른 점은 읽는 게임 API이며, API가 없으면 도우미는 대체 동작을 하거나 이유와 함께 nil을 반환합니다.
게임 API를 직접 읽지 않습니다.
비공개 값 (Retail과 Forever)
Retail과 Forever에서는 게임이 애드온에 비공개 값을 넘깁니다. 이 도우미는 읽는 값을 확인하고(addon.Platform:CanReadValue), 비교할 수 없는 비공개 값 대신 restricted-value 같은 이유와 함께 nil을 반환합니다. nil은 거짓이 아니라 사용할 수 없음으로 취급하세요.
애드온에서 호출하는 방식
소스
Core/level_conditions.lua, 21번째 줄. 게임에서는 읽기 전용이며, 복제하면 편집 가능한 사본이 생깁니다.
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