Jump to content

Module:Shogi diagram

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ish ishwar (talk | contribs) at 01:07, 10 June 2016 (Created page with 'local testobj = {} local function piecesymbol(abbreviation) -- strip whitespace abbreviation = mw.text.trim(abbreviation) -- letter to character mapping loc...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local testobj = {}

local function piecesymbol(abbreviation)
	-- strip whitespace
	abbreviation = mw.text.trim(abbreviation)
	-- letter to character mapping
	local piecenames = {
		p = '歩',
		t = 'と',
		l = '香',
		pl = '杏',
		n = '桂',
		pn = '圭',
		s = '銀',
		ps = '全',
		g = '金',
		b = '角',
		h = '馬',
		r = '飛',
		d = '龍',
		k = '玉',
		ak = '王',
		tx = '个',
		plx = '仝',
		pnx = '今',
		dx = '竜',
		e = '象',
		a = '太',
	}
	return string.format( piecenames[abbreviation] )
end

function testobj.testfunct(frame)
	local arg = frame.args[1]
	return piecesymbol(arg)
end

return testobj