Module:StandardBioSentence

local util_args = require('Module:ArgsUtil') local util_cargo = require('Module:CargoUtil') local util_table = require('Module:TableUtil')

local m_role = require('Module:Role') local m_team = require('Module:Team') local h = {}

function h.getData(frame) local variables = { 'id', 'firstname', 'lastname', 'nativename', 'namealphabet', 'lastteam', 'role', 'teamStr' } local bools = { 'sharesrole', 'isasub', 'ispersonality', 'lastteampresent' } local data = {} for _, v in ipairs(variables) do		local var = frame:callParserFunction('#var', v)		if var ~= '' then data[v] = var end end local i = 2 repeat local teami = frame:callParserFunction('#var', 'team' .. i) data['team' .. i] = teami ~= '' and teami i = i + 1 until(not teami or teami == '') for _, v in ipairs(bools) do		data[v] = util_cargo.strToBool(frame:callParserFunction('#var', v)) end data.suspended = data.lastteam == 'Suspended' return data end

function h.writeSentenceParts(data) local tbl = h.writeStart(data) local tbl_end if data.suspended then tbl_end = h.writeSuspended(data) elseif not data.lastteam then tbl_end = h.writeNoInfo(data) else tbl_end = h.writeStandard(data) end util_table.mergeArrays(tbl, tbl_end) util_table.removeFalseEntries(tbl) return tbl end

function h.writeStart(data) local tbl = { data.firstname, data.id and ("\"%s\""):format(data.id), data.lastname, data.nativename and ("(%s: %s)"):format(data.namealphabet or 'original', data.nativename), }	return tbl end

function h.writeSuspended(data) local tbl = { "is a", m_role.rolelc(data.role), "who", data.lastteampresent and 'is currently' or 'was previously', 'suspended' }	return tbl end

function h.writeNoInfo(data) return { "is a", data.ispersonality and 'personality' or 'player' } end

function h.writeStandard(data) local tbl = { data.teamStr and 'is' or 'was previously', data.isasub and 'a substitute' or (data.sharesrole and m_role.article(data.role) or data.role and 'the' or 'a'), m_role.sentence(data.role), m_team.plainlinked(data.teamStr or data.lastteam) }	if data.team2 then tbl[#tbl+1] = 'and also plays for' tbl[#tbl+1] = h.addOtherTeams(data) end return tbl end

function h.addOtherTeams(data) local teamlist = {} local i = 2 while data['team' .. i] do teamlist[#teamlist+1] = m_team.plainlinked(data['team' .. i]) i = i + 1 end return util_table.printList(teamlist) end

local p = {} function p.main(frame) local args = util_args.merge(true) local data = h.getData(frame) local sentenceParts = h.writeSentenceParts(data) local output = table.concat(sentenceParts, ' ') .. '.'	return output end return p