◆42Lab是非盈利性、非官方的云图计划维基百科。
◆诚邀指挥官们加入编辑部共同建设wiki。点这里加入42Lab
如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!
◆有任何意见、建议、纠错,欢迎在任意评论区评论
◆编辑讨论QQ群741423564 微博@GFwiki少前百科 欢迎您

模块:Relationship

来自42LAB

可在模块:Relationship/doc创建此模块的帮助文档

local p = {}
local args = {}
local root
local data = mw.loadData('Module:Relationship/data')
local rtypes = {
	"重要协助者", "好友", "同僚", "冤家", "挚友", "旧识", "同好", "猫朋狗友",
	"偶像", "粉丝", "“姐弟”", "教官", "学生", "前辈", "后辈",
	"互联网匿名冤家", "拳友", "姐妹", "警戒", "?","崇拜", "导师", "关照",
	"监护人", "合作者",
}

local function addCell(charid, rtype)
	local charname = data.chars[charid]
	local avatar = mw.getCurrentFrame():expandTemplate{title="小头像", args={charid+1000, '', '', charname, charname}}
	root:tag('div'):addClass('relationship-cell')
		:tag('div'):wikitext(rtypes[rtype]):addClass('relationship'):done()
		:tag('div'):wikitext(avatar)
end

function p.listAcquaintances(frame)
	args = frame == mw.getCurrentFrame() and frame:getParent().args or frame
	local selfid = tonumber(args['ID']) - 1000
	local rowstart = data.indptr[selfid] + 1
	local rowend = data.indptr[selfid+1]
	root = mw.html.create():wikitext('== 人际关系 =='):newline()
	for i = rowstart, rowend do
		addCell(data.indices[i] + 1, data.data[i])
	end
	return tostring(root)
end

return p