调用方式
addon:GetConditionPointResourceV2(unit, cache)
可直接通过 addon 使用,无需依赖项。
作用
使用原有的实时职业映射和身份缓存解析点数资源,并采用显式的 TBC 玩家 ComboPoints 后备传输策略。若玩家后备与模块加载时捕获的可读原始 Enum.PowerType 表和 ComboPoints 值相符,则选择 target-combo;显式的职业映射条目、其他角色和其他客户端系列保留 power。被替换、继承或无法证明来源的后备保留 power。此带版本的策略并不声称原生 UnitPower 有问题或与之等效。已知单位不存在时返回 false;所需观测不可用时返回 nil 及原因。此处不查询当前值或最大值。
参数
| 名称 | 类型 | 作用 |
|---|---|---|
self | RMAddon | Rotation Master 插件实例(使用冒号调用时隐含传入)。 |
unit | string | 确切的所选单位标识;只有字面上的 player 标识可以选择 TBC 连击点传输方式。 |
cache | table | nil | 评估轮次缓存;为 nil 时直接观测身份。成功的玩家职业观测可以使用现有的长期身份缓存;资源映射保持实时。 |
返回值
| 1 | number | boolean | nil | 显式的非负整数选择器;已知单位不存在时为 false,所需数据不可用时为 nil。 |
|---|---|---|
| 2 | string | nil | 选择器为 nil 时的策略、查询验证或身份/选择器可用性原因。 |
| 3 | string | nil | 仅限所选资源:target-combo 用于显式的 TBC 玩家后备,power 用于现有的所选单位传输方式。 |
版本
内置辅助函数在每个版本上都会注册。不同的是它们读取的游戏 API;某个 API 缺失时,辅助函数会改用后备方案,或返回 nil 并附上原因。
- 该版本不可用(原因见提示)
- 仅在暴雪的弃用兼容层开启时
| 游戏 API | |||||
|---|---|---|---|---|---|
Enum | |||||
canaccessvalue |
秘密值(正式服和永久服)
在正式服和永久服上,游戏交给插件的是秘密值。此辅助函数会检查它读取的内容(addon.Platform:CanReadValue),遇到无法比较的秘密值时返回 nil 并附上原因(例如 restricted-value),而不是返回该秘密值。请将 nil 视为不可用,而不是假。
插件如何调用它
- 点数 (evaluate)
local point,reason,transport=addon:GetConditionPointResourceV2(value.unit,cache)
依赖项
editionPointResource→Core.point_conditions.editionPointResourceplayerClassCacheKey(builtin:Core/point_conditions.lua:playerClassCacheKey)pointComboTypes(builtin:Core/point_conditions.lua:pointComboTypes)pointComboValue(builtin:Core/point_conditions.lua:pointComboValue)pointIdentity→Core.point_conditions.pointIdentity
源码
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




