changeset 11:bd476e399376

individual boss information for Highmaul, EJ detection version
author ovolkov
date Tue, 03 Feb 2015 10:26:29 +0300
parents 627bb3803132
children 64c9517efa88
files LFGFilter.lua
diffstat 1 files changed, 95 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/LFGFilter.lua	Tue Feb 03 07:41:39 2015 +0300
+++ b/LFGFilter.lua	Tue Feb 03 10:26:29 2015 +0300
@@ -1,5 +1,4 @@
 local dump = DevTools_Dump
-
 LFGListFrame.SearchPanel.SearchBox:SetMaxLetters(2048)
 
 local filter_expression_functions = setmetatable({}, {
@@ -30,6 +29,23 @@
    aliases[class_lc .. "s"] = class_lc
 end
 
+-- EJ_GetCurrentInstance()
+-- EJ_SelectInstance(477)
+-- EJ_GetEncounterInfoByIndex(4)
+
+local token_to_encounter_id = {
+   highmaul = {
+      ej_instance = 477,
+      [1128] = { "kargath", "bladefist", "kargath_bladefist" },
+      [971]  = { "butcher", "the_butcher" },
+      [1195] = { "tectus" },
+      [1196] = { "brackenspore", "bracken" },
+      [1148] = { "twin_orgon", "twins" },
+      [1153] = { "koragh", "breaker" },
+      [1197] = { "imperator", "margok" },
+   }
+}
+
 function LFGListSearchPanel_DoSearch(self)
    local searchText = self.SearchBox:GetText();
    local real_search, filter_expression = searchText:match("^([^=]-)=(.+)$")
@@ -48,6 +64,50 @@
    LFGListSearchPanel_UpdateResults(self);
 end
 
+local localized_encounter_name_to_id = {}
+
+local function InsertEncounterStateAliases(result_env, raid_token, completed_encounters)
+   local encounter_aliases = token_to_encounter_id[raid_token]
+   if not encounter_aliases then return end
+
+   local ej_instance = encounter_aliases.ej_instance
+   local encounter_names = localized_encounter_name_to_id[ej_instance]
+   if not encounter_names then
+      encounter_names = {}
+      EJ_SelectInstance(ej_instance)
+      local encounter_idx = 1
+      local encounter_name, encounter_id, root_section_id, _
+      repeat
+         encounter_name, _, encounter_id, root_section_id = EJ_GetEncounterInfoByIndex(encounter_idx)
+         if encounter_name then
+            encounter_names[encounter_name] = encounter_id
+            local next_section_id = root_section_id
+            repeat
+               local title, description, headerType, abilityIcon, displayInfo, siblingID, _, fileredByDifficulty, link, startsOpen, flag1, flag2, flag3, flag4 = EJ_GetSectionInfo(next_section_id)
+               if displayInfo ~= 0 then
+                  if not encounter_names[title] then encounter_names[title] = encounter_id end
+               end
+               next_section_id = siblingID
+            until not next_section_id
+            encounter_idx = encounter_idx + 1
+         end
+      until not encounter_name
+      localized_encounter_name_to_id[ej_instance] = encounter_names
+   end
+
+   for idx = 1, #completed_encounters do
+      local encounter_id = encounter_names[completed_encounters[idx]]
+      if encounter_id then
+         local aliases = encounter_aliases[encounter_id]
+         if aliases then
+            for alias_idx = 1, #aliases do
+               result_env[aliases[alias_idx]] = true
+            end
+         end
+      end
+   end
+end
+
 local result_env = {}
 -- =highmaul and ((normal and (name:match("imp") or defeated == 6)) or (heroic and defeated == 2))
 function LFGListUtil_SortSearchResults(results)
@@ -86,15 +146,23 @@
             if not count then result_env[class_lc] = 0 end
          end
 
+         local raid_token
          if activityID == 37 then
-            result_env.highmaul = true
+            raid_token = "highmaul"
             result_env.normal = true
          elseif activityID == 38 then
-            result_env.highmaul = true
+            raid_token = "highmaul"
             result_env.heroic = true
+            
          end
 
-          -- dump(result_env)
+         result_env[raid_token] = true
+         if completedEncounters then InsertEncounterStateAliases(result_env, raid_token, completedEncounters) end
+
+         result_env.dead = true
+         result_env.defeated = true
+
+         -- dump(result_env)
 
          for alias, original in pairs(aliases) do result_env[alias] = result_env[original] end
 
@@ -153,4 +221,26 @@
       local id1, activityID1, name1, comment1, voiceChat1, iLvl1, age1, numBNetFriends1, numCharFriends1, numGuildMates1, isDelisted1 = C_LFGList.GetSearchResultInfo(results[idx])
       print(id1, activityID1, C_LFGList.GetActivityInfo(activityID1), '*', name1)
    end
-end
\ No newline at end of file
+end
+
+function LFGPrintInstanceScan(ej_instance)
+   EJ_SelectInstance(ej_instance)
+   local encounter_idx = 1
+   local encounter_name, encounter_id, root_section_id, _
+   repeat
+      encounter_name, _, encounter_id, root_section_id = EJ_GetEncounterInfoByIndex(encounter_idx)
+      if encounter_name then
+         print(encounter_id, encounter_name)
+         local next_section_id = root_section_id
+         repeat
+            local title, description, headerType, abilityIcon, displayInfo, siblingID, _, fileredByDifficulty, link, startsOpen, flag1, flag2, flag3, flag4 = EJ_GetSectionInfo(next_section_id)
+            if displayInfo ~= 0 then
+               print(encounter_id, title)
+            end
+            next_section_id = siblingID
+         until not next_section_id
+         encounter_idx = encounter_idx + 1
+      end
+   until not encounter_name
+   localized_encounter_name_to_id[ej_instance] = encounter_names
+end