diff --git a/README.md b/README.md index 0567f60..2c7792a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # WoW Forever addons -Nine small addons for WoW Forever (client 1.60.1, Interface 16001). +Ten small addons for WoW Forever (client 1.60.1, Interface 16001). | Addon | What it does | Check command | | --- | --- | --- | @@ -13,10 +13,11 @@ Nine small addons for WoW Forever (client 1.60.1, Interface 16001). | Flight Finder | Marks the flight masters you haven't discovered yet on zone and continent maps, coloured by faction. Click one to set a waypoint. | `/ff` toggles and counts | | Fish Key | While you fish, the key you cast Fishing with clicks the bobber instead. It casts Fishing again once the fish is looted and the key is released. For the cast it turns the Interact Key setting on and press and hold casting off, then puts both back. It also turns off music, ambience and dialog and turns sound effects to full, so the splash stands out. | `/fish`, `/fish on`, `/fish off`, `/fish sound on`, `/fish sound off` | | Windfury! | Every Windfury proc slams a huge "WINDFURY!" onto the screen with a lightning flash, a storm glow, a burst of Windfury icons and a raid warning horn. Procs within 8 seconds build a combo that gets bigger and shakier. | `/wf` plays it once, `/wf on`, `/wf off`, `/wf sound on`, `/wf sound off` | +| Windfury Reminder | A pulsing Windfury icon at the top of the screen while your shaman's main hand has no Windfury, from Windfury Weapon or Windfury Totem, with a horn when a fight starts without it. Counts down the last 30 seconds of Windfury Weapon. Hidden in rest areas out of combat, while dead and on flights. | `/wfr` previews and shows status, `/wfr on`, `/wfr off`, `/wfr sound on`, `/wfr sound off`, `/wfr move`, `/wfr reset` | ## Install -Copy the nine addon folders into `World of Warcraft/_forever_/Interface/AddOns/`, then type `/reload` in game. +Copy the ten addon folders into `World of Warcraft/_forever_/Interface/AddOns/`, then type `/reload` in game. Each addon works on its own, so copy only the ones you want. Vendor Flag and Quest Shopping List stay disabled unless Auctionator is installed. ## Known limits @@ -31,6 +32,7 @@ Each addon works on its own, so copy only the ones you want. Vendor Flag and Que - Flight Finder learns which flight points you have only from a flight master's taxi map, since Forever's map lists every flight point as known. Until you talk to any flight master once on a character, every flight point shows. - Fish Key finds Fishing on Blizzard's action bars, `CLICK` bindings to addon buttons, and spell or macro bindings. It doesn't see bar addons that bind keys through their own override bindings, such as Bartender. While you fish it raises the interact range to 30 yards, so a closer NPC or object can be picked over the bobber. - Windfury! can't read the combat log, which Forever keeps from addons. It reacts to the extra attack combat text event instead, whose spell name is hidden in combat, so Hand of Justice and Sword Specialization procs can set it off too. The client only sends that event while Scrolling Combat Text is on, so if it's off the addon turns it on and hides Blizzard's floating text. To get Blizzard's text back, turn the setting off and on again with the addon disabled. +- Windfury Reminder spots Windfury by the "Windfury" line on the main hand tooltip, so it needs an English client. It checks the main hand only. ## Tests @@ -47,6 +49,7 @@ lua tests/test_sr.lua ShipRoutes lua tests/test_fk.lua FishKey/FishKey.lua lua tests/test_ff.lua FlightFinder lua tests/test_wf.lua Windfury/Windfury.lua +lua tests/test_wfr.lua WindfuryReminder/WindfuryReminder.lua ``` ## Regenerating Dungeon Pre-Quest's data diff --git a/WindfuryReminder/WindfuryReminder.lua b/WindfuryReminder/WindfuryReminder.lua new file mode 100644 index 0000000..a1c4d71 --- /dev/null +++ b/WindfuryReminder/WindfuryReminder.lua @@ -0,0 +1,304 @@ +-- Windfury Reminder: a pulsing Windfury icon at the top of the screen while a +-- shaman's main hand has no Windfury (Windfury Weapon or Windfury Totem), and +-- a countdown in the last 30 seconds of a long one. Hidden while dead, on a +-- flight, with no main hand weapon, and in rest areas out of combat. +-- +-- The weapon enchant API gives enchant IDs but no names, so the main hand +-- tooltip is read for a "Windfury" line. IDs found that way are saved. If the +-- client hides the values in combat, the last readable state is kept and its +-- expiry counted down. + +local SLOT = 16 -- main hand inventory slot +local WARN = 30 -- seconds left that count as expiring +local LONG = 60 -- only enchants this long get a countdown (the totem's lasts 10s) +local POLL = 0.25 +local PREVIEW = 4 +local MATCH = "Windfury" +local SPELL = "Windfury Weapon" +local ICON = "Interface\\Icons\\Spell_Nature_Cyclone" +local SOUND = (SOUNDKIT and SOUNDKIT.RAID_WARNING) or 8959 +local PERMANENT = (Enum and Enum.ItemEnchantType and Enum.ItemEnchantType.Permanent) or 1 + +local function secret(v) return issecretvalue ~= nil and issecretvalue(v) end +local function readable(v) return v ~= nil and not secret(v) end + +local db +local notWindfury = {} -- enchant IDs seen without Windfury, this session only +local st = { + shaman = false, known = false, + seen = false, -- had one readable answer since login + expires = nil, -- GetTime() when the current Windfury ends, nil = none + peak = 0, -- longest time left seen on the current Windfury + mode = nil, -- "missing", "expiring" or nil + previewUntil = 0, +} + +-- Reading the weapon -------------------------------------------------------- + +local function enchants() + if C_Item and C_Item.GetWeaponEnchantInfo then + return C_Item.GetWeaponEnchantInfo(Enum.WeaponSlot.MainHand) + end + local has, ms, charges, id = GetWeaponEnchantInfo() + return { { hasEnchant = has, enchantType = 2, timeLeft = ms, charges = charges, enchantID = id } } +end + +-- true / false, or nil when the tooltip can't be read. Line 1 is the item +-- name, which is skipped so a weapon called "Windfury ..." doesn't count. +local function tooltipSaysWindfury() + if not C_TooltipInfo then return nil end + local data = C_TooltipInfo.GetInventoryItem("player", SLOT) + if not readable(data) or not readable(data.lines) or #data.lines < 2 then return nil end + for i = 2, #data.lines do + local text = data.lines[i].leftText + if text ~= nil then + if secret(text) then return nil end + if text:find(MATCH, 1, true) then return true end + end + end + return false +end + +-- has (bool), seconds left (number) — or nil when nothing can be read. +local function readWeapon() + local ok, list = pcall(enchants) + if not ok or not readable(list) then return nil end + local temps, unknown = {}, {} + for _, e in pairs(list) do + if not readable(e) or not readable(e.hasEnchant) then return nil end + if e.hasEnchant and e.enchantType ~= PERMANENT then + temps[#temps + 1] = e + local id = e.enchantID + if not readable(id) or (db.ids[id] == nil and not notWindfury[id]) then + unknown[#unknown + 1] = e + end + end + end + -- A saved Windfury ID settles it, and the tooltip's Windfury line would be + -- that one's anyway, so it can't name the others. + local best + for _, e in ipairs(temps) do + if readable(e.enchantID) and db.ids[e.enchantID] then + if not readable(e.timeLeft) then return nil end + best = math.max(best or 0, e.timeLeft / 1000) + end + end + if best or #unknown == 0 then return best ~= nil, best or 0 end + + local tip = tooltipSaysWindfury() + if tip == nil then return nil end + if not tip then + for _, e in ipairs(unknown) do + if readable(e.enchantID) then notWindfury[e.enchantID] = true end + end + return false, 0 + end + -- One unnamed enchant: the Windfury line is that one's. With more, take the + -- shortest time left, so the countdown never comes late. + if #unknown == 1 and readable(unknown[1].enchantID) then db.ids[unknown[1].enchantID] = true end + for _, e in ipairs(unknown) do + if not readable(e.timeLeft) then return nil end + best = math.min(best or math.huge, e.timeLeft / 1000) + end + return true, best +end + +local function knowsWindfury() + local info = C_Spell.GetSpellInfo(SPELL) + if not readable(info) or not readable(info.spellID) then return false end + local ok, known = pcall(C_SpellBook.IsSpellKnownOrInSpellBook, info.spellID) + if not ok or not readable(known) then return true end + return known +end + +local function relevant() + if not db.enabled or not st.shaman or not st.known or not st.seen then return false end + if UnitIsDeadOrGhost("player") or UnitOnTaxi("player") then return false end + if not GetInventoryItemID("player", SLOT) then return false end + if IsResting() and not InCombatLockdown() then return false end + return true +end + +-- Display ------------------------------------------------------------------- + +local f = CreateFrame("Frame", "WindfuryReminderFrame", UIParent) +f:SetSize(64, 64) +f:SetFrameStrata("HIGH") +f:SetMovable(true) +f:SetClampedToScreen(true) +f:EnableMouse(false) +f:RegisterForDrag("LeftButton") +f:Hide() + +local glow = f:CreateTexture(nil, "BACKGROUND") +glow:SetTexture("Interface\\Buttons\\UI-ActionButton-Border") +glow:SetBlendMode("ADD") +glow:SetSize(150, 150) +glow:SetPoint("CENTER") + +local icon = f:CreateTexture(nil, "ARTWORK") +icon:SetTexture(ICON) +icon:SetAllPoints() +icon:SetTexCoord(0.07, 0.93, 0.07, 0.93) + +local label = f:CreateFontString(nil, "OVERLAY") +label:SetFont(STANDARD_TEXT_FONT, 22, "THICKOUTLINE") +label:SetPoint("TOP", f, "BOTTOM", 0, -6) + +local function place() + f:ClearAllPoints() + local p = db.point + if p then f:SetPoint(p[1], UIParent, p[2], p[3], p[4]) else f:SetPoint("CENTER", UIParent, "CENTER", 0, 220) end +end + +f:SetScript("OnDragStart", function(self) self:StartMoving() end) +f:SetScript("OnDragStop", function(self) + self:StopMovingOrSizing() + local p, _, rp, x, y = self:GetPoint() + db.point = { p, rp, x, y } +end) + +local pulse = 0 +f:SetScript("OnUpdate", function(_, elapsed) + pulse = pulse + elapsed + local speed = InCombatLockdown() and 9 or 4 + local s = 0.5 + 0.5 * math.sin(pulse * speed) + if st.mode == "missing" then + glow:SetAlpha(0.35 + 0.65 * s) + icon:SetAlpha(0.6 + 0.4 * s) + else + glow:SetAlpha(0.3 * s) + icon:SetAlpha(1) + end +end) + +local function show(mode, left) + st.mode = mode + if mode == "missing" then + glow:SetVertexColor(1, 0.15, 0.1) + icon:SetDesaturated(true) + label:SetTextColor(1, 0.25, 0.2) + label:SetText("NO WINDFURY") + else + glow:SetVertexColor(1, 0.8, 0.1) + icon:SetDesaturated(false) + label:SetTextColor(1, 0.85, 0.1) + left = math.ceil(left) + label:SetText(string.format("WINDFURY %d:%02d", math.floor(left / 60), left % 60)) + end + f:Show() +end + +local function hide() + st.mode = nil + if not db or not db.moving then f:Hide() end +end + +-- State --------------------------------------------------------------------- + +local function update() + if not db then return end + local now = GetTime() + local wasActive = st.expires ~= nil + + local has, left = readWeapon() + if has ~= nil then + st.seen = true + if has then + if not wasActive or left > st.peak then st.peak = left end + st.expires = now + left + else + st.expires = nil + end + elseif st.expires and st.expires <= now then + st.expires = nil -- unreadable, but the countdown has run out + end + if not st.expires then + -- A long Windfury just ran out mid-fight: sound the alarm. + if wasActive and st.peak > LONG and InCombatLockdown() and db.sound and relevant() then + PlaySound(SOUND, "Master") + end + st.peak = 0 + end + + if now < st.previewUntil then + show("missing") + elseif not relevant() then + hide() + elseif not st.expires then + show("missing") + elseif st.peak > LONG and st.expires - now <= WARN then + show("expiring", st.expires - now) + else + hide() + end + if db.moving then f:Show() end +end + +-- Events -------------------------------------------------------------------- + +local ev = CreateFrame("Frame") +ev:RegisterEvent("ADDON_LOADED") +ev:SetScript("OnEvent", function(self, event, arg1) + if event == "ADDON_LOADED" then + if arg1 ~= "WindfuryReminder" then return end + WindfuryReminderDB = WindfuryReminderDB or {} + db = WindfuryReminderDB + if db.enabled == nil then db.enabled = true end + if db.sound == nil then db.sound = true end + db.ids = db.ids or {} + db.moving = nil + place() + self:UnregisterEvent("ADDON_LOADED") + for _, e in ipairs({ "PLAYER_ENTERING_WORLD", "PLAYER_EQUIPMENT_CHANGED", "WEAPON_ENCHANT_CHANGED", + "PLAYER_REGEN_DISABLED", "PLAYER_REGEN_ENABLED", "PLAYER_UPDATE_RESTING", "PLAYER_DEAD", + "PLAYER_ALIVE", "PLAYER_UNGHOST", "SPELLS_CHANGED", "LEARNED_SPELL_IN_TAB" }) do + pcall(self.RegisterEvent, self, e) + end + self:RegisterUnitEvent("UNIT_INVENTORY_CHANGED", "player") + C_Timer.NewTicker(POLL, update) + return + end + if event == "PLAYER_ENTERING_WORLD" or event == "SPELLS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then + st.shaman = select(2, UnitClass("player")) == "SHAMAN" + st.known = st.shaman and knowsWindfury() + end + update() + if event == "PLAYER_REGEN_DISABLED" and st.mode == "missing" and db.sound then + PlaySound(SOUND, "Master") + end +end) + +-- Slash command ------------------------------------------------------------- + +local function say(msg) print("|cff66ccffWindfury Reminder|r " .. msg) end + +SLASH_WINDFURYREMINDER1 = "/wfr" +SlashCmdList.WINDFURYREMINDER = function(msg) + msg = (msg or ""):lower():gsub("^%s+", ""):gsub("%s+$", "") + if msg == "on" or msg == "off" then + db.enabled = msg == "on" + say(db.enabled and "on." or "off.") + elseif msg == "sound on" or msg == "sound off" then + db.sound = msg == "sound on" + say(db.sound and "sound on." or "sound off.") + elseif msg == "move" then + db.moving = not db.moving + f:EnableMouse(db.moving) + say(db.moving and "drag it, then /wfr move again." or "locked.") + elseif msg == "reset" then + db.point = nil + place() + say("position reset.") + else + st.previewUntil = GetTime() + PREVIEW + local now = GetTime() + local state = st.expires and string.format("Windfury %ds left", math.floor(st.expires - now)) + or (st.seen and "no Windfury" or "weapon not read yet") + say(string.format("%s, sound %s. %s. %s. /wfr on|off, sound on|off, move, reset", + db.enabled and "on" or "off", db.sound and "on" or "off", + not st.shaman and "Not a shaman" or (st.known and SPELL .. " known" or SPELL .. " not learned"), + state)) + end + update() +end diff --git a/WindfuryReminder/WindfuryReminder.toc b/WindfuryReminder/WindfuryReminder.toc new file mode 100644 index 0000000..4fd8251 --- /dev/null +++ b/WindfuryReminder/WindfuryReminder.toc @@ -0,0 +1,7 @@ +## Interface: 16001 +## Title: Windfury Reminder +## Notes: Warns when your main hand has no Windfury. +## Version: 1.0 +## SavedVariables: WindfuryReminderDB + +WindfuryReminder.lua diff --git a/tests/test_wfr.lua b/tests/test_wfr.lua new file mode 100644 index 0000000..c8090b2 --- /dev/null +++ b/tests/test_wfr.lua @@ -0,0 +1,240 @@ +-- Runs WindfuryReminder.lua against a mock of the WoW API. +-- arg[1] = addon file + +local clock = 100 +function GetTime() return clock end +STANDARD_TEXT_FONT = "Fonts\\FRIZQT__.TTF" +SOUNDKIT = { RAID_WARNING = 8959 } +Enum = { WeaponSlot = { MainHand = 0 }, ItemEnchantType = { Permanent = 1, Temporary = 2, Imbue = 3 } } +local sounds = {} +function PlaySound(id, channel) sounds[#sounds + 1] = id; assert(channel == "Master") end +local secrets = {} +function issecretvalue(v) return secrets[v] == true end +local printed = {} +function print(s) printed[#printed + 1] = s end +SlashCmdList = {} + +-- World state. +local class, dead, taxi, resting, combat, weapon = "SHAMAN", false, false, false, false, 1234 +local knows = true +local weaponEnchants = {} -- list returned by GetWeaponEnchantInfo +local tipLines = { "Quel'Serrar" } +local enchantSecret = false +local tipCalls = 0 +function UnitClass() return "Shaman", class end +function UnitIsDeadOrGhost() return dead end +function UnitOnTaxi() return taxi end +function IsResting() return resting end +function InCombatLockdown() return combat end +function GetInventoryItemID(_, slot) assert(slot == 16); return weapon end +C_Spell = { GetSpellInfo = function(n) assert(n == "Windfury Weapon"); return knows and { spellID = 8232 } or nil end } +C_SpellBook = { IsSpellKnownOrInSpellBook = function(id) assert(id == 8232); return knows end } +C_Item = { GetWeaponEnchantInfo = function(slot) + assert(slot == 0) + if enchantSecret then local s = {}; secrets[s] = true; return s end + return weaponEnchants +end } +C_TooltipInfo = { GetInventoryItem = function(unit, slot) + assert(unit == "player" and slot == 16) + tipCalls = tipCalls + 1 + local lines = {} + for i, t in ipairs(tipLines) do lines[i] = { leftText = t } end + return { lines = lines } +end } +local tickers = {} +C_Timer = { NewTicker = function(_, fn) tickers[#tickers + 1] = fn end } + +local frames, fontStrings = {}, {} +local function region() + local r = { shown = true, alpha = 1 } + function r:SetAlpha(a) assert(a >= -1e-9 and a <= 1 + 1e-9, "alpha " .. a); self.alpha = a end + function r:Show() self.shown = true end + function r:Hide() self.shown = false end + function r:IsShown() return self.shown end + function r:SetText(t) self.text = t end + function r:SetDesaturated(d) self.desat = d end + function r:EnableMouse(m) self.mouse = m end + function r:GetPoint() return "TOP", UIParent, "TOP", 5, -40 end + local noop = function() end + for _, k in ipairs({ "SetPoint", "ClearAllPoints", "SetAllPoints", "SetSize", "SetTexture", "SetBlendMode", + "SetVertexColor", "SetFont", "SetTextColor", "SetFrameStrata", "SetMovable", "SetClampedToScreen", + "RegisterForDrag", "SetTexCoord", "StartMoving", "StopMovingOrSizing" }) do + r[k] = r[k] or noop + end + return r +end +function CreateFrame(_, name) + local fr = region() + fr.scripts, fr.events = {}, {} + function fr:SetScript(k, fn) self.scripts[k] = fn end + function fr:RegisterEvent(e) self.events[e] = true end + function fr:RegisterUnitEvent(e) self.events[e] = true end + function fr:UnregisterEvent(e) self.events[e] = nil end + function fr:CreateTexture() return region() end + function fr:CreateFontString() local s = region(); fontStrings[#fontStrings + 1] = s; return s end + frames[#frames + 1] = fr + if name then _G[name] = fr end + return fr +end +UIParent = region() + +dofile(arg[1]) + +local frame = WindfuryReminderFrame +local ev +for _, fr in ipairs(frames) do if fr.events.ADDON_LOADED then ev = fr end end +assert(frame and ev) +local function fire(...) ev.scripts.OnEvent(ev, ...) end +local function tick(sec) + for _ = 1, math.floor(sec / 0.25 + 0.5) do + clock = clock + 0.25 + for e in pairs(weaponEnchants) do + local w = weaponEnchants[e] + if w.timeLeft then w.timeLeft = math.max(0, w.timeLeft - 250) end + end + for _, fn in ipairs(tickers) do fn() end + if frame.shown then frame.scripts.OnUpdate(frame, 0.25) end + end +end +fire("ADDON_LOADED", "Other") +assert(WindfuryReminderDB == nil) +fire("ADDON_LOADED", "WindfuryReminder") +assert(WindfuryReminderDB.enabled and WindfuryReminderDB.sound and #tickers == 1) +assert(not frame.shown) + +-- Nothing until the world is entered. +tick(1) +assert(not frame.shown) +fire("PLAYER_ENTERING_WORLD") +assert(frame.shown, "no enchant should warn") +local function lastPrint() return printed[#printed] or "" end + +-- Windfury on: tooltip names it, ID gets saved, no reminder. +weaponEnchants = { { hasEnchant = true, enchantType = 3, timeLeft = 300000, charges = 0, enchantID = 1669 } } +tipLines = { "Quel'Serrar", "Main Hand", "Windfury 4 (5 min)" } +tick(0.25) +assert(not frame.shown, "Windfury present") +assert(WindfuryReminderDB.ids[1669] == true) +-- Cached: the tooltip isn't read again. +local calls = tipCalls +tick(1) +assert(tipCalls == calls) + +-- Last 30 seconds: countdown. +tick(271) +assert(frame.shown and fontStrings[1].text:find("^WINDFURY 0:2%d$"), fontStrings[1].text) +-- Runs out in combat: one alarm, then "missing". +combat = true +fire("PLAYER_REGEN_DISABLED") +assert(#sounds == 0, "had Windfury at pull") +tick(30) +weaponEnchants = {} +tick(0.25) +assert(frame.shown and fontStrings[1].text == "NO WINDFURY") +assert(#sounds == 1, "expiry alarm " .. #sounds) +tick(5) +assert(#sounds == 1) + +-- Combat start while missing: alarm. +combat = false +fire("PLAYER_REGEN_ENABLED") +combat = true +fire("PLAYER_REGEN_DISABLED") +assert(#sounds == 2) +combat = false +fire("PLAYER_REGEN_ENABLED") + +-- Rockbiter isn't Windfury. +weaponEnchants = { { hasEnchant = true, enchantType = 3, timeLeft = 300000, charges = 0, enchantID = 503 } } +tipLines = { "Quel'Serrar", "Main Hand", "Rockbiter 3 (5 min)" } +tick(0.25) +assert(frame.shown, "Rockbiter should warn") +assert(WindfuryReminderDB.ids[503] == nil) + +-- A weapon named Windfury doesn't count. +tipLines = { "Windfury Blade", "Main Hand", "Rockbiter 3 (5 min)" } +weaponEnchants[1].enchantID = 504 +tick(0.25) +assert(frame.shown) + +-- Totem Windfury (10s, refreshed): no countdown flicker, no reminder. +weaponEnchants = { { hasEnchant = true, enchantType = 2, timeLeft = 10000, charges = 0, enchantID = 1783 } } +tipLines = { "Quel'Serrar", "Windfury Totem 2 (10 sec)" } +for _ = 1, 4 do + tick(5) + assert(not frame.shown, "totem windfury") + weaponEnchants[1].timeLeft = 10000 +end + +-- Permanent enchants are ignored. +weaponEnchants = { { hasEnchant = true, enchantType = 1, timeLeft = 0, charges = 0, enchantID = 1900 } } +tipLines = { "Quel'Serrar", "Crusader" } +tick(0.25) +assert(frame.shown) + +-- Two temp enchants, one cached Windfury: fine. +weaponEnchants = { + { hasEnchant = true, enchantType = 2, timeLeft = 1800000, charges = 0, enchantID = 13 }, + { hasEnchant = true, enchantType = 3, timeLeft = 300000, charges = 0, enchantID = 1669 }, +} +tipLines = { "Quel'Serrar", "Sharpened +2 (30 min)", "Windfury 4 (5 min)" } +tick(0.25) +assert(not frame.shown) + +-- Secret values in combat: last state kept, countdown runs on. +combat = true +enchantSecret = true +tick(200) +assert(not frame.shown, "still has Windfury by the clock") +tick(80) +assert(frame.shown, "countdown from remembered expiry") +tick(25) +assert(frame.shown, "expired by the clock") +assert(#sounds == 3, "alarm when a remembered Windfury runs out") +enchantSecret = false +combat = false + +-- Hidden: rest area, dead, taxi, no weapon, other class, not learned. +weaponEnchants = {} +tick(0.25) +assert(frame.shown) +resting = true; tick(0.25); assert(not frame.shown) +combat = true; tick(0.25); assert(frame.shown, "rest area in combat still warns") +combat = false; resting = false +dead = true; tick(0.25); assert(not frame.shown); dead = false +taxi = true; tick(0.25); assert(not frame.shown); taxi = false +weapon = nil; tick(0.25); assert(not frame.shown); weapon = 1234 +knows = false; fire("SPELLS_CHANGED"); assert(not frame.shown) +knows = true; fire("SPELLS_CHANGED"); assert(frame.shown) +class = "WARRIOR"; fire("PLAYER_ENTERING_WORLD"); assert(not frame.shown) +class = "SHAMAN"; fire("PLAYER_ENTERING_WORLD"); assert(frame.shown) + +-- Slash commands. +SlashCmdList.WINDFURYREMINDER("off") +assert(not WindfuryReminderDB.enabled and not frame.shown) +SlashCmdList.WINDFURYREMINDER("") +assert(frame.shown, "preview shows even when off") +assert(lastPrint():find("off, sound on"), lastPrint()) +tick(5) +assert(not frame.shown, "preview ends") +SlashCmdList.WINDFURYREMINDER("on") +assert(frame.shown) +SlashCmdList.WINDFURYREMINDER("sound off") +assert(not WindfuryReminderDB.sound) +local n = #sounds +combat = true; fire("PLAYER_REGEN_DISABLED"); combat = false +assert(#sounds == n, "sound off") +SlashCmdList.WINDFURYREMINDER("move") +assert(frame.mouse) +frame.scripts.OnDragStop(frame) +assert(WindfuryReminderDB.point[1] == "TOP" and WindfuryReminderDB.point[4] == -40) +weaponEnchants = { { hasEnchant = true, enchantType = 3, timeLeft = 300000, charges = 0, enchantID = 1669 } } +tick(0.25) +assert(frame.shown, "stays visible while moving") +SlashCmdList.WINDFURYREMINDER("move") +assert(not frame.mouse and not frame.shown) +SlashCmdList.WINDFURYREMINDER("reset") +assert(WindfuryReminderDB.point == nil) + +print = io.write +io.write("ok\n")