Module:Chessboard/Dou Shou Qi

கட்டற்ற கலைக்களஞ்சியமான விக்கிப்பீடியாவில் இருந்து.

Documentation for this module may be created at Module:Chessboard/Dou Shou Qi/doc

local p = {}

function p.dims()
	return 9, 7
end

function p.letters()
	return {'A', 'B', 'C', 'E', 'E', 'F', 'G', 'H', 'I'}
end

function p.image_board(size)
	return string.format( '<div style="width: %dpx; height: %dpx; overflow: hidden;">' ..
		'<div style="position: relative; top: -%dpx; left: -%dpx; width: %dpx">' ..
		'<div class="noresize">[[File:DouShouQi.svg|%dx%dpx|link=]]</div></div></div>',
		7*size + 1, 9*size + 1, (size - 1)/2, (size - 1)/2, 8*size, 8*size, 10*size)
end

function p.image_square( pc, row, col, size )
	local colornames = {
		l = { m = 'white', f = 'white' },
		d = { m = 'black', f = 'black' }
	}
	local piecenames = { 
		e = { name = 'elephant', gender = 'm' },
		l = { name = 'lion', gender = 'm' },
		t = { name = 'tiger', gender = 'm' },
		p = { name = 'leopard', gender = 'm' },
		w = { name = 'wolf', gender = 'm' },
		d = { name = 'dog', gender = 'm' },
		c = { name = 'cat', gender = 'm' },
		m = { name = 'mouse', gender = 'm' }
	}
	local symnames = {
		xx = 'black cross',
		ox = 'white cross',
		xo = 'black circle',
		oo = 'white circle',
		ul = 'up-left arrow',
		ua = 'up arrow',
		ur = 'up-right arrow',
		la = 'left arrow',
		ra = 'right arrow',
		dl = 'down-left arrow',
		da = 'down arrow',
		dr = 'down-right arroe',
		lr = 'left-right arrow',
		ud = 'up-down arrow',
		x0 = 'zero',
		x1 = 'one',
		x2 = 'two',
		x3 = 'three',
		x4 = 'four',
		x5 = 'five',
		x6 = 'six',
		x7 = 'seven',
		x8 = 'eight',
		x9 = 'nine',
	}
	local colchar = {'A','B','C','D','E','F','G','H','I'}
    local color = mw.ustring.gsub( pc, '^.*(%w)(%w).*$', '%2' ) or ''
    local piece = mw.ustring.gsub( pc, '^.*(%w)(%w).*$', '%1' ) or ''
    local alt = colchar[col] .. row .. ' '

    if colornames[color] and piecenames[piece] then
		alt = alt .. colornames[color][piecenames[piece]['gender']] .. ' ' .. piecenames[piece]['name']
    else
		alt = alt .. ( symnames[piece .. color] or piece .. ' ' .. color )
	end

	fn = ''

	if pc == 'el' then
		fn = 'Doushouqi-elephant'
	elseif pc == 'ed' then
		fn = 'Doushouqi-elephant-inv'
	elseif pc == 'll' then
		fn = 'Doushouqi-lion'
	elseif pc == 'ld' then
		fn = 'Doushouqi-lion-inv'
	elseif pc == 'tl' then
		fn = 'Doushouqi-tiger'
	elseif pc == 'td' then
		fn = 'Doushouqi-tiger-inv'
	elseif pc == 'pl' then
		fn = 'Doushouqi-leopard'
	elseif pc == 'pd' then
		fn = 'Doushouqi-leopard-inv'
	elseif pc == 'wl' then
		fn = 'Doushouqi-wolf'
	elseif pc == 'wd' then
		fn = 'Doushouqi-wolf-inv'
	elseif pc == 'dl' then
		fn = 'Doushouqi-dog'
	elseif pc == 'dd' then
		fn = 'Doushouqi-dog-inv'
	elseif pc == 'cl' then
		fn = 'Doushouqi-cat'
	elseif pc == 'cd' then
		fn = 'Doushouqi-cat-inv'
	elseif pc == 'ml' then
		fn = 'Doushouqi-rat'
	elseif pc == 'md' then
		fn = 'Doushouqi-rat-inv'
	end

	return string.format( '[[File:%s.svg|%dx%dpx|alt=%s|%s|top]]', fn, size, size, alt, alt )

end

return p
"https://ta.wikipedia.org/w/index.php?title=Module:Chessboard/Dou_Shou_Qi&oldid=3821924" இலிருந்து மீள்விக்கப்பட்டது