Module:RaceData: Difference between revisions

From MB Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 18: Line 18:
         category = "Banished",
         category = "Banished",
         subrace = "Frog",
         subrace = "Frog",
         color = "#F44336"
         color = "#F44336",
        description = "Frog-like banished creatures with amphibious abilities."
     },
     },
      
      
Line 24: Line 25:
         displayName = "Human",
         displayName = "Human",
         category = "Standard",
         category = "Standard",
         color = "#4CAF50"
         color = "#4CAF50",
        description = "Standard human race with versatile capabilities."
     },
     },
      
      
Line 31: Line 33:
         category = "Banished",
         category = "Banished",
         subrace = "Armor Spirit",
         subrace = "Armor Spirit",
         color = "#F44336"
         color = "#F44336",
        description = "Spiritual beings bound to armor, cast out from their realm."
     },
     },
      
      
Line 38: Line 41:
         category = "Minx",
         category = "Minx",
         subrace = "Dragon-kin",
         subrace = "Dragon-kin",
         color = "#FF9800"
         color = "#FF9800",
        description = "Dragon-blooded minx with draconic features."
     },
     },
      
      
Line 44: Line 48:
         displayName = "Mortal",
         displayName = "Mortal",
         category = "Standard",
         category = "Standard",
         color = "#4CAF50"
         color = "#4CAF50",
        description = "Mortal beings with finite lifespans and diverse backgrounds."
     },
     },
      
      
Line 51: Line 56:
         category = "Minx",
         category = "Minx",
         subrace = "Base",
         subrace = "Base",
         color = "#FF9800"
         color = "#FF9800",
        description = "Base minx race with feline characteristics."
     },
     },
      
      
Line 57: Line 63:
         displayName = "Elf",
         displayName = "Elf",
         category = "Elven",
         category = "Elven",
         color = "#9C27B0"
         color = "#9C27B0",
        description = "Elegant, long-lived beings with affinity for nature and magic."
     },
     },
      
      
Line 64: Line 71:
         category = "Banished",
         category = "Banished",
         subrace = "Giant",
         subrace = "Giant",
         color = "#F44336"
         color = "#F44336",
        description = "Gigantic banished beings with immense strength."
     },
     },
      
      
Line 71: Line 79:
         category = "Minx",
         category = "Minx",
         subrace = "Tiger",
         subrace = "Tiger",
         color = "#FF9800"
         color = "#FF9800",
        description = "Tiger-striped minx with predatory instincts."
     },
     },
      
      
Line 78: Line 87:
         category = "Minx",
         category = "Minx",
         subrace = "Moon Cat",
         subrace = "Moon Cat",
         color = "#FF9800"
         color = "#FF9800",
        description = "Lunar-aligned minx with mystical abilities."
     },
     },
      
      
Line 85: Line 95:
         category = "Hybrid",
         category = "Hybrid",
         subrace = "Minx-Giant",
         subrace = "Minx-Giant",
         color = "#FF5722"
         color = "#FF5722",
        description = "Hybrid of Minx and Giant characteristics."
     },
     },
      
      
Line 92: Line 103:
         category = "Hybrid",
         category = "Hybrid",
         subrace = "Mortal-Vampire",
         subrace = "Mortal-Vampire",
         color = "#FF5722"
         color = "#FF5722",
        description = "Hybrid beings with both mortal and vampiric traits."
     },
     },
      
      
Line 99: Line 111:
         category = "Minx",
         category = "Minx",
         subrace = "Fox",
         subrace = "Fox",
         color = "#FF9800"
         color = "#FF9800",
        description = "Fox-like minx with cunning and agility."
     },
     },
      
      
Line 106: Line 119:
         category = "Demonic",
         category = "Demonic",
         subrace = "Gothic",
         subrace = "Gothic",
         color = "#9C27B0"
         color = "#9C27B0",
        description = "Dark, gothic-themed demonic beings."
     },
     },
      
      
