стабильная версия encounter journal

This commit is contained in:
2026-05-16 23:43:39 +04:00
parent 255485daca
commit d8d94f10b0
5 changed files with 15271 additions and 26 deletions
@@ -9,14 +9,6 @@ do
local NO_CLASS_FILTER = 0
local NO_SPEC_FILTER = 0
local LJ_ITEMSET_REALM_FLAG = {
[E_REALM_ID.SOULSEEKER] = 0x1,
[E_REALM_ID.SIRUS] = 0x2,
[E_REALM_ID.SCOURGE] = 0x4,
[E_REALM_ID.ALGALON] = 0x8,
[E_REALM_ID.NEVEREST] = 0x10,
}
local function getPlayerFactionID()
local factionGroup = UnitFactionGroup("player") or "NEUTRAL"
if factionGroup == "Renegade" then
@@ -67,9 +59,9 @@ do
function C_LootJournal.GenerateLootData(classFilter, specFilter)
table.wipe(LJ_BUFFER)
local serverID = C_Service.GetRealmID()
local serverID = C_Service and C_Service.GetRealmID and C_Service.GetRealmID() or 0
local playerFactionID = getPlayerFactionID()
local itemSetSourceRealm = EJ_ITEMSET_SOURCE_REALM[serverID]
local itemSetSourceRealm = EJ_ITEMSET_SOURCE_REALM and EJ_ITEMSET_SOURCE_REALM[serverID]
for setIndex, itemSetData in pairs(EJ_ITEMSET_DATA) do
local name, itemlevel, tierName, sourceID, classID, specID, isPVP, itemList, factionID, realmFlag = unpack(itemSetData, 1, 10)
@@ -7,13 +7,55 @@ local function ApplyEncounterJournalData(data)
return
end
local function NormalizeTierInstances(tiers, tierInstances)
if type(tiers) ~= "table" or type(tierInstances) ~= "table" then
return tierInstances
end
local tierIDs = {}
for _, tierInfo in ipairs(tiers) do
if type(tierInfo) == "table" then
tierIDs[tierInfo[1]] = true
end
end
local hasTierKey = false
for tierID in pairs(tierIDs) do
if tierInstances[tierID] then
hasTierKey = true
break
end
end
if not hasTierKey then
return tierInstances
end
local normalized = {}
for tierID, instanceList in pairs(tierInstances) do
if tierIDs[tierID] and type(instanceList) == "table" then
for _, instanceID in ipairs(instanceList) do
normalized[instanceID] = normalized[instanceID] or {}
table.insert(normalized[instanceID], tierID)
end
else
normalized[tierID] = instanceList
end
end
return normalized
end
local tiers = data.JOURNALTIER or data.tiers or JOURNALTIER
local tierInstances = data.JOURNALTIERXINSTANCE or data.tierInstances or JOURNALTIERXINSTANCE
JOURNALINSTANCE = data.JOURNALINSTANCE or data.instances or JOURNALINSTANCE
JOURNALENCOUNTER = data.JOURNALENCOUNTER or data.encounters or JOURNALENCOUNTER
JOURNALENCOUNTERCREATURE = data.JOURNALENCOUNTERCREATURE or data.creatures or JOURNALENCOUNTERCREATURE
JOURNALENCOUNTERITEM = data.JOURNALENCOUNTERITEM or data.items or JOURNALENCOUNTERITEM
JOURNALENCOUNTERSECTION = data.JOURNALENCOUNTERSECTION or data.sections or JOURNALENCOUNTERSECTION
JOURNALTIER = data.JOURNALTIER or data.tiers or JOURNALTIER
JOURNALTIERXINSTANCE = data.JOURNALTIERXINSTANCE or data.tierInstances or JOURNALTIERXINSTANCE
JOURNALTIER = tiers
JOURNALTIERXINSTANCE = NormalizeTierInstances(tiers, tierInstances)
JOURNAACTUALRAIDS = data.JOURNAACTUALRAIDS or data.actualRaids or JOURNAACTUALRAIDS
if C_EncounterJournal and C_EncounterJournal.ReloadData then
@@ -23,6 +65,11 @@ end
MoonWell_ApplyEncounterJournalData = ApplyEncounterJournalData
local staticData = MoonWellEncounterJournalData or EncounterJournalData
if staticData then
ApplyEncounterJournalData(staticData)
end
if AIO then
local Handler = AIO.AddHandlers("MoonWellEncounterJournal", {})
@@ -44,6 +44,7 @@ local NO_INV_TYPE_FILTER = 0
local SEARCH_LIMIT = 500
local JOURNALINSTANCE
local JOURNALENCOUNTER
local JOURNALENCOUNTERCREATURE
local JOURNALENCOUNTERITEM
@@ -503,6 +504,7 @@ end
PRIVATE.ReloadData = function()
do
JOURNALINSTANCE = _G.JOURNALINSTANCE or {}
JOURNALENCOUNTER = _G.JOURNALENCOUNTER or {}
JOURNALENCOUNTERCREATURE = _G.JOURNALENCOUNTERCREATURE or {}
JOURNALENCOUNTERITEM = _G.JOURNALENCOUNTERITEM or {}
@@ -514,6 +516,7 @@ PRIVATE.ReloadData = function()
_G.MoonWell_EncounterJournalTiers = JOURNALTIER
_G.MoonWell_EncounterJournalTierInstances = JOURNALTIERXINSTANCE
_G.JOURNALINSTANCE = nil
_G.JOURNALENCOUNTER = nil
_G.JOURNALENCOUNTERCREATURE = nil
_G.JOURNALENCOUNTERITEM = nil
@@ -705,13 +708,13 @@ function C_EncounterJournal.GetItemSourceDrops(itemID)
if itemDifficultyMask ~= -1 then
if bitband(instanceInfo[INSTANCE_FIELD.FLAGS], INSTANCE_FLAG.RAID) ~= 0 then
for difficultyID, difficultyFlag in ipairs(EJ_DIFFICULT_RAID_FLAGS) do
if bitband(difficultyFlag, itemDifficultyMask) ~= 0 then
if PRIVATE.MatchesDifficultyMask(itemDifficultyMask, difficultyFlag) then
difficulties[#difficulties + 1] = _G["RAID_DIFFICULTY"..difficultyID]
end
end
else
for difficultyID, difficultyFlag in ipairs(EJ_DIFFICULT_PARTY_FLAGS) do
if bitband(difficultyFlag, itemDifficultyMask) ~= 0 then
if PRIVATE.MatchesDifficultyMask(itemDifficultyMask, difficultyFlag) then
difficulties[#difficulties + 1] = _G["PLAYER_DIFFICULTY"..difficultyID]
end
end
@@ -943,6 +946,13 @@ do -- Difficulty
return difficultyMask or 0x1
end
PRIVATE.MatchesDifficultyMask = function(contentDifficultyMask, selectedDifficultyMask)
return contentDifficultyMask == nil
or contentDifficultyMask == 0
or selectedDifficultyMask == -1
or bitband(contentDifficultyMask, selectedDifficultyMask) ~= 0
end
PRIVATE.IsDifficultyAvailable = function(difficultyID, isRaid)
if not isRaid and difficultyID == 3 and not C_MythicPlus.IsMythicPlusActive() then
return false
@@ -959,7 +969,7 @@ do -- Difficulty
if difficultyMask then
for encounterIndex, encounterInfo in ipairs(encounterList) do
local encounterDifficultyMask = encounterInfo[ENCOUNTER_FIELD.DIFFICULTY_MASK]
if difficultyMask == -1 or bitband(encounterDifficultyMask, difficultyMask) ~= 0 then
if PRIVATE.MatchesDifficultyMask(encounterDifficultyMask, difficultyMask) then
return true
end
end
@@ -1018,7 +1028,7 @@ do -- Difficulty
local isRaid = PRIVATE.InstanceIsRaidByID(instanceID)
for difficultyIndex, difficultyInfo in ipairs(EJ_DIFFICULTIES) do
if isRaid == (difficultyInfo.size ~= "5") and bitband(difficultyInfo.difficultyMask, difficultyMask) ~= 0 then
if isRaid == (difficultyInfo.size ~= "5") and PRIVATE.MatchesDifficultyMask(difficultyMask, difficultyInfo.difficultyMask) then
return difficultyInfo.difficultyID
end
end
@@ -1093,12 +1103,12 @@ do -- Instance
end
local encounterList = JOURNALENCOUNTER[instanceID]
if encounterList then
if encounterList and encounterList[1] then
local difficultyMask = PRIVATE.GetDifficultyMask(PRIVATE.SELECTED_DIFFICULTY)
local foundDifficultyMatch = false
for encounterIndex, encounterInfo in ipairs(encounterList) do
local encounterDifficultyMask = encounterInfo[ENCOUNTER_FIELD.DIFFICULTY_MASK]
if difficultyMask == -1 or bitband(encounterDifficultyMask, difficultyMask) ~= 0 then
if PRIVATE.MatchesDifficultyMask(encounterDifficultyMask, difficultyMask) then
foundDifficultyMatch = true
break
end
@@ -1108,7 +1118,7 @@ do -- Instance
if encounterList[1] then
local encounterDifficultyMask = encounterList[1][ENCOUNTER_FIELD.DIFFICULTY_MASK]
for difficultyIndex, difficultyInfo in ipairs(EJ_DIFFICULTIES) do
if bitband(encounterDifficultyMask, difficultyInfo.difficultyMask) ~= 0 then
if PRIVATE.MatchesDifficultyMask(encounterDifficultyMask, difficultyInfo.difficultyMask) then
foundDifficultyMatch = true
PRIVATE.SetDifficulty(difficultyInfo.difficultyID)
break
@@ -1124,6 +1134,9 @@ do -- Instance
PRIVATE.SELECTED_INSTANCE_ID = instanceID
return true
end
PRIVATE.SELECTED_INSTANCE_ID = instanceID
return true
end
PRIVATE.SELECTED_INSTANCE_ID = nil
@@ -1331,7 +1344,7 @@ do -- Encounter
for encounterIndex, encounterInfo in ipairs(encounterList) do
if PRIVATE.CanShowEncounter(encounterInfo)
and (encounterInfo[ENCOUNTER_FIELD.DIFFICULTY_MASK] == -1 or bitband(encounterInfo[ENCOUNTER_FIELD.DIFFICULTY_MASK], difficultyMask) ~= 0)
and PRIVATE.MatchesDifficultyMask(encounterInfo[ENCOUNTER_FIELD.DIFFICULTY_MASK], difficultyMask)
then
tinsert(PRIVATE.ENCOUNTER_BY_INDEX, encounterInfo)
end
@@ -1368,7 +1381,7 @@ do -- Encounter
and PRIVATE.CanShowEncounter(encounterInfo)
and encounterInfo[ENCOUNTER_FIELD.WORLDMAP_AREA_ID] == worldMapAreaID
and encounterInfo[ENCOUNTER_FIELD.FLOOR_INDEX] == mapDungeonLevel
and (encounterInfo[ENCOUNTER_FIELD.DIFFICULTY_MASK] == -1 or bitband(encounterInfo[ENCOUNTER_FIELD.DIFFICULTY_MASK], difficultyMask) ~= 0)
and PRIVATE.MatchesDifficultyMask(encounterInfo[ENCOUNTER_FIELD.DIFFICULTY_MASK], difficultyMask)
then
tinsert(PRIVATE.MAP_ENCOUNTER_BY_INDEX, encounterInfo)
end
@@ -1684,7 +1697,7 @@ do -- Section
if sectionInfo[ENCOUNTER_SECTION_FIELD.DIFFCULTY_MASK] ~= -1 then
local difficultyMask = PRIVATE.GetDifficultyMask(PRIVATE.SELECTED_DIFFICULTY)
if bitband(sectionInfo[ENCOUNTER_SECTION_FIELD.DIFFCULTY_MASK], difficultyMask) == 0 then
if not PRIVATE.MatchesDifficultyMask(sectionInfo[ENCOUNTER_SECTION_FIELD.DIFFCULTY_MASK], difficultyMask) then
filteredByDifficulty = true
end
end
@@ -2024,7 +2037,7 @@ do -- Loot
local factionMask = itemInfo[ENCOUNTER_ITEM_FIELD.FACTION_MASK]
if factionMask == -1 or factionMask == PRIVATE.PLAYER_FACTION_GROUP_MASK then
local difficultyMask = itemInfo[ENCOUNTER_ITEM_FIELD.DIFFICULTY_MASK]
if (difficultyMask == -1 or bitband(difficultyMask, currentDiffMask) ~= 0) then
if PRIVATE.MatchesDifficultyMask(difficultyMask, currentDiffMask) then
if intTypeFilter == NO_INV_TYPE_FILTER or PRIVATE.IsItemAllowedBySlotFilter(itemInfo.equipSlot, intTypeFilter) then
local itemClassMask = itemInfo[ENCOUNTER_ITEM_FIELD.CLASS_MASK]
if classFilter == NO_CLASS_FILTER or itemClassMask == -1 or bitband(itemClassMask, classFlag) ~= 0 then
@@ -2079,7 +2092,7 @@ do -- Loot
if difficultyMask ~= -1 then
for i = #EJ_DIFFICULTIES, 1, -1 do
local diffInfo = EJ_DIFFICULTIES[i]
if bitband(difficultyMask, diffInfo.difficultyMask) ~= 0 then
if PRIVATE.MatchesDifficultyMask(difficultyMask, diffInfo.difficultyMask) then
difficultyID = diffInfo.difficultyID
break
end
@@ -16,8 +16,8 @@ EncounterJournal\EncounterJournalCompat.lua
EncounterJournal\SharedXML\Pools.lua
EncounterJournal\SharedXML\TableUtil.lua
EncounterJournal\SharedXML\SoundKitConstants.lua
EncounterJournal\Generated_EncounterJournalData.lua
EncounterJournal\EncounterJournalData.lua
EncounterJournal\Generated_EncounterJournal.lua
EncounterJournal\EncounterJournalTierFilter.lua
EncounterJournal\EncounterJournalTierSnapshot.lua
EncounterJournal\GlobalStrings.lua