Module:AchievementSystem: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 613: Line 613:
         debugLog("No achievements under ID '" .. key .. "', trying alternative ID: '" .. altKey .. "'")
         debugLog("No achievements under ID '" .. key .. "', trying alternative ID: '" .. altKey .. "'")
         userAchievements = data.user_achievements[altKey] or {}
         userAchievements = data.user_achievements[altKey] or {}
    end
    -- Special case for test page ID 18451
    if key == "18451" then
        mw.log("TITLE-ACHIEVEMENT-DEBUG: Processing test page 18451")
     end
     end


Line 618: Line 623:
     if #userAchievements > 0 then
     if #userAchievements > 0 then
         debugLog("Found " .. #userAchievements .. " achievements for user " .. key)
         debugLog("Found " .. #userAchievements .. " achievements for user " .. key)
       
        -- Log each achievement for the test page
        if key == "18451" then
            for i, ach in ipairs(userAchievements) do
                mw.log("TITLE-ACHIEVEMENT-DEBUG: Test page achievement " .. i .. " type=" .. (ach.type or "nil"))
            end
        end
     else
     else
         debugLog("No achievements found for user " .. key)
         debugLog("No achievements found for user " .. key)
Line 627: Line 639:
     for _, typeData in ipairs(data.achievement_types) do
     for _, typeData in ipairs(data.achievement_types) do
         typeDefinitions[typeData.id] = typeData
         typeDefinitions[typeData.id] = typeData
       
        -- Log definitions for test page
        if key == "18451" then
            mw.log("TITLE-ACHIEVEMENT-DEBUG: Definition [" .. typeData.id .. "]: type=" ..
                  (typeData.type or "nil") .. ", name=" .. (typeData.name or "nil"))
        end
     end
     end


Line 633: Line 651:
     local titleAchievement = nil
     local titleAchievement = nil


     for _, achievement in ipairs(userAchievements) do
     for i, achievement in ipairs(userAchievements) do
         local achType = achievement.type
         local achType = achievement.type
         if achType then
         if achType then
             local typeData = typeDefinitions[achType]
             local typeData = typeDefinitions[achType]
             if typeData then
             if typeData then
                -- Check if it's a title type
                local achDefType = typeData.type
               
                -- Log processing details for test page
                if key == "18451" then
                    mw.log("TITLE-ACHIEVEMENT-DEBUG: Checking achievement " .. i .. ": type=" .. achType ..
                          ", definition type=" .. (achDefType or "nil"))
                end
               
                 -- Only consider achievements with type="title"
                 -- Only consider achievements with type="title"
                 if typeData.type == "title" then
                 if achDefType == "title" then
                     debugLog("Found title achievement: " .. achType)
                     debugLog("Found title achievement: " .. achType)
                     local tier = typeData.tier or 999
                     local tier = typeData.tier or 999