Line 112: Line 126:
         displayName = "Felinyan",
         displayName = "Felinyan",
         category = "Feline",
         category = "Feline",
         color = "#795548"
         color = "#795548",
        description = "Feline humanoids with graceful movements."
     },
     },
      
      
Line 118: Line 133:
         displayName = "Dwarf",
         displayName = "Dwarf",
         category = "Dwarven",
         category = "Dwarven",
         color = "#607D8B"
         color = "#607D8B",
        description = "Stout, sturdy beings skilled in craftsmanship."
     },
     },
      
      
Line 124: Line 140:
         displayName = "Banished",
         displayName = "Banished",
         category = "Banished",
         category = "Banished",
         color = "#F44336"
         color = "#F44336",
        description = "Beings cast out from their original realms."
     },
     },
      
      
Line 130: Line 147:
         displayName = "Demonkind",
         displayName = "Demonkind",
         category = "Demonic",
         category = "Demonic",
         color = "#9C27B0"
         color = "#9C27B0",
        description = "Demonic beings with infernal powers."
     },
     },
      
      
Line 137: Line 155:
         category = "Aquatic",
         category = "Aquatic",
         subrace = "Moon Priestess",
         subrace = "Moon Priestess",
         color = "#2196F3"
         color = "#2196F3",
        description = "Aquatic beings with enchanting voices and lunar connections."
     }
     }
}
}
Line 143: Line 162:
-- Helper function to get light color variant
-- Helper function to get light color variant
function p.getLightColor(hexColor)
function p.getLightColor(hexColor)
    if not hexColor or hexColor:len() ~= 7 then
        return "#F8F9FA"
    end
   
     -- Convert hex to RGB
     -- Convert hex to RGB
     local r = tonumber(hexColor:sub(2, 3), 16)
     local r = tonumber(hexColor:sub(2, 3), 16)
     local g = tonumber(hexColor:sub(4, 5), 16)
     local g = tonumber(hexColor:sub(4, 5), 16)
     local b = tonumber(hexColor:sub(6, 7), 16)
     local b = tonumber(hexColor:sub(6, 7), 16)
   
    if not r or not g or not b then
        return "#F8F9FA"
    end
      
      
     -- Lighten by mixing with white (80% white, 20% original)
     -- Lighten by mixing with white (80% white, 20% original)
Line 159: Line 186:
function p.darkenColor(hexColor, percent)
function p.darkenColor(hexColor, percent)
     percent = percent or 20
     percent = percent or 20
   
    if not hexColor or hexColor:len() ~= 7 then
        return "#333333"
    end
   
     local r = tonumber(hexColor:sub(2, 3), 16)
     local r = tonumber(hexColor:sub(2, 3), 16)
     local g = tonumber(hexColor:sub(4, 5), 16)
     local g = tonumber(hexColor:sub(4, 5), 16)
     local b = tonumber(hexColor:sub(6, 7), 16)
     local b = tonumber(hexColor:sub(6, 7), 16)
   
    if not r or not g or not b then
        return "#333333"
    end
      
      
     r = math.floor(r * (100 - percent) / 100)
     r = math.floor(r * (100 - percent) / 100)
Line 187: Line 223:
end
end


-- Function to get race infobox with color coding (permanent display)
-- Function to get race info with hover infobox (for Template:RaceInfo) - UPDATED
function p.getRaceInfobox(frame)
function p.getRaceInfo(frame)
     local raceName = frame.args[1] or mw.text.trim(frame:getParent().args[1] or "")
     local raceName = frame.args[1] or mw.text.trim(frame:getParent().args[1] or "")
      
      
     if raceName == "" then
     if raceName == "" then
         return "Error: No race name provided"
         return "<span class='race-error'>Unknown Race</span>[[Category:Unknown Race]]"
     end
     end
      
      
