--[[ Addon: util Author: TProg Taonnor Created by @Taonnor ]]-- -- Version Control local VERSION = 1 --[[ Class definition (Static class) ]]-- -- A table in hole lua workspace must be unique -- The ui helper is global util table, used in several of my addons -- The table is created as "static" class without constructor and static helper methods if (TaosZOSMockingHelper == nil or TaosZOSMockingHelper.Version == nil or TaosZOSMockingHelper.Version < VERSION) then TaosZOSMockingHelper = {} TaosZOSMockingHelper.__index = TaosZOSMockingHelper TaosZOSMockingHelper.Version = VERSION local oldGetUnitName = nil local oldIsUnitDead = nil local oldIsUnitGrouped = nil local oldGetGroupSize = nil --[[ Mocks GetUnitName, returns always playerTag if not "player" ]]-- local function GetUnitNameMock(playerTag) if (playerTag == "player" and oldGetUnitName ~= nil) then return oldGetUnitName(playerTag) else return playerTag end end --[[ Mocks IsUnitDead, returns randomly unit death ]]-- local function IsUnitDeadMock(playerTag) return math.random() > 0.8 end --[[ Mocks IsUnitGrouped, returns always player in group ]]-- local function IsUnitGroupedMock(playerTag) return true end --[[ Mocks GetGroupSize, returns always player in group with 6 players ]]-- local function GetGroupSizeMock() return 6 end --[[ Mocks needed ZOS methods with mock methods ]]-- function MockZOSMethods() -- Mock GetUnitName oldGetUnitName = GetUnitName GetUnitName = GetUnitNameMock -- Mock IsUnitDead oldIsUnitDead = IsUnitDead IsUnitDead = IsUnitDeadMock -- Mock IsUnitGrouped oldIsUnitGrouped = IsUnitGrouped IsUnitGrouped = IsUnitGroupedMock -- Mock GetGroupSize oldGetGroupSize = GetGroupSize GetGroupSize = GetGroupSizeMock end end