From 5e3415e3bb07686b0623b51d6ece2b9ff9e79e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tekkub=20=CA=95=20=C2=B4=E1=B4=A5=60=20=CA=94?= Date: Wed, 23 Nov 2016 23:49:53 -0700 Subject: [PATCH] Add pilgrim bounty buff reminder --- Cork.toc | 3 +++ modules/DarkmoonExp.lua | 23 ++++------------------- modules/PilgrimsBountyRep.lua | 31 +++++++++++++++++++++++++++++++ services/holiday_active.lua | 22 ++++++++++++++++++++++ 4 files changed, 60 insertions(+), 19 deletions(-) create mode 100644 modules/PilgrimsBountyRep.lua create mode 100644 services/holiday_active.lua diff --git a/Cork.toc b/Cork.toc index ea5b041..5811cea 100644 --- a/Cork.toc +++ b/Cork.toc @@ -21,6 +21,8 @@ CallbackHandler-1.0.lua LibDataBroker-1.1\LibDataBroker-1.1.lua AceEvent-3.0\AceEvent-3.0.xml +services\holiday_active.lua + Locale.lua KeyBlacklist.lua @@ -71,6 +73,7 @@ modules\LancePole.lua modules\Lures.lua modules\Minipet.lua modules\OpenableItems.lua +modules\PilgrimsBountyRep.lua modules\QuestStartingItems.lua modules\Repairs.lua modules\Salvage.lua diff --git a/modules/DarkmoonExp.lua b/modules/DarkmoonExp.lua index a2c9ebe..3feb0b1 100644 --- a/modules/DarkmoonExp.lua +++ b/modules/DarkmoonExp.lua @@ -1,5 +1,5 @@ -local myname, Cork = ... +local myname, ns = ... local ae = LibStub("AceEvent-3.0") @@ -7,27 +7,12 @@ local maxlevel = GetMaxPlayerLevel() local itemname = "Darkmoon EXP Buff" local spellname, _, icon = GetSpellInfo(46668) local hatspell = GetSpellInfo(136583) -local dataobj = Cork:GenerateSelfBuffer(itemname, icon, spellname, hatspell) -Cork.defaultspc[itemname.."-enabled"] = true +local dataobj = ns:GenerateSelfBuffer(itemname, icon, spellname, hatspell) +ns.defaultspc[itemname.."-enabled"] = true local function DarkmoonToday() - local _, _, day = CalendarGetDate() - local title, hour, sequenceType - local i = 1 - repeat - title, hour, _, _, sequenceType = CalendarGetDayEvent(0, day, i) - if title == "Darkmoon Faire" then - if sequenceType == "START" then - return GetGameTime() >= hour - elseif sequenceType == "END" then - return GetGameTime() < hour - else - return true - end - end - i = i + 1 - until not title + return ns.IsHolidayActive("Darkmoon Faire") end diff --git a/modules/PilgrimsBountyRep.lua b/modules/PilgrimsBountyRep.lua new file mode 100644 index 0000000..c57cb1d --- /dev/null +++ b/modules/PilgrimsBountyRep.lua @@ -0,0 +1,31 @@ + +local myname, ns = ... +local ae = LibStub("AceEvent-3.0") + + +local maxlevel = GetMaxPlayerLevel() +local itemname = "Pilgrim's Bounty Rep Buff" +local spellname, _, icon = GetSpellInfo(61849) +local dataobj = ns:GenerateSelfBuffer(itemname, icon, spellname) +ns.defaultspc[itemname.."-enabled"] = true + + +local function BountyToday() + return ns.IsHolidayActive("Pilgrim's Bounty") +end + + +function dataobj:Test() + if UnitLevel("player") < maxlevel then return false end + return BountyToday() and self:TestWithoutResting() +end + + +function dataobj:Init() + if UnitLevel("player") == maxlevel then OpenCalendar() end +end + + +ae.RegisterEvent(dataobj, "CALENDAR_UPDATE_EVENT_LIST", "Scan") +dataobj.tiplink = "spell:61849" +dataobj.CorkIt = nil diff --git a/services/holiday_active.lua b/services/holiday_active.lua new file mode 100644 index 0000000..5a82bfe --- /dev/null +++ b/services/holiday_active.lua @@ -0,0 +1,22 @@ + +local myname, ns = ... + + +function ns.IsHolidayActive(name) + local _, _, day = CalendarGetDate() + local title, hour, sequenceType + local i = 1 + repeat + title, hour, _, _, sequenceType = CalendarGetDayEvent(0, day, i) + if title == name then + if sequenceType == "START" then + return GetGameTime() >= hour + elseif sequenceType == "END" then + return GetGameTime() < hour + else + return true + end + end + i = i + 1 + until not title +end