Module:AbilityHints: Difference between revisions

Jump to navigation Jump to search
Vergir (talk | contribs)
m add healingtempo automatic hint
Vergir (talk | contribs)
m Adjust to the new AbilityTable contracts. This restores abilityhints
Line 2: Line 2:
-- Used by Template:AbilitySection. Styles are there too.
-- Used by Template:AbilitySection. Styles are there too.


local AbilityTable = require("Module:AbilityTable")
local ability_data = mw.loadJsonData("Data:AbilityData.json")
local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json")
local item_data = mw.loadJsonData("Data:ItemData.json")
local p = {}
-- Automatic hints that get shown without corresponding {{AbilityInteraction}}. Powered by Module:AbilityTable
local CONFIG = {
local CONFIG = {
     { list = "melee",            file = "Melee Lifesteal.png",  tip = "Benefits from melee items (e.g. [[Melee Lifesteal]])" },
     { list = "melee",            file = "Melee Lifesteal.png",  tip = "Benefits from melee items (e.g. [[Melee Lifesteal]])" },
Line 25: Line 17:
}
}


-- Display order: item slot (Weapon, then Vitality, then Spirit), then cost, then name.
local AbilityTable = require("Module:AbilityTable")
local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json")
local item_data = mw.loadJsonData("Data:ItemData.json")
 
local p = {}
 
-- Display order: item type (Weapon => Vitality => Spirit), then cost, then name.
local function sort_key(file)
local function sort_key(file)
     local base = mw.ustring.lower((file:gsub('%.%w+$', '')))
     local base = mw.ustring.lower((file:gsub('%.%w+$', '')))
Line 93: Line 91:
     local placed = {}
     local placed = {}


     local record = ability_data[ability_key]
     local num = tonumber(ability_num)
    if record ~= nil then
    for _, def in ipairs(CONFIG) do
        local num = tonumber(ability_num)
        if AbilityTable.is_member(def.list, ability_key, num) then
        for _, def in ipairs(CONFIG) do
            local key = mw.ustring.lower(def.file)
            if AbilityTable.is_member(def.list, record, num) then
            local m = manual_by_file[key]
                local key = mw.ustring.lower(def.file)
            if m ~= nil then
                local m = manual_by_file[key]
                table.insert(entries, { file = m.file, html = manual_icon(m) })
                if m ~= nil then
                placed[key] = true
                    table.insert(entries, { file = m.file, html = manual_icon(m) })
            else
                    placed[key] = true
                table.insert(entries, { file = def.file, html = hint_icon(def) })
                else
                    table.insert(entries, { file = def.file, html = hint_icon(def) })
                end
             end
             end
         end
         end