mirror of
https://github.com/parnic/LibDogTag-Unit-3.0.git
synced 2025-06-16 21:41:53 -05:00
- add support for MobHealth2, 3, and 4 for health-related tags
- Add PercentHP, MissingHP, FractionalHP, IsMaxHP, HPColor tags. - for most HP tags, you can specify the optional kwarg "known", e.g. HP(unit='target', known=true), to only show known HP values, i.e. if they are in your party or if MobHealth can estimate its health. This eliminates the need for the SureHP tag as in LibDogTag-2.0
This commit is contained in:
32
test.lua
32
test.lua
@ -14,11 +14,21 @@ local units = {
|
||||
maxhp = 2000,
|
||||
exists = true,
|
||||
},
|
||||
pet = {
|
||||
hp = 0,
|
||||
maxhp = 1000,
|
||||
exists = true,
|
||||
},
|
||||
target = {
|
||||
hp = 2500,
|
||||
maxhp = 2500,
|
||||
exists = true,
|
||||
},
|
||||
pettarget = {
|
||||
hp = 50,
|
||||
maxhp = 100,
|
||||
exists = true,
|
||||
},
|
||||
focus = {
|
||||
exists = false,
|
||||
}
|
||||
@ -94,6 +104,13 @@ assert_equal(DogTag:Evaluate("[HP(unit='player')]", "Unit"), 1500)
|
||||
assert_equal(DogTag:Evaluate("[HP]", "Unit", { unit = 'player'}), 1500)
|
||||
assert_equal(DogTag:Evaluate("[MaxHP('player')]", "Unit"), 2000)
|
||||
assert_equal(DogTag:Evaluate("[MaxHP(unit='player')]", "Unit"), 2000)
|
||||
assert_equal(DogTag:Evaluate("[PercentHP(unit='player')]", "Unit"), 75)
|
||||
assert_equal(DogTag:Evaluate("[MissingHP(unit='player')]", "Unit"), 500)
|
||||
assert_equal(DogTag:Evaluate("[FractionalHP(unit='player')]", "Unit"), "1500/2000")
|
||||
assert_equal(DogTag:Evaluate("[HP(unit='pettarget', known=true)]", "Unit"), nil)
|
||||
assert_equal(DogTag:Evaluate("[MissingHP(unit='pettarget', known=true)]", "Unit"), nil)
|
||||
print(DogTag:CreateFunctionFromCode("[FractionalHP(unit='pettarget', known=true)]", "Unit"))
|
||||
assert_equal(DogTag:Evaluate("[FractionalHP(unit='pettarget', known=true)]", "Unit"), nil)
|
||||
|
||||
assert_equal(DogTag:Evaluate("[HP('target')]", "Unit"), 2500)
|
||||
assert_equal(DogTag:Evaluate("[MaxHP('target')]", "Unit"), 2500)
|
||||
@ -126,6 +143,19 @@ assert_equal(DogTag:Evaluate("[HP(MyValue)]", "Unit"), 'Bad unit: "fakeunit"')
|
||||
MyValue_data = 50
|
||||
assert_equal(DogTag:Evaluate("[HP(MyValue)]", "Unit"), 'Bad unit: "50"')
|
||||
MyValue_data = nil
|
||||
assert_equal(DogTag:Evaluate("[HP(MyValue)]", "Unit"), 'Bad unit: "nil"')
|
||||
assert_equal(DogTag:Evaluate("[HP(MyValue)]", "Unit"), nil)
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
local fs = frame:CreateFontString(nil, "ARTWORK")
|
||||
DogTag:AddFontString(fs, frame, "[HP]", "Unit", { unit = "player" })
|
||||
assert_equal(fs:GetText(), 1500)
|
||||
units.player.hp = 1600
|
||||
FireEvent("UNIT_HEALTH", "player")
|
||||
FireOnUpdate(0.05)
|
||||
assert_equal(fs:GetText(), 1600)
|
||||
|
||||
assert_equal(DogTag:Evaluate("[HPColor(unit='target')]", "Unit"), "|cff00ff00")
|
||||
assert_equal(DogTag:Evaluate("[HPColor(unit='pet')]", "Unit"), "|cffff0000")
|
||||
assert_equal(DogTag:Evaluate("[HPColor(unit='player')]", "Unit"), "|cff65ff00")
|
||||
|
||||
print("LibDogTag-Unit-3.0: Tests succeeded")
|
Reference in New Issue
Block a user