The Alchemist Code Wiki

READ MORE

The Alchemist Code Wiki
No edit summary
m (alchemistcodedb supports "https" protocol.)
Line 18: Line 18:
 
end
 
end
 
 
local url = 'http://www.alchemistcodedb.com/'
+
local url = 'https://www.alchemistcodedb.com/'
 
 
 
if jp then
 
if jp then

Revision as of 21:18, 3 March 2021

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 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