Line 198: Line 234:
      
      
     if not race then
     if not race then
         return "Error: Race '" .. raceName .. "' not found"
         return "<span class='race-error'>Race Not Found</span>[[Category:Unknown Race]]"
     end
     end
      
      
     local color = race.color or categoryColors[race.category] or "#666666"
     local color = race.color or categoryColors[race.category] or "#666666"
     local lightColor = p.getLightColor(color)
     local lightColor = p.getLightColor(color)
    local darkColor = p.darkenColor(color, 20)
      
      
     local output = ""
     local output = ""
      
      
     output = output .. '<div class="race-mini-infobox" style="border-color: ' .. color .. ';">\n'
    -- Create hover container
     output = output .. '<div class="race-header" style="background: linear-gradient(135deg, ' .. color .. ' 0%, ' .. p.darkenColor(color, 20) .. ' 100%);">\n'
     output = output .. '<div class="race-hover-container">\n'
     output = output .. '<h3>Race Information</h3>\n'
   
    -- The clickable race link - goes to race page
    output = output .. '<span class="race-hover-trigger">\n'
    output = output .. '<a href="/wiki/' .. mw.uri.encode(race.displayName) .. ' (Race)" class="race-link-inline" style="color: ' .. color .. ';">\n'
    output = output .. race.displayName .. '\n'
    output = output .. '</a>\n'
    output = output .. '</span>\n'
   
    -- The hidden infobox that appears on hover
    output = output .. '<div class="race-hover-infobox" style="border-color: ' .. color .. ';">\n'
     output = output .. '<div class="race-hover-header" style="background: linear-gradient(135deg, ' .. color .. ' 0%, ' .. darkColor .. ' 100%);">\n'
     output = output .. '<h4>' .. race.displayName .. '</h4>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '<div class="race-content" style="background-color: ' .. lightColor .. ';">\n'
     output = output .. '<div class="race-hover-content" style="background-color: ' .. lightColor .. ';">\n'
    output = output .. '<div class="race-badge" style="background-color: ' .. color .. ';">' .. race.category .. '</div>\n'
     output = output .. '<table class="race-hover-table">\n'
     output = output .. '<table class="race-info-table">\n'
     output = output .. '<tr><td><strong>Category:</strong></td><td><span class="category-badge-small" style="background-color: ' .. color .. ';">' .. race.category .. '</span></td></tr>\n'
    output = output .. '<tr><td><strong>Race:</strong></td><td>' .. race.displayName .. '</td></tr>\n'
     output = output .. '<tr><td><strong>Category:</strong></td><td><span class="category-tag" style="background-color: ' .. color .. ';">' .. race.category .. '</span></td></tr>\n'
      
      
     if race.subrace then
     if race.subrace then
         output = output .. '<tr><td><strong>Subrace:</strong></td><td>' .. race.subrace .. '</td></tr>\n'
         output = output .. '<tr><td><strong>Subrace:</strong></td><td>' .. race.subrace .. '</td></tr>\n'
    end
   
    if race.description then
        output = output .. '<tr><td colspan="2" style="padding-top: 10px; font-size: 0.9em; line-height: 1.4; color: #555;">' .. race.description .. '</td></tr>\n'
     end
     end
      
      
     output = output .. '</table>\n'
     output = output .. '</table>\n'
     output = output .. '<div class="race-footer">\n'
     output = output .. '<div class="race-hover-footer">\n'
     output = output .. '<a href="/wiki/' .. race.displayName .. ' (Race)" class="race-link">View Full Race Page</a>\n'
     output = output .. '<a href="/wiki/' .. mw.uri.encode(race.displayName) .. ' (Race)" class="view-full-link" style="background-color: ' .. color .. ';">View Full Race Page</a>\n'
    output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
      
      
    return output
     -- Add category for character
end
 
