Module:ResidencyChange

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_news = require("Module:NewsUtil") local util_table = require("Module:TableUtil") local util_vars = require("Module:VarsUtil") local i18n = require("Module:I18nUtil")

local m_team = require('Module:Team') local Region = require('Module:Region')

local h = {}

local p = {} function p.main(frame) local args = util_args.merge i18n.init('ResidencyChange') util_cargo.setStoreNamespace('Data') h.castArgs(args) util_news.setId args.Sentence = h.writeSentence(args) h.storeResidencyCargo(args) local newsCargo = h.getNewsCargo(args) util_cargo.store(newsCargo) return util_news.makeSentenceOutput(args, newsCargo) end

function h.castArgs(args) args.original = Region(args.original) args.new = Region(args.new) end

function h.writeSentence(args) return i18n.default(		'sentence',		util_esports.playerLinked(args.player),		args.original:flair,		args.new:flair	) end

function h.storeResidencyCargo(args) local tbl = { _table = 'ResidencyChanges', ResidencyOld = args.original, ResidencyNew = args.new, Player = args.player, NewsId= util_news.getId, }	util_cargo.store(tbl) end

function h.getNewsCargo(args) return util_table.merge(		util_news.getNewsCargoFieldsFromArgs(args),		h.getNewsSubjectTags(args)	) end

function h.getNewsSubjectTags(args) if not args.team then return {} end local ret = { SubjectType = 'Team', Subject = m_team.teamlinkname(args.team), Teams = m_team.teamlinkname(args.team), Region = args.new, }	return ret end

return p