Module:AchievementSystem: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 1: Line 1:
-- Module:AchievementSystem
-- Module:AchievementSystem
-- Achievement system that loads data from MediaWiki:AchievementData.json.
-- Loads data from MediaWiki:AchievementData.json
-- STYLING NOTE: All achievement styling is defined in CSS/Templates.css, not in the JSON.
-- All achievement styling is defined in CSS/Templates.css, not in the JSON. This module only assigns CSS classes based on achievement IDs in the format:
-- This module only assigns CSS classes based on achievement IDs in the format:
-- .person-template .template-title.achievement-{id}::after {}
--   .person-template .template-title.achievement-{id}::after {}
--
-- The module does not use any styling information from the JSON data structure.


local Achievements = {}
local Achievements = {}
Line 47: Line 44:
end
end


-- We'll use MediaWiki's built-in JSON functions directly, no external module needed
-- Use MediaWiki's built-in JSON functions directly
local function jsonDecode(jsonString)
local function jsonDecode(jsonString)
     if not jsonString then return nil end
     if not jsonString then return nil end
Line 81: Line 78:
-- Configuration, Default Data, and Cache
-- Configuration, Default Data, and Cache
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local ACHIEVEMENT_DATA_PAGE = 'MediaWiki:AchievementData.json'
local ACHIEVEMENT_DATA_PAGE = 'MediaWiki:AchievementData.json'
local dataCache = nil
local dataCache = nil
Line 172: Line 168:
             end
             end
         end
         end
       
         -- As an absolute last resort, use local default data
         -- As absolute last resort, use local default data
         return DEFAULT_DATA
         return DEFAULT_DATA
     end)
     end)