Module:ElementAchievementHeader: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
--[[  
--[[
* Module:ElementAchievementHeader
* Name: ElementAchievementHeader
* Renders the achievement header for person templates
* Author: Mark W. Datysgeld
* Displays title achievements with special styling
* Description: Element module that renders achievement headers for Person templates and handles all title-type achievements
*
* Notes: Creates blocks for Blueprint framework; loads achievement data using AchievementSystem; filters for title-type achievements; renders with animated backgrounds using two-layer approach for readability; includes phantom row when no achievements found; protected execution with error handling
* Integrates with Blueprint template system.
]]
]]


local p = {}
local p = {}
Line 34: Line 33:
             end
             end
              
              
             -- CRITICAL: We must pre-load the JSON data with the frame before getting any achievements
             -- CRITICAL: WE MUST PRE-LOAD THE JSON DATA WITH THE FRAME BEFORE GETTING ANY ACHIEVEMENTS
            -- This is how LuaTemplatePerson.lua ensures the JSON is loaded correctly
             pcall(function()
             pcall(function()
                 Achievements.loadData(frame)
                 Achievements.loadData(frame)
Line 42: Line 40:
              
              
             -- Now get the title achievement
             -- Now get the title achievement
             local achievementId, displayName, achievementId2 = Achievements.getTitleAchievement(pageId, frame)
             local titleAchievement = Achievements.getTitleAchievement(pageId, frame)
              
              
             -- Minimal debug comment only visible in source
             -- Minimal debug comment only visible in source
Line 51: Line 49:
              
              
             -- Always create a row for debugging purposes
             -- Always create a row for debugging purposes
             if achievementId ~= "" and displayName ~= "" and achievementId2 ~= "" then
             if titleAchievement then
                 -- Achievement found - create populated row with achievement data
                -- Get category link from the centralized function
                local categoryLink = Achievements.getCategoryLinks({ { type = titleAchievement.id } }, frame)
 
                 -- Achievement found: create populated row with achievement data
                 return string.format(
                 return string.format(
                     '|-\n! colspan="2" class="achievement-header %s" data-achievement-id="%s" data-achievement-name="%s" | ' ..
                     '|-\n! colspan="2" class="achievement-header %s" data-achievement-id="%s" data-achievement-name="%s" | ' ..
                     '<div class="achievement-foreground-layer">%s</div>%s',
                     '<div class="achievement-foreground-layer">%s</div>%s%s',
                     achievementId, achievementId, displayName, displayName, debugInfo
                     titleAchievement.id, titleAchievement.id, titleAchievement.name, titleAchievement.name, debugInfo, categoryLink
                 )
                 )
             else
             else
                 -- No achievement found - create empty phantom row
                 -- No achievement found: create empty phantom row
                 return string.format(
                 return string.format(
                     '|-\n! colspan="2" class="achievement-header-phantom" | ' ..
                     '|-\n! colspan="2" class="achievement-header-phantom" | ' ..