參考資料 › 函式參考 › Core

Core.point_conditions.GetConditionPointResourceV2

公用

呼叫方式

addon:GetConditionPointResourceV2(unit, cache)

可直接透過 addon 使用,不需要相依項目。

作用

使用原有的即時職業對應與身分快取解析點數資源,並採用明確的 TBC 玩家 ComboPoints 備用傳輸政策。若玩家備用與模組載入時擷取的可讀原始 Enum.PowerType 表格與 ComboPoints 值相符,則選擇 target-combo;明確的職業對應項目、其他角色與其他用戶端系列保留 power。被取代、繼承或無法證明來源的備用保留 power。此帶版本的政策並不聲稱原生 UnitPower 有問題或與之等效。已知單位不存在時傳回 false;所需觀測無法使用時傳回 nil 及原因。此處不查詢目前值或最大值。

參數

名稱類型作用
selfRMAddonRotation Master 插件實例(使用冒號呼叫時隱含傳入)。
unitstring確切的所選單位代碼;只有字面上的 player 代碼可以選擇 TBC 連擊點傳輸方式。
cachetable | nil評估輪次快取;為 nil 時直接觀測身分。成功的玩家職業觀測可以使用現有的長期身分快取;資源對應保持即時。

傳回值

1number | boolean | nil明確的非負整數選擇器;已知單位不存在時為 false,所需資料無法使用時為 nil。
2string | nil選擇器為 nil 時的政策、查詢驗證或身分/選擇器可用性原因。
3string | nil僅限所選資源:target-combo 用於明確的 TBC 玩家備用,power 用於現有的所選單位傳輸方式。

版本

內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。

  • 該版本無法使用(原因請見提示)
  • 僅在暴雪的棄用相容層開啟時
遊戲 API經典時代TBC 週年版經典進程永久正式版
Enum經典時代TBC 週年版經典進程永久正式版
canaccessvalue經典時代TBC 週年版經典進程永久正式版

機密值(正式版與永久)

在正式版與永久上,遊戲交給插件的是機密值。此輔助函式會檢查它讀取的內容(addon.Platform:CanReadValue),遇到無法比較的機密值時,會傳回 nil 並附上原因(例如 restricted-value),而不是傳回該機密值。請將 nil 視為無法使用,而非假。

插件如何呼叫它

  • 點數 (evaluate)
    local point,reason,transport=addon:GetConditionPointResourceV2(value.unit,cache)

相依項目

原始碼

Core/point_conditions.lua,第 210 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。

Core.point_conditions.GetConditionPointResourceV2(self, unit, cache)
    local platform=self.Platform
    local info=platform:GetClientInfo()
    local policy=info.combatDataPolicy
    if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
    if not platform:CanReadValue(unit) then return nil,'restricted-value' end
    if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
    local record,reason=addon.Functions.cache.getCached(cache,pointIdentity,self,unit,playerClassCacheKey)
    if not record then return nil,reason end
    if not record.exists then return false end
    local family=info.family
    if policy=='probe' and (family=='era' or family=='progression') then return editionPointResource(platform,info,unit,record.class,cache) end
    local points=self.points
    if not platform:CanReadValue(points) then return nil,'restricted-value' end
    if type(points)~='table' then return nil,'invalid-point-resource-map' end
    local fallbackEnum,fallbackTypes
    local ok,selected=pcall(function() return points[record.class] end)
    if not ok then return nil,'api-error' end
    if not platform:CanReadValue(selected) then return nil,'restricted-value' end
    if selected==nil or selected==false then
        local enum=Enum
        if not platform:CanReadValue(enum) then return nil,'restricted-value' end
        if type(enum)~='table' then return nil,'point-resource-unavailable' end
        local typesOK,types=pcall(function() return enum.PowerType end)
        if not typesOK then return nil,'api-error' end
        if not platform:CanReadValue(types) then return nil,'restricted-value' end
        if type(types)~='table' then return nil,'point-resource-unavailable' end
        local fallbackOK,fallback=pcall(function() return types.ComboPoints end)
        if not fallbackOK then return nil,'api-error' end
        selected=fallback
        if not platform:CanReadValue(selected) then return nil,'restricted-value' end
        fallbackEnum,fallbackTypes=enum,types
    end
    if selected==nil then return nil,'point-resource-unavailable' end
    if type(selected)~='number' or selected~=selected or selected<0 or selected==math.huge or selected%1~=0 then return nil,'invalid-point-resource' end
    if policy=='restricted' and not platform:IsNeverSecretPointPower(selected) then return nil,'unsupported-policy' end
    local transport='power'
    if unit=='player' and fallbackTypes then
        local rawTypes,rawCombo=rawget(fallbackEnum,'PowerType'),rawget(fallbackTypes,'ComboPoints')
        if platform:CanReadValue(pointComboTypes) and (not canaccessvalue or canaccessvalue(pointComboTypes))
            and platform:CanReadValue(rawTypes) and (not canaccessvalue or canaccessvalue(rawTypes))
            and rawequal(fallbackTypes,pointComboTypes) and rawequal(rawTypes,fallbackTypes)
            and platform:CanReadValue(rawCombo) and (not canaccessvalue or canaccessvalue(rawCombo)) and rawCombo==selected
            and platform:CanReadValue(pointComboValue) and (not canaccessvalue or canaccessvalue(pointComboValue))
            and pointComboValue==selected then
            local family
            if platform:CanReadValue(info) and type(info)=='table' then family=rawget(info,'family') end
            if platform:CanReadValue(family) and (not canaccessvalue or canaccessvalue(family)) and family=='tbc' then transport='target-combo' end
        end
    end
    return selected,nil,transport

返回函式參考