Reborn Wiki
Advertisement
Reborn Wiki

Documentation for this module may be created at Module:KHRRef/doc

local p = {}
local getArgs = require('Dev:Arguments').getArgs

local data = mw.loadData('Module:KHRRef/data')

function p.reftext(frame)
	local args = getArgs(frame)
    local category = args.category or args[1]
    local reference = args.reference or args[2]
    local notes = args.notes
    local pages = args.pages
    local text = ""
    
    local mangatext = "[[Akira Amano|Amano, Akira]]. ''[[Katekyo Hitman Reborn!]]''. Tokyo: [[wikipedia:Shueisha|Shueisha]], 2004–2012. Print."
    
    if (category == "anime") then
    	if (reference == "ova") then
    		text = "''[[Katekyo Hitman Reborn!]]'' special anime: [[" .. data[category][reference] .. "]]"
    	else
    		text = "''[[Katekyo Hitman Reborn!]]'' anime: [[Episode " .. reference .. "]]"
    	end
    elseif (category == "vol") then
    	text = mangatext .. " [[Volume " .. reference .. "|Vol. " .. reference .. "]]"
    elseif (category == "chap") then
    	text = mangatext .. " [[Volume " .. p.volnum(reference) .. "|Vol. " .. p.volnum(reference) .. "]]: [[Chapter " .. reference .. "]]"
    elseif (category == "book" or category == "novel") then
    	text = p.easyformat(category, reference)
    else
    	text = "''[[" .. data[category][reference] .. "]]''"
    end
    
    if (notes) then
    	notes = ", " .. notes
    end

    return text .. (notes or "")
end

function p.easyformat(category, reference)
	if (category == "novel") then
		if (reference == "boy") then
			return "[[Akira Amano|Amano, Akira]]. \"[[".. data[category][reference]["name"] .. "]].\" ''[[".. data[category][reference]["volume"] .. "]].'' Tokyo: [[wikipedia:Shueisha|Shueisha]]. ".. data[category][reference]["year"] .. ". Print."
		end
		return "Koyasu, Hideaki (writer) & [[Akira Amano|Amano, Akira]] (illus). \"[[".. data[category][reference]["name"] .. "]].\" ''".. data[category][reference]["volume"] .. ".'' Tokyo: [[wikipedia:Shueisha|Shueisha]]. ".. data[category][reference]["year"] .. ". Print."
	end
	return "[[Akira Amano|Amano, Akira]]. ''[[" .. data[category][reference]["name"] .."]].'' Tokyo: [[wikipedia:Shueisha|Shueisha]]. ".. data[category][reference]["year"] .. ". Print."
end

--ugly brute force
function p.volnum(num)
	if (num > "401") then
		return 42
	elseif (num > "391") then
		return 41
	elseif (num > "381") then
		return 40
	elseif (num > "371") then
		return 39
	elseif (num > "361") then
		return 38
	elseif (num > "351") then
		return 37
	elseif (num > "341") then
		return 36
	elseif (num > "330") then
		return 35
	elseif (num > "320") then
		return 34
	elseif (num > "310") then
		return 33
	elseif (num > "299") then
		return 32
	elseif (num > "288") then
		return 31
	elseif (num > "278") then
		return 30
	elseif (num > "268") then
		return 29
	elseif (num > "258") then
		return 28
	elseif (num > "247") then
		return 27
	elseif (num > "237") then
		return 26
	elseif (num > "226") then
		return 25
	elseif (num > "215") then
		return 24
	elseif (num > "205") then
		return 23
	elseif (num > "195") then
		return 22
	elseif (num > "185") then
		return 21
	elseif (num > "174") then
		return 20
	elseif (num > "164") then
		return 19
	elseif (num > "153") then
		return 18
	elseif (num > "143") then
		return 17
	elseif (num > "134") then
		return 16
	elseif (num > "125") then
		return 15
	elseif (num > "116") then
		return 14
	elseif (num > "107") then
		return 13
	elseif (num > "99") then
		return 12
	elseif (num > "89") then
		return 11
	elseif (num > "79") then
		return 10
	elseif (num > "70") then
		return 9
	elseif (num > "60") then
		return 8
	elseif (num > "51") then
		return 7
	elseif (num > "42") then
		return 6
	elseif (num > "33") then
		return 5
	elseif (num > "25") then
		return 4
	elseif (num > "16") then
		return 3
	elseif (num > "7") then
		return 2
	end
	return 1
end

return p
Advertisement