Content deleted Content added
align |
fix alt text for fairy pieces and symbols |
||
Line 2:
function chessboard( position, size, reverse)
local piecenames = { p = 'Pawn', r = 'Rook', n = 'Knight', b = 'Bishop', q = 'Queen', k = 'King' }▼
local colornames = { l = 'White', d = 'Black' }
▲ local piecenames = { p = '
c = 'chancelor', z = 'champion', w = 'wizard', t = 'fool', h = 'upside-down pawn', m = 'upside-down rook',
s = 'upside-down knight', f = 'upside-down king', e = 'upside-down bishop', g = 'upside-down queen'}
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 arrow', 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'}
function rowchar( row ) return 9 - row end
function filechar( file ) return ( "abcdefgh" ):sub( file, file ) end
function coord( ind ) return ( reverse and ( 8 - ind ) * size ) or ( ind - 1 ) * size end
function piecediv(
local color = mw.ustring.gsub(
local piece = mw.ustring.gsub(
local alt =
if (colornames[color] and piecenames[piece]) then
alt = alt .. colornames[color] .. ' ' .. piecenames[piece]
else
alt = alt .. (symnames[ piece .. color ] or (piece .. ' ' .. color))
end
local img = string.format('[[File:Chess %s%st45.svg|%dx%dpx|alt=%s|%s]]', piece, color, size, size, alt, alt)
table.insert( res, string.format('<div style="position:absolute;z-index:3;top:%dpx;left:%dpx;">%s</div>', coord( row ), coord( file ), img) )
|