-- Function to get race link with colored badge
function p.getRaceLink(frame)
    local raceName = frame.args[1] or mw.text.trim(frame:getParent().args[1] or "")
   
    if raceName == "" then
        return "[[Category:Unknown Race]]"
    end
   
    local race = raceData[raceName]
   
    if not race then
        return "[[Category:Unknown Race]]"
    end
   
    local color = race.color or categoryColors[race.category] or "#666666"
   
    local output = ""
   
    -- Create colored badge link
    output = output .. '<span class="race-link-badge">'
    output = output .. '<a href="/wiki/' .. race.displayName .. ' (Race)" class="race-link" style="background-color: ' .. color .. ';">'
    output = output .. race.displayName
    output = output .. '</a>'
    output = output .. '</span>'
   
     -- Add category
     output = output .. "\n[[Category:" .. race.category .. " Characters]]"
     output = output .. "\n[[Category:" .. race.category .. " Characters]]"
    output = output .. "\n[[Category:" .. race.displayName .. " Characters]]"
      
      
     return output
     return output
end
end


-- Function to get race info with hover infobox (for Template:RaceInfo)
-- Function to get race infobox for race pages
function p.getRaceInfo(frame)
function p.getRaceInfobox(frame)
     local raceName = frame.args[1] or mw.text.trim(frame:getParent().args[1] or "")
     local raceName = frame.args[1] or mw.text.trim(frame:getParent().args[1] or "")
      
      
     if raceName == "" then
     if raceName == "" then
         return "[[Category:Unknown Race]]"
         return "Error: No race name provided"
     end
     end
      
      
Line 272: Line 296:
      
      
     if not race then
     if not race then
         return "[[Category:Unknown Race]]"
         return "Error: Race '" .. raceName .. "' not found"
     end
     end
      
      
     local color = race.color or categoryColors[race.category] or "#666666"
     local color = race.color or categoryColors[race.category] or "#666666"
    local lightColor = p.getLightColor(color)
    local darkColor = p.darkenColor(color, 20)
      
      
     local output = ""
     local output = ""
      
      
    -- Create hover container
     output = output .. '<div class="race-full-infobox" style="border-color: ' .. color .. ';">\n'
     output = output .. '<div class="race-hover-container">\n'
     output = output .. '<div class="race-full-header" style="background: linear-gradient(135deg, ' .. color .. ' 0%, ' .. darkColor .. ' 100%);">\n'
   
     output = output .. '<h2>Race Information</h2>\n'
    -- The clickable race link
    output = output .. '<span class="race-hover-trigger" style="color: ' .. color .. ';">\n'
    output = output .. '[[' .. race.displayName .. ' (Race)|' .. race.displayName .. ']]\n'
    output = output .. '</span>\n'
   
    -- The hidden infobox that appears on hover
    output = output .. '<div class="race-hover-infobox" style="border-color: ' .. color .. ';">\n'
     output = output .. '<div class="race-hover-header" style="background: linear-gradient(135deg, ' .. color .. ' 0%, ' .. p.darkenColor(color, 20) .. ' 100%);">\n'
     output = output .. '<h4>' .. race.displayName .. '</h4>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '<div class="race-hover-content">\n'
     output = output .. '<div class="race-full-content" style="background-color: ' .. lightColor .. ';">\n'
     output = output .. '<table class="race-hover-table">\n'
    output = output .. '<div class="race-badge-large" style="background-color: ' .. color .. ';">' .. race.category .. '</div>\n'
     output = output .. '<tr><td><strong>Category:</strong></td><td>' .. race.category .. '</td></tr>\n'
     output = output .. '<table class="race-full-table">\n'
    output = output .. '<tr><td><strong>Race Name:</strong></td><td>' .. race.displayName .. '</td></tr>\n'
     output = output .. '<tr><td><strong>Category:</strong></td><td><span class="category-tag-large" style="background-color: ' .. color .. ';">' .. race.category .. '</span></td></tr>\n'
      
      
     if race.subrace then
     if race.subrace then
         output = output .. '<tr><td><strong>Subrace:</strong></td><td>' .. race.subrace .. '</td></tr>\n'
         output = output .. '<tr><td><strong>Subrace:</strong></td><td>' .. race.subrace .. '</td></tr>\n'
    end
   
    if race.description then
        output = output .. '<tr><td><strong>Description:</strong></td><td>' .. race.description .. '</td></tr>\n'
     end
     end
      
      
     output = output .. '</table>\n'
     output = output .. '</table>\n'
     output = output .. '<div class="race-hover-footer">\n'
     output = output .. '<div class="race-characters-section">\n'
     output = output .. '<small>Click race name for full page</small>\n'
     output = output .. '<h3>Characters of this Race</h3>\n'
    output = output .. '<div class="category-list">\n'
    output = output .. '{{#categorytree:' .. race.displayName .. ' Characters|depth=1|mode=pages}}\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
     output = output .. '</div>\n'
   
    -- Add category
    output = output .. "\n[[Category:" .. race.category .. " Characters]]"
      
      
     return output
     return output
