Module:AchievementSystem: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 450: Line 450:
                 if key == "18451" or key == 18451 then
                 if key == "18451" or key == 18451 then
                     debugLog("EMERGENCY OVERRIDE TRIGGERED for 18451")
                     debugLog("EMERGENCY OVERRIDE TRIGGERED for 18451")
                     -- Force injection, bypassing all checks
                     -- Force injection of fake achievement
                     userAchievements = {
                     userAchievements = {
                         {
                         {
Line 464: Line 464:
                     debugLog("  - Number of achievements after override: " .. #userAchievements)
                     debugLog("  - Number of achievements after override: " .. #userAchievements)
                     debugLog("  - First achievement type: " .. userAchievements[1].type)
                     debugLog("  - First achievement type: " .. userAchievements[1].type)
                     debugLog("  - Will check if this type exists in achievement_types next")
                      
                    -- Also inject the type definition if needed
                    -- This ensures we have a complete achievement type to return
                    local typeFound = false
                    for _, typeData in ipairs(data.achievement_types or {}) do
                        if typeData.id == "jedi" then
                            typeFound = true
                            debugLog("  - Found existing 'jedi' type in achievement_types")
                            break
                        end
                    end
                   
                    if not typeFound then
                        debugLog("  - 'jedi' type not found in achievement_types, injecting it")
                        -- Create a minimal achievement_types array if it doesn't exist
                        if not data.achievement_types then
                            data.achievement_types = {}
                            debugLog("  - Created empty achievement_types array")
                        end
                       
                        -- Insert a fake Jedi achievement type
                        table.insert(data.achievement_types, {
                            id = "jedi",
                            name = "Jedi",
                            description = "Emergency debug achievement (force-injected)",
                            tier = 1,  -- Top tier for priority
                            display = {
                                icon = "⚔️",
                                color = "#000000",
                                background = "#ffd700"
                            }
                        })
                        debugLog("  - Successfully injected 'jedi' type definition")
                    end
                 else
                 else
                     -- Last resort - dump all data for inspection
                     -- Last resort - dump all data for inspection