Leaguepedia | League of Legends Esports Wiki
Advertisement
Leaguepedia | League of Legends Esports Wiki

Documentation for this module may be created at Module:RosterChangeSentencePrinterAbstract/doc

local util_args = require('Module:ArgsUtil')
local util_cargo = require('Module:CargoUtil')
local util_esports = require('Module:EsportsUtil')
local util_html = require('Module:HtmlUtil')
local util_math = require('Module:MathUtil')
local util_map = require('Module:MapUtil')
local util_news = require("Module:NewsUtil")
local util_sentence = require("Module:SentenceUtil")
local util_sort = require("Module:SortUtil")
local util_source = require("Module:SourceUtil")
local util_table = require('Module:TableUtil')
local util_text = require('Module:TextUtil')
local util_time = require("Module:TimeUtil")
local util_title = require('Module:TitleUtil')
local util_vars = require("Module:VarsUtil")
local LCS = require('Module:LuaClassSystem')
local i18n = require("Module:I18nUtil")
local lang = mw.getLanguage('en')
local h = {}
local p = LCS.class.abstract()

function p:init(args)
	self.args = args
end

function p:run(args, listOfPlayers)
	local playersByPreload = self:groupPlayersByPreload(listOfPlayers)
	local playersAsSentences = util_map.selfDictInPlace(self, playersByPreload, self.getSentencePart)
	local ret = {
		Sentence = self:getSentenceParts(playersAsSentences, args)
	}
	return util_map.inPlace(ret, util_table.concatDict, ' ')
end

function p:groupPlayersByPreload(listOfPlayers) end

function p:getSentencePart(row)
	if row.class then
		return self:makeSentencePartWithClass(row, row.class)
	end
	return self:getSentencePartText(row, self.args)
end 

function p:makeSentencePartWithClass(row, class)
	local span = mw.html.create('span')
		:addClass('rosterchange-' .. class)
	span:wikitext(self:getSentencePartText(row, self.args))
	return tostring(span)
end

function p:getSentencePartText(row, args)
	local text = self:getTextForReplacements(row, self.args)
	local replacements = self:getReplacements(row, self.args)
	return util_sentence.makeReplacements(text, replacements)
end

function p:getTextForReplacements(row, args) end

function p:getReplacements(players, args) end

function p:getSentenceParts(playersAsSentences)
	-- returns ordered dict
	local prepend = { 'prepend', prepend = util_text.ucfirst(self.args.custom_prepend) }
	local append = { 'append', append = util_text.ucfirst(self.args.custom_append) }
	return util_table.mergeDicts(prepend, playersAsSentences, append)
end

return p
Advertisement