The Alchemist Code Wiki

READ MORE

The Alchemist Code Wiki
Register
Advertisement

To edit the documentation or categories for this module, click here.


local p = {}

function p.wikiSafeName(name)
	if name == nil then return end
    return string.gsub(name, '[%[%]]', {
        ['['] = '【',
        [']'] = '】',
    })
end

function p.acdbLink(iname, jp)
    local prefix = string.sub(iname, 1, 2)
    
    local type = (prefix == 'IT' and 'item') or (prefix == 'TS' and 'card') or (prefix == 'AF' and 'gear') or (prefix == 'QE' and 'quest') or (prefix == 'UN' and 'unit') or (prefix == 'SK' and 'skill') or nil
    
    if type == 'unit' then
        iname = string.gsub(iname, 'UN_V2_', '')
    end
    
    local url = 'https://www.alchemistcodedb.com/'
    
    if jp then
    	url = url..'jp/'
    end
    
    if type then
        url = url..type..'/'..string.lower(string.gsub(iname, '_', '-'))
    end
    
    return url
end

function p.releasedVersLink(name, iname, jpOnly)
    return jpOnly and p.acdbLink(iname, true) or p.wikiSafeName(name)
end

return p
Advertisement