此模块的文档可以在模块:Card/link/doc创建

local name_to_id = require('Module:Card/name_to_id')
local id_to_cost = require('Module:Card/id_to_cost')
local Card = require('Module:Card')
local Util = require('Module:Util')

local p = {}

function p.cost(frame)
	local args = frame:getParent().args
	local name = args[1]
	local text = args[2] or args[1]
	local id = name_to_id(name)
	local cost = id_to_cost(id)
	
	return '<span class="huiji-tt" data-type="card" data-name="'..id..'"'..(args['style'] and (' style="' .. args['style'] .. '"') or '')..'>'
		..'['..cost..'][['..name..'|'..text..']]</span>'
end

local function style(card)
	card = Util.clone(card)
	if mw.ustring.len(card.name)>7 then
		card._name = mw.ustring.sub(card.name,1,6)..'...'
	end
	return '<div style="border:1px solid #000;display:inline-flex;flex-wrap:nowrap;;width:200px;margin:2px 2px;padding:0;background:#333;color:#fff;">'
		..'<div style="display:inline-flex;align-items:center;padding:4px;background:#36c;color:#fff;">'
			..(card.cost and '[[file:Mana_icon.png|12px|link=]]'
				..'<b style="display:inline-block;width:20px;margin-right:-3px;text-align:center;">'..card.cost..'</b>' 
				or '')
		..'</div>'
		..'<span class="quiet" style="padding:6px;white-space:nowrap;overflow:hidden;flex:1;">'
			..(card.rarity and card.rarity~='FREE' and mw.getCurrentFrame():expandTemplate{title=card.rarity:sub(1,1),args={}} or '')
			..require('Module:Hearthstone')._cardLink(card)
		..'</span>'
		..'<div class="bg_'..card.cardClass..'" style="display:flex;width:33px;align-items:center;justify-content:center;">'
			..'[[file:icon_'..card.cardClass:lower()..'.png|20px|link=]]'
		..'</div>'
	..'</div>'
end

function p.style(frame) --=p.style{'幼龙鹰'}
	local data
	if frame._id then
		data = frame
	else
		local args = frame.getParent and frame:getParent().args or frame.args or frame
		local name = args[1]
		data = Card.getByName(name)
	end
	return style(data)
end

return p
0.0
0人评价
avatar