Module:AbilityHints: Difference between revisions

Jump to navigation Jump to search
Move hint icon positioning to a class and add action sentences to hint tooltips (with help from vergir-bot LLM)
Keep overriding manual hints in their automatic hint's CONFIG-order slot (with help from vergir-bot LLM)
Line 40: Line 40:
     manual = manual or {}
     manual = manual or {}


     -- Files claimed by a manual icon suppress the matching automatic icon.
     -- Manual icons indexed by file so an override can take its automatic hint's slot.
     local manual_files = {}
     local manual_by_file = {}
     for _, m in ipairs(manual) do
     for _, m in ipairs(manual) do
         manual_files[mw.ustring.lower(m.file)] = true
         manual_by_file[mw.ustring.lower(m.file)] = m
     end
     end


     local icons = {}
     local icons = {}
    local placed = {}


    -- Automatic hints in CONFIG order; an overriding manual icon takes the slot.
     local record = ability_data[ability_key]
     local record = ability_data[ability_key]
     if record ~= nil then
     if record ~= nil then
         local num = tonumber(ability_num)
         local num = tonumber(ability_num)
         for _, def in ipairs(CONFIG) do
         for _, def in ipairs(CONFIG) do
             if AbilityTable.is_member(def.list, record, num)
             if AbilityTable.is_member(def.list, record, num) then
                 and not manual_files[mw.ustring.lower(def.file)] then
                 local key = mw.ustring.lower(def.file)
                 table.insert(icons, hint_icon(def))
                local m = manual_by_file[key]
                if m ~= nil then
                    table.insert(icons, manual_icon(m))
                    placed[key] = true
                 else
                    table.insert(icons, hint_icon(def))
                end
             end
             end
         end
         end
     end
     end


    -- Remaining manual icons (no automatic slot) in their original order.
     for _, m in ipairs(manual) do
     for _, m in ipairs(manual) do
         table.insert(icons, manual_icon(m))
         if not placed[mw.ustring.lower(m.file)] then
            table.insert(icons, manual_icon(m))
        end
     end
     end