end
end


-- Function to get colored category list
-- Function to get all races in a category
function p.getColoredCategories()
function p.getRaceCategory(frame)
     local output = "== Race Categories ==\n"
    local category = frame.args[1] or mw.text.trim(frame:getParent().args[1] or "")
   
    if category == "" then
        return "Error: No category specified"
    end
   
     local output = "== " .. category .. " Races ==\n\n"
    local found = false
      
      
    -- Group races by category
     for raceName, race in pairs(raceData) do
    local categories = {}
         if race.category == category then
     for _, race in pairs(raceData) do
             found = true
         if not categories[race.category] then
            local color = race.color or categoryColors[race.category] or "#666666"
             categories[race.category] = {
            output = output .. '=== <span style="color: ' .. color .. ';">' .. race.displayName .. '</span> ===\n'
                color = race.color or categoryColors[race.category] or "#666666",
            output = output .. '* [[' .. race.displayName .. ' (Race)|View Race Page]]\n'
                races = {}
             output = output .. '* [[:Category:' .. race.displayName .. ' Characters|View ' .. race.displayName .. ' Characters]]\n\n'
             }
         end
         end
        table.insert(categories[race.category].races, race.displayName)
     end
     end
      
      
     -- Display each category
     if not found then
    for categoryName, categoryData in pairs(categories) do
         return "Error: Category '" .. category .. "' not found or has no races"
         output = output .. '\n=== <span style="color: ' .. categoryData.color .. ';">' .. categoryName .. '</span> ===\n'
        table.sort(categoryData.races)
        for _, raceName in ipairs(categoryData.races) do
            output = output .. '* [[' .. raceName .. ' (Race)|' .. raceName .. ']]\n'
        end
     end
     end
      
      

Revision as of 09:29, 21 January 2026

Documentation for this module may be created at Module:RaceData/doc

local p = {}

local categoryColors = {
    ["Standard"] = "#4CAF50",      
    ["Elven"] = "#9C27B0",         
    ["Minx"] = "#FF9800",          
    ["Feline"] = "#795548",        
    ["Dwarven"] = "#607D8B",       
    ["Banished"] = "#F44336",      
    ["Demonic"] = "#9C27B0",       
    ["Aquatic"] = "#2196F3",       
    ["Hybrid"] = "#FF5722",        
}

