Module:BuildLink

local p = {}

local esper_stats = { ["Carbuncle"]     = "carbuncle-2star-lvl40/3350/5780/1940/3270/4450/6330/", ["Diabolos"]      = "diabolos-2star-lvl40/4680/6170/1640/2390/5460/3250/", ["Golem"]         = "golem-2star-lvl40/6400/4330/3335/4860/1630/1630/", ["Ifrit"]         = "ifrit-2star-lvl40/5000/2240/5320/3070/2190/2150/", ["Lakshmi"]       = "lakshmi-2star-lv40/5040/5150/2060/2510/3485/5890/", ["Odin"]          = "odin-2star-lvl40/5450/3955/6250/4310/2075/2270/", ["Ramuh"]         = "ramuh-2star-lvl40/3170/6280/1770/1225/6035/4595/", ["Shiva"]         = "shiva-2star-lvl40/3825/6005/2260/2460/5520/5580/", ["Siren"]         = "siren-2star-lvl40/3450/3475/2000/2035/3695/3775/", ["Titan"]         = "titan-2star-lvl40/7000/2050/5450/4230/1840/3270/", ["Tetra Sylphid"] = "tetra-sylphid-2star-lvl40/4250/5550/2700/2035/6300/3560/", ["Empty"]         = "Empty/0/0/0/0/0/0/" }

local item_convert = { ["Moonblade"]                  = "moon-blade", ["Adventurer IV"]             = "adventurer-4", ["Adventurer V"]              = "adventurer-5", ["Sworn Six's Pride - Dark"]  = "sworn-sixs-pride-dark", ["Sworn Six's Pride - Fire"]  = "sworn-sixs-pride-fire", ["Sworn Six's Pride - Water"] = "sworn-sixs-pride-water", ["Sworn Six's Pride - Wind"]  = "sworn-sixs-pride-wind", ["Sworn Six's Pride - Light"] = "sworn-sixs-pride-light", ["Sworn Six's Pride - Earth"] = "sworn-sixs-pride-earth", ["Katana Mastery"]            = "blade-mastery" }

-- Create Link to FFBE database from build info -- Sample Link: -- http://www.ffbedb.com/tool/unit-calculator/build/delita-6star/SPR Baseline Test2/blessed-hammer/Empty/crown-of-justice/cupids-robe/magistral-crest/magistral-crest/mentality/mentality/mentality/mentality/Empty/0/0/0/0/0/0/Empty/Empty/0/0/0/0/0/0 function p.get_url(frame) local base = "http://www.ffbedb.com/tool/unit-calculator/build/" base = base.._urlformat(frame.args.unit).."-6star/" --name base = base.._titleformat(frame.args.title).."/" --title base = base.._urlformat(frame.args.rhand).."/" base = base.._urlformat(frame.args.lhand).."/" base = base.._urlformat(frame.args.head).."/" base = base.._urlformat(frame.args.body).."/" base = base.._urlformat(frame.args.acc1).."/" base = base.._urlformat(frame.args.acc2).."/"

base = base.._urlformat(frame.args.mat1).."/" base = base.._urlformat(frame.args.mat2).."/" base = base.._urlformat(frame.args.mat3).."/" base = base.._urlformat(frame.args.mat4).."/"

if frame.args.esper == nil or esper_stats[frame.args.esper] == nil then base = base..esper_stats["Empty"] else base = base..esper_stats[frame.args.esper] end

base = base.."Empty/Empty/"

--Full Pot Support base = base..(frame		:preprocess('')		:match(mw.text.encode('Rarity|6}} || ([^LB]-)\n', '{}|'))			or "0/0/0/0/0/0"	):gsub(' &#124;&#124; ', '/')

return base end

function _urlformat(s) if s == nil or s == "" then return "Empty" end

if item_convert[s] ~= nil then return item_convert[s] end

local result = string.lower(s) result = string.gsub(result, "'", "") result = string.gsub(result, "+", "") result = string.gsub(result, "%%", "") result = string.gsub(result, ".item.", "") result = string.gsub(result, "^%s*(.-)%s*$", "%1") result = string.gsub(result, " ", "-") return result end

function _titleformat(s) if s == nil or s == "" then return "Build" end

result = string.gsub(s, " ", "%%20") result = string.gsub(result, "/", "-") return result end

return p