diff --git a/FollowerCache.lua b/FollowerCache.lua index cd1776d..77408d9 100644 --- a/FollowerCache.lua +++ b/FollowerCache.lua @@ -21,7 +21,7 @@ local tostring=tostring local GetItemInfo=GetItemInfo local LE_FOLLOWER_TYPE_GARRISON_6_0=_G.LE_FOLLOWER_TYPE_GARRISON_6_0 local LE_FOLLOWER_TYPE_SHIPYARD_6_2=_G.LE_FOLLOWER_TYPE_SHIPYARD_6_2 -local LE_FOLLOWER_TYPE_GARRISON_7_0=_G.LE_FOLLOWER_TYPE_GARRISON_7_0 or 4 +local LE_FOLLOWER_TYPE_GARRISON_7_0=_G.LE_FOLLOWER_TYPE_GARRISON_7_0 local maxrank=GARRISON_FOLLOWER_MAX_UPGRADE_QUALITY*1000+GARRISON_FOLLOWER_MAX_LEVEL local module=addon:NewSubClass('FollowerCache') --#module local cache={} --#cache @@ -35,7 +35,7 @@ function module:OnInitialized() self:RegisterEvent("GARRISON_FOLLOWER_XP_CHANGED","OnEvent") self.followerCache=cache:new(LE_FOLLOWER_TYPE_GARRISON_6_0) self.shipCache=cache:new(LE_FOLLOWER_TYPE_SHIPYARD_6_2) - self.hallCache=cache:new(LE_FOLLOWER_TYPE_GARRISON_7_0) + self.heroCache=cache:new(LE_FOLLOWER_TYPE_GARRISON_7_0) end function module:OnEvent(event,...) --@debug@ @@ -46,12 +46,12 @@ print(event,...) self.shipCache:OnEvent(event,...) elseif self.followerCache.cache[followerID].followerID then self.followerCache:OnEvent(event,...) - elseif self.hallCache.cache[followerID].followerID then - self.hallCache:OnEvent(event,...) + elseif self.heroCache.cache[followerID].followerID then + self.heroCache:OnEvent(event,...) else self.followerCache:Wipe() self.shipCache:Wipe() - self.hallCache:Wipe() + self.heroCache:Wipe() end end @@ -67,9 +67,6 @@ print(event,...) --@end-debug@ if event=="GARRISON_FOLLOWER_UPGRADED" or event=="GARRISON_FOLLOWER_XP_CHANGED" then local followerType,followerID=... - if toc < 70000 then - followerID=followerType - end if (self.cache[followerID]) then self.cache[followerID]['level']=G.GetFollowerLevel(followerID) self.cache[followerID]['xp']=G.GetFollowerXP(followerID) @@ -94,7 +91,13 @@ end function cache:Refresh() if next(self.cache) then return end self:Wipe() - for _,follower in pairs(G.GetFollowers(self.type)) do + print(self.type) + local list=G.GetFollowers(self.type) + if type(list) ~="table" then + print("Requested",self.type, " no follower found") + return + end + for _,follower in pairs(list) do followerTypes[follower.followerID]=follower.followerTypeID if follower.isCollected then self:AddExtraData(follower) @@ -104,7 +107,6 @@ function cache:Refresh() tinsert(self.sorted,i) self.cache[i]=follower end - end end function cache:AddAbilities(follower) @@ -148,6 +150,9 @@ function cache:AddExtraData(follower) follower.coloredname=C(follower.name,tostring(follower.quality)) follower.fullname=format("%3d %s",follower.rank,follower.coloredname) follower.maxed=follower.qLevel>=maxrank + if follower.followerTypeID==LE_FOLLOWER_TYPE_GARRISON_7_0 then + follower.maxed=false + end local weaponItemID, weaponItemLevel, armorItemID, armorItemLevel = G.GetFollowerItems(follower.followerID); follower.weaponItemID=weaponItemID follower.weaponItemLevel=weaponItemLevel @@ -232,10 +237,15 @@ function addon:GetAnyData(followerType,...) end if followerType== LE_FOLLOWER_TYPE_SHIPYARD_6_2 then return self:GetShipData(...) + elseif followerType== LE_FOLLOWER_TYPE_GARRISON_7_0 then + return self:GetHeroData(...) else return self:GetFollowerData(...) end end +function addon:GetHeroData(followerID,key,default) + return module.heroCache:GetFollowerData(followerID,key,default) +end function addon:GetFollowerData(followerID,key,default) return module.followerCache:GetFollowerData(followerID,key,default) end @@ -254,11 +264,16 @@ end function addon:GetShipsIterator(func) return module.shipCache:GetFollowersIterator(func) end +function addon:GetHeroesIterator(func) + return module.heroCache:GetFollowersIterator(func) +end function addon:GetAnyIterator(followerType,func) if followerType==LE_FOLLOWER_TYPE_GARRISON_6_0 then return self:GetFollowersIterator(func) - else + elseif followerType==LE_FOLLOWER_TYPE_SHIPYARD_6_2 then return self:GetShipsIterator(func) + else + return self:GetHeroesIterator(func) end end function addon:GetFollowerType(followerID) diff --git a/MatchMaker.lua b/MatchMaker.lua index 40e92d2..d554a30 100644 --- a/MatchMaker.lua +++ b/MatchMaker.lua @@ -73,14 +73,14 @@ end function addon:FollowerScore(mission,followerID) local score,chance=self:MissionScore(mission) - return format("%s %04d",score,followerID and math.min(1000-self:GetFollowerData(followerID,'rank',90),999)),chance + return format("%s %04d",score,followerID and math.min(1000-self:GetAnyData(0,followerID,'rank',90),999)),chance end local filters={skipMaxed=false,skipBusy=false} function filters.nop(followerID) return true end function filters.maxed(followerID,missionID) - return filters.skipMaxed and addon:GetFollowerData(followerID,'maxed') or false + return filters.skipMaxed and addon:GetAnyData(0,followerID,'maxed') or false end function filters.busy(followerID,missionID) return not addon:IsFollowerAvailableForMission(followerID,filters.skipBusy) @@ -95,7 +95,20 @@ function filters.xp(followerID,missionID) return filters.maxed(followerID,missionID) or filters.other(followerID,missionID) end --alias - +--[[ +local filters={skipMaxed=false,skipBusy=true,skipTroops=false,skipIgnored=true} +setmetatable(filters,{ + __call=function(t,followerID,missionID) + local follower=addon:GetAnyData(0,followerID) + if t.skipMaxed then return follower.maxed end + if t.skipTroops then return follower.isTroop end + if t.skipBusy then return addon:IsFollowerAvailableForMission(followerID,t.skipBusy) end + if t.skipIgnored then return addon:IsIgnored(followerID,missionID) end + end, + __index=function(t,key) return t end +} +) +--]] local nop={addRow=function() end} local scroller=nop local function CreateFilter(missionClass) @@ -148,7 +161,7 @@ local function AddMoreFollowers(self,mission,scores,justdo) c1="red" c2="green" end - scroller:AddRow(addon:GetFollowerData(followerID,'fullname') .." changes score from " .. C(candidateScore,c1).." to "..C(newScore,c2)) + scroller:AddRow(addon:GetAnyData(0,followerID,'fullname') .." changes score from " .. C(candidateScore,c1).." to "..C(newScore,c2)) end if (newScore > candidateScore or justdo) then candidate=followerID @@ -160,7 +173,7 @@ local function AddMoreFollowers(self,mission,scores,justdo) if candidate then local slot=P:CurrentSlot() if P:AddFollower(candidate) and dbg then - scroller:addRow(C("Slot " .. slot..":","Green").. " " .. addon:GetFollowerData(candidate,'fullname')) + scroller:addRow(C("Slot " .. slot..":","Green").. " " .. addon:GetAnyData(0,candidate,'fullname')) end candidate=nil end @@ -234,7 +247,7 @@ local function MatchMaker(self,mission,party,includeBusy,onlyBest) end if firstmember then if P:AddFollower(firstmember) and dbg then - scroller:AddRow(C("Slot 1:","Green").. " " .. addon:GetFollowerData(firstmember,'fullname')) + scroller:AddRow(C("Slot 1:","Green").. " " .. addon:GetAnyData(0,firstmember,'fullname')) end if mission.numFollowers > 1 then AddMoreFollowers(self,mission,scores) @@ -288,7 +301,7 @@ function addon:MCMatchMaker(missionID,party,skipEpic,cap) if (skipEpic) then if (self:GetMissionData(missionID,'class')=='xp') then for i=1,#party.members do - if not self:GetFollowerData(party.members[i],'maxed') then + if not self:GetAnyData(0,party.members[i],'maxed') then return end end diff --git a/MissionCache.lua b/MissionCache.lua index e0ea1e2..74c4053 100644 --- a/MissionCache.lua +++ b/MissionCache.lua @@ -14,6 +14,7 @@ local GARRISON_SHIP_OIL_CURRENCY=GARRISON_SHIP_OIL_CURRENCY local GARRISON_FOLLOWER_MAX_LEVEL=GARRISON_FOLLOWER_MAX_LEVEL local LE_FOLLOWER_TYPE_GARRISON_6_0=_G.LE_FOLLOWER_TYPE_GARRISON_6_0 local LE_FOLLOWER_TYPE_SHIPYARD_6_2=_G.LE_FOLLOWER_TYPE_SHIPYARD_6_2 +local LE_FOLLOWER_TYPE_GARRISON_7_0=_G.LE_FOLLOWER_TYPE_GARRISON_7_0 local GMF=GMF local GSF=GSF local GMFMissions=GMFMissions @@ -26,6 +27,7 @@ local tostring,GetSpecializationInfo,GetSpecialization=tostring,GetSpecializatio local empty={} local index={} local classes +local _G=_G -- Mission caching is a bit different fron follower caching mission appears and disappears on a regular basis local module=addon:NewSubClass('MissionCache') --#module @@ -114,6 +116,12 @@ function module:GetMission(id,noretry) elseif type=="p" then mission=GMFMissions.inProgressMissions[ix] if mission and mission.missionID==id then return mission end + elseif type=="ha" then + mission=GHFMissions.availableMissions[ix] + if mission and mission.missionID==id then return mission end + elseif type=="hp" then + mission=GHFMissions.inProgressMissions[ix] + if mission and mission.missionID==id then return mission end elseif type=="s" then mission=GSFMissions.missions[ix] if mission and mission.missionID==id then return mission end @@ -124,10 +132,13 @@ function module:GetMission(id,noretry) scan(GMFMissions.availableMissions,'a') scan(GMFMissions.inProgressMissions,'p') scan(GSFMissions.missions,'s') + if GHFMissions then + scan(GHFMissions.availableMissions,'ha') + scan(GHFMissions.inProgressMissions,'hp') + end return self:GetMission(id,true) end function module:AddExtraData(mission) - --print(mission.missionID,mission.creates) if mission.class then return end local rewards=mission.rewards if not rewards then @@ -236,7 +247,8 @@ print("Iterator called, list is",list) end,list,0 end function module:OnAllGarrisonMissions(func,inProgress,missionType) - local list=inProgress and GMFMissions.inProgressMissions or GMFMissions.availableMissions + local m=(missionType and missionType==LE_FOLLOWER_TYPE_GARRISON_7_0) and GHFMissions or GMFMissions + local list=inProgress and m.inProgressMissions or m.availableMissions local tmp=addon:NewTable() if type(list)=='table' then for i=1,#list do @@ -290,11 +302,6 @@ function addon:GetMissionData(missionID,key,default) local good,mc=pcall(self.GetModule,self,"MissionCompletion") if good then mission=mc:GetMission(missionID) ---@debug@ - else - print(missionID,mc) - ---@end-debug@ end if mission then if type(mission.improvedDurationSeconds)~='number' then @@ -304,13 +311,9 @@ function addon:GetMissionData(missionID,key,default) end end if not mission then - mission=G.GetMissionInfo(missionID) - end - if not mission then - ---@debug@ -print("Could not find info for mission",missionID,G.GetMissionName(missionID)) ---@end-debug@ + --@debug@ + print("Could not find info for mission",missionID,G.GetMissionName(missionID)) + --@end-debug@ return default end if (key==nil) then diff --git a/MissionCompletion.lua b/MissionCompletion.lua index 1cff671..a444d57 100644 --- a/MissionCompletion.lua +++ b/MissionCompletion.lua @@ -5,8 +5,10 @@ local shipyard local _G=_G local GMF=GMF local GSF=GSF +local GHF=GHF local GMFMissions=GarrisonMissionFrameMissions local GSFMissions=GarrisonMissionFrameMissions +local GHFMissions=GarrisonMissionFrameMissions local GARRISON_CURRENCY=GARRISON_CURRENCY local GARRISON_SHIP_OIL_CURRENCY=_G.GARRISON_SHIP_OIL_CURRENCY local SEAL_CURRENCY=994 @@ -50,6 +52,8 @@ local cappedCurrencies={ local missions={} local followerType=LE_FOLLOWER_TYPE_GARRISON_6_0 +local missionsFrame +local panel local states={} local rewards={ items={}, @@ -76,9 +80,9 @@ local function startTimer(delay,event,...) --@end-debug@ end function module:MissionsCleanup() - local f=followerType==LE_FOLLOWER_TYPE_GARRISON_6_0 and GMF or GSF - local fmissions=followerType==LE_FOLLOWER_TYPE_GARRISON_6_0 and GMFMissions or GSFMissions - local module=followerType==LE_FOLLOWER_TYPE_GARRISON_6_0 and addon or addon:GetModule("ShipYard") + local f=panel + local fmissions=missionsFrame + local module=followerType==LE_FOLLOWER_TYPE_GARRISON_6_0 and addon or addon:GetModule(LE_FOLLOWER_TYPE_SHIPYARD_6_2 and "ShipYard" or "OrderHall") self:Events(false) stopTimer() f.MissionTab.MissionList.CompleteDialog:Hide() @@ -89,6 +93,7 @@ function module:MissionsCleanup() -- Re-enable "view" button fmissions.CompleteDialog.BorderFrame.ViewButton:SetEnabled(true) module:OpenLastTab() + if panel==GHF then return end f:UpdateMissions() f:CheckCompleteMissions() end @@ -105,16 +110,21 @@ function module:Events(on) end function module:CloseReport() if report then pcall(report.Close,report) report=nil end - if GSF:IsVisible() then + if GSF and GSF:IsVisible() then --@debug@ print "Ship close mission" --@end-debug@ GSF:CloseMissionComplete() - elseif GMF:IsVisible() then + elseif GMF and GMF:IsVisible() then --@debug@ print "Garr close mission" --@end-debug@ GMF:CloseMissionComplete() + elseif GHF and GHF:IsVisible() then + --@debug@ + print "Hall close mission" + --@end-debug@ + GHF:CloseMissionComplete() end addon:OpenMissionsTab() addon:RefreshParties() @@ -125,8 +135,6 @@ function module:MissionComplete(this,button,skiprescheck) missions=G.GetCompleteMissions(followerType) shipyard=addon:GetModule("ShipYard") shipsnumber=shipyard:GetTotFollowers() - local missionsFrame - local panel if followerType == LE_FOLLOWER_TYPE_GARRISON_6_0 then missionsFrame=GMFMissions panel=GMF @@ -134,6 +142,8 @@ function module:MissionComplete(this,button,skiprescheck) missionsFrame=GSFMissions panel=GSF elseif followerType == LE_FOLLOWER_TYPE_GARRISON_7_0 then + GHF=_G.OrderHallMissionFrame + GHFMissions=GHF.MissionTab.MissionList missionsFrame=GHFMissions panel=GHF else @@ -195,7 +205,7 @@ function module:MissionComplete(this,button,skiprescheck) ) return end - report=self:GenerateMissionCompleteList("Missions' results",followerType==LE_FOLLOWER_TYPE_GARRISON_6_0 and GMF or GSF) + report=self:GenerateMissionCompleteList("Missions' results",panel) report:SetUserData('missions',missions) report:SetUserData('current',1) self:Events(true) diff --git a/PartyCache.lua b/PartyCache.lua index c5de57d..3812a16 100644 --- a/PartyCache.lua +++ b/PartyCache.lua @@ -1,4 +1,5 @@ local me,ns=... +local pp=print ns.Configure() local addon=addon --#addon --upvalue @@ -59,11 +60,11 @@ local ID,maxFollowers,members,ignored,threats=0,1,{},{},{} function party:Open(missionID,followers) maxFollowers=followers ID=missionID - local mechanics=G.GetMissionUncounteredMechanics(ID) - if (type(mechanics)=="table") then - for enemy,menaces in pairs(mechanics) do - for i=1,#menaces do - tinsert(threats,format("%d:%d",enemy,menaces[i])) + local enemies=select(8,G.GetMissionInfo(ID)) + if (type(enemies)=="table") then + for enemy,data in pairs(enemies) do + for menace,more in pairs(data.mechanics) do + tinsert(threats,format("%d:%d",enemy,menace)) end end end