local raceData = {
    ["Banished (Frog)"] = {
        displayName = "Banished (Frog)",
        category = "Banished",
        subrace = "Frog",
        color = "#F44336",
        description = "Frog-like banished creatures with amphibious abilities."
    },
    
    ["Human"] = {
        displayName = "Human",
        category = "Standard",
        color = "#4CAF50",
        description = "Standard human race with versatile capabilities."
    },
    
    ["Banished (Armor Spirit)"] = {
        displayName = "Banished (Armor Spirit)",
        category = "Banished",
        subrace = "Armor Spirit",
        color = "#F44336",
        description = "Spiritual beings bound to armor, cast out from their realm."
    },
    
    ["Minx (Dragon-kin)"] = {
        displayName = "Minx (Dragon-kin)",
        category = "Minx",
        subrace = "Dragon-kin",
        color = "#FF9800",
        description = "Dragon-blooded minx with draconic features."
    },
    
    ["Mortal"] = {
        displayName = "Mortal",
        category = "Standard",
        color = "#4CAF50",
        description = "Mortal beings with finite lifespans and diverse backgrounds."
    },
    
    ["Minx"] = {
        displayName = "Minx",
        category = "Minx",
        subrace = "Base",
        color = "#FF9800",
        description = "Base minx race with feline characteristics."
    },
    
    ["Elf"] = {
        displayName = "Elf",
        category = "Elven",
        color = "#9C27B0",
        description = "Elegant, long-lived beings with affinity for nature and magic."
    },
    
    ["Banished (Giant)"] = {
        displayName = "Banished (Giant)",
        category = "Banished",
        subrace = "Giant",
        color = "#F44336",
        description = "Gigantic banished beings with immense strength."
    },
    
    ["Minx (Tiger)"] = {
        displayName = "Minx (Tiger)",
        category = "Minx",
        subrace = "Tiger",
        color = "#FF9800",
        description = "Tiger-striped minx with predatory instincts."
    },
    
    ["Minx (Moon Cat)"] = {
        displayName = "Minx (Moon Cat)",
        category = "Minx",
        subrace = "Moon Cat",
        color = "#FF9800",
        description = "Lunar-aligned minx with mystical abilities."
    },
    
    ["Minx-Giant"] = {
        displayName = "Minx-Giant",
        category = "Hybrid",
        subrace = "Minx-Giant",
        color = "#FF5722",
        description = "Hybrid of Minx and Giant characteristics."
    },
    
    ["Mortal/Vampire"] = {
        displayName = "Mortal/Vampire",
        category = "Hybrid",
        subrace = "Mortal-Vampire",
        color = "#FF5722",
        description = "Hybrid beings with both mortal and vampiric traits."
    },
    
    ["Fox Minx"] = {
        displayName = "Fox Minx",
        category = "Minx",
        subrace = "Fox",
        color = "#FF9800",
        description = "Fox-like minx with cunning and agility."
    },
    
    ["Gothic Demon"] = {
        displayName = "Gothic Demon",
        category = "Demonic",
        subrace = "Gothic",
        color = "#9C27B0",
        description = "Dark, gothic-themed demonic beings."
    },
    
    ["Felinyan"] = {
        displayName = "Felinyan",
        category = "Feline",
        color = "#795548",
        description = "Feline humanoids with graceful movements."
    },
    
    ["Dwarf"] = {
        displayName = "Dwarf",
        category = "Dwarven",
        color = "#607D8B",
        description = "Stout, sturdy beings skilled in craftsmanship."
    },
    
    ["Banished"] = {
        displayName = "Banished",
        category = "Banished",
        color = "#F44336",
        description = "Beings cast out from their original realms."
    },
    
    ["Demonkind"] = {
        displayName = "Demonkind",
        category = "Demonic",
        color = "#9C27B0",
        description = "Demonic beings with infernal powers."
    },
    
    ["Siren"] = {
        displayName = "Siren",
        category = "Aquatic",
        subrace = "Moon Priestess",
        color = "#2196F3",
        description = "Aquatic beings with enchanting voices and lunar connections."
    }
}

