Module:AchievementSystem: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 544: Line 544:
     local data = Achievements.loadData()
     local data = Achievements.loadData()
     debugLog("Looking up title achievements for ID: " .. tostring(pageId))
     debugLog("Looking up title achievements for ID: " .. tostring(pageId))
   
    -- Debug log all achievements for this user
    for i, achievement in ipairs(userAchievements) do
        local achType = achievement.type or "nil"
        debugLog("Achievement " .. i .. ": type=" .. achType)
    end
      
      
     -- Build a table of achievement definitions for quick lookup
     -- Build a table of achievement definitions for quick lookup
Line 549: Line 555:
     for _, typeData in ipairs(data.achievement_types) do
     for _, typeData in ipairs(data.achievement_types) do
         typeDefinitions[typeData.id] = typeData
         typeDefinitions[typeData.id] = typeData
        -- Debug log all achievement definitions
        debugLog("Definition: id=" .. typeData.id ..
                ", name=" .. (typeData.name or "nil") ..
                ", type=" .. (typeData.type or "nil"))
     end
     end


Line 562: Line 572:
                 -- Check if it's a title type by examining "type" property
                 -- Check if it's a title type by examining "type" property
                 local achDefType = typeData.type
                 local achDefType = typeData.type
               
                debugLog("Checking achievement " .. i .. ": type=" .. achType ..
                        ", definition type=" .. (achDefType or "nil"))
                  
                  
                 -- Only consider achievements with type="title"
                 -- Only consider achievements with type="title"
Line 573: Line 586:
                     end
                     end
                 end
                 end
            else
                debugLog("No definition found for achievement type: " .. achType)
             end
             end
         end
         end
Line 582: Line 597:
     end
     end


     local cssClass = "achievement-" .. titleAchievement.id
     -- Return the ID directly (e.g., "title-developer") instead of "achievement-title-developer"
    -- This matches the CSS class structure in Achievements.css
     local displayName = titleAchievement.name or titleAchievement.id or "Award"
     local displayName = titleAchievement.name or titleAchievement.id or "Award"
     local achievementId = titleAchievement.id
     local achievementId = titleAchievement.id
      
      
     debugLog("Using title achievement: " .. cssClass .. " with name: " .. displayName)
     debugLog("Using title achievement ID: " .. achievementId .. " with name: " .. displayName)
      
      
     return cssClass, displayName, achievementId
     return achievementId, displayName, achievementId
end
end