Module:NewsData

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_news = require("Module:NewsUtil") local util_sentence = require("Module:SentenceUtil") local util_table = require("Module:TableUtil") local util_text = require('Module:TextUtil') local util_title = require('Module:TitleUtil') local util_vars = require('Module:VarsUtil') local i18n = require('Module:I18nUtil') local COLUMNS = util_news.COLUMNS local WeeklyDataPages = require('Module:WeeklyDataPages') local m_team = require('Module:Team') local LCS = require('Module:LuaClassSystem')

-- none of these functions stores any semantic information. there are no roster changes, team changes, renames, etc, associated to any of them. the only effect of using these templates to write news is that the news will show up on the pages in question.

local h = {}

local p = {}

function p.start(frame) return WeeklyDataPages.start('NewsData') end

function p.date(frame) i18n.init('NewsData') local args = util_args.merge return WeeklyDataPages.date(args, COLUMNS) end

function p.endTable(frame) return ' ' end

local news = LCS.class.abstract local teamNews = news:extends local tournamentNews = news:extends local playerNews = news:extends teamNews.SubjectType = 'Team' tournamentNews.SubjectType = 'Tournament' playerNews.SubjectType = 'Player'

function news:init(args) util_cargo.setStoreNamespace('Data') util_news.setId local players = args.players or args.player args.Sentence = args.sentence local hasPlayerExtraInfo = util_args.isSplitArg(players) if hasPlayerExtraInfo then players = util_news.getPlayersFromArg(players) args.Sentence = h.getPlayerSentence(args, players) end local data = util_news.getNewsCargoFieldsFromArgs(args) data.Subject = self:getSubject(args, players) data.SubjectLink = self:getSubjectLink(args) data.SubjectType = self.SubjectType if hasPlayerExtraInfo then data.Players = util_table.concat(util_table.extractValueToList(players:toList, 'Player')) end util_cargo.store(data) return util_news.makeSentenceOutput(args, data) end

function h.getPlayerSentence(args, players) local replacements = { PLAYERS = util_sentence.players(players:toDict) }	return util_sentence.makeReplacements(args.sentence, replacements) end

function news:getSubjectLink(args) end function news:getSubject(args, players) end

function p.team(frame) local args = util_args.merge return teamNews:init(args) end

function teamNews:getSubject(args, players) return m_team.teamlinkname(args.team) end

function p.tournament(frame) local args = util_args.merge return tournamentNews:init(args) end

function tournamentNews:getSubjectLink(args) return util_title.target(args.link) or args.tournament end

function tournamentNews:getSubject(args, players) return args.tournament end

function p.player(frame) local args = util_args.merge return playerNews:init(args) end

function playerNews:getSubject(args, players) return players:get(1) end

return p