-- Helper function to get light color variant
function p.getLightColor(hexColor)
    if not hexColor or hexColor:len() ~= 7 then
        return "#F8F9FA"
    end
    
    -- Convert hex to RGB
    local r = tonumber(hexColor:sub(2, 3), 16)
    local g = tonumber(hexColor:sub(4, 5), 16)
    local b = tonumber(hexColor:sub(6, 7), 16)
    
    if not r or not g or not b then
        return "#F8F9FA"
    end
    
    -- Lighten by mixing with white (80% white, 20% original)
    r = math.floor(r * 0.2 + 255 * 0.8)
    g = math.floor(g * 0.2 + 255 * 0.8)
    b = math.floor(b * 0.2 + 255 * 0.8)
    
    return string.format("#%02X%02X%02X", r, g, b)
end

-- Helper function to darken color
function p.darkenColor(hexColor, percent)
    percent = percent or 20
    
    if not hexColor or hexColor:len() ~= 7 then
        return "#333333"
    end
    
    local r = tonumber(hexColor:sub(2, 3), 16)
    local g = tonumber(hexColor:sub(4, 5), 16)
    local b = tonumber(hexColor:sub(6, 7), 16)
    
    if not r or not g or not b then
        return "#333333"
    end
    
    r = math.floor(r * (100 - percent) / 100)
    g = math.floor(g * (100 - percent) / 100)
    b = math.floor(b * (100 - percent) / 100)
    
    return string.format("#%02X%02X%02X", r, g, b)
end

-- Function to get race data
function p.getRace(frame)
    local raceName = frame.args[1] or mw.text.trim(frame:getParent().args[1] or "")
    
    if raceName == "" then
        return "Error: No race name provided"
    end
    
    local race = raceData[raceName]
    
    if not race then
        return "Error: Race '" .. raceName .. "' not found in database"
    end
    
    return race
end

-- Function to get race info with hover infobox (for Template:RaceInfo) - UPDATED
function p.getRaceInfo(frame)
    local raceName = frame.args[1] or mw.text.trim(frame:getParent().args[1] or "")
    
    if raceName == "" then
        return "<span class='race-error'>Unknown Race</span>[[Category:Unknown Race]]"
    end
    
    local race = raceData[raceName]
    
    if not race then
        return "<span class='race-error'>Race Not Found</span>[[Category:Unknown Race]]"
    end
    
    local color = race.color or categoryColors[race.category] or "#666666"
    local lightColor = p.getLightColor(color)
    local darkColor = p.darkenColor(color, 20)
    
    local output = ""
    
    -- Create hover container
    output = output .. '<div class="race-hover-container">\n'
    
    -- The clickable race link - goes to race page
    output = output .. '<span class="race-hover-trigger">\n'
    output = output .. '<a href="/wiki/' .. mw.uri.encode(race.displayName) .. ' (Race)" class="race-link-inline" style="color: ' .. color .. ';">\n'
    output = output .. race.displayName .. '\n'
    output = output .. '</a>\n'
    output = output .. '</span>\n'
    
    -- The hidden infobox that appears on hover
    output = output .. '<div class="race-hover-infobox" style="border-color: ' .. color .. ';">\n'
    output = output .. '<div class="race-hover-header" style="background: linear-gradient(135deg, ' .. color .. ' 0%, ' .. darkColor .. ' 100%);">\n'
    output = output .. '<h4>' .. race.displayName .. '</h4>\n'
    output = output .. '</div>\n'
    output = output .. '<div class="race-hover-content" style="background-color: ' .. lightColor .. ';">\n'
    output = output .. '<table class="race-hover-table">\n'
    output = output .. '<tr><td><strong>Category:</strong></td><td><span class="category-badge-small" style="background-color: ' .. color .. ';">' .. race.category .. '</span></td></tr>\n'
    
    if race.subrace then
        output = output .. '<tr><td><strong>Subrace:</strong></td><td>' .. race.subrace .. '</td></tr>\n'
    end
    
    if race.description then
        output = output .. '<tr><td colspan="2" style="padding-top: 10px; font-size: 0.9em; line-height: 1.4; color: #555;">' .. race.description .. '</td></tr>\n'
    end
    
    output = output .. '</table>\n'
    output = output .. '<div class="race-hover-footer">\n'
    output = output .. '<a href="/wiki/' .. mw.uri.encode(race.displayName) .. ' (Race)" class="view-full-link" style="background-color: ' .. color .. ';">View Full Race Page</a>\n'
    output = output .. '</div>\n'
    output = output .. '</div>\n'
    output = output .. '</div>\n'
    output = output .. '</div>\n'
    
    -- Add category for character
    output = output .. "\n[[Category:" .. race.category .. " Characters]]"
    output = output .. "\n[[Category:" .. race.displayName .. " Characters]]"
    
    return output
end

-- Function to get race infobox for race pages
function p.getRaceInfobox(frame)
    local raceName = frame.args[1] or mw.text.trim(frame:getParent().args[1] or "")
    
    if raceName == "" then
        return "Error: No race name provided"
    end
    
    local race = raceData[raceName]
    
    if not race then
        return "Error: Race '" .. raceName .. "' not found"
    end
    
    local color = race.color or categoryColors[race.category] or "#666666"
    local lightColor = p.getLightColor(color)
    local darkColor = p.darkenColor(color, 20)
    
    local output = ""
    
    output = output .. '<div class="race-full-infobox" style="border-color: ' .. color .. ';">\n'
    output = output .. '<div class="race-full-header" style="background: linear-gradient(135deg, ' .. color .. ' 0%, ' .. darkColor .. ' 100%);">\n'
    output = output .. '<h2>Race Information</h2>\n'
    output = output .. '</div>\n'
    output = output .. '<div class="race-full-content" style="background-color: ' .. lightColor .. ';">\n'
    output = output .. '<div class="race-badge-large" style="background-color: ' .. color .. ';">' .. race.category .. '</div>\n'
    output = output .. '<table class="race-full-table">\n'
    output = output .. '<tr><td><strong>Race Name:</strong></td><td>' .. race.displayName .. '</td></tr>\n'
    output = output .. '<tr><td><strong>Category:</strong></td><td><span class="category-tag-large" style="background-color: ' .. color .. ';">' .. race.category .. '</span></td></tr>\n'
    
    if race.subrace then
        output = output .. '<tr><td><strong>Subrace:</strong></td><td>' .. race.subrace .. '</td></tr>\n'
    end
    
    if race.description then
        output = output .. '<tr><td><strong>Description:</strong></td><td>' .. race.description .. '</td></tr>\n'
    end
    
    output = output .. '</table>\n'
    output = output .. '<div class="race-characters-section">\n'
    output = output .. '<h3>Characters of this Race</h3>\n'
    output = output .. '<div class="category-list">\n'
    output = output .. '{{#categorytree:' .. race.displayName .. ' Characters|depth=1|mode=pages}}\n'
    output = output .. '</div>\n'
    output = output .. '</div>\n'
    output = output .. '</div>\n'
    output = output .. '</div>\n'
    
    return output
end

-- Function to get all races in a category
function p.getRaceCategory(frame)
    local category = frame.args[1] or mw.text.trim(frame:getParent().args[1] or "")
    
    if category == "" then
        return "Error: No category specified"
    end
    
    local output = "== " .. category .. " Races ==\n\n"
    local found = false
    
    for raceName, race in pairs(raceData) do
        if race.category == category then
            found = true
            local color = race.color or categoryColors[race.category] or "#666666"
            output = output .. '=== <span style="color: ' .. color .. ';">' .. race.displayName .. '</span> ===\n'
            output = output .. '* [[' .. race.displayName .. ' (Race)|View Race Page]]\n'
            output = output .. '* [[:Category:' .. race.displayName .. ' Characters|View ' .. race.displayName .. ' Characters]]\n\n'
        end
    end
    
    if not found then
        return "Error: Category '" .. category .. "' not found or has no races"
    end
    
    return output
end

return p