Homepage
Games
News
News βΎ
All
Transfers
Drama
Business
Sponsors
Mergers
Investors
Hires
Companies
More
People
Tournaments
Brands
Brands βΎ
Companies
Organizations
Sponsors
Other
Locations
Search
Editing
Module:GameLanding/Tournaments
From TwogPedia
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local cargo = mw.ext.cargo local p = {} local prizeToString = require('Module:Functions').prizeToString function p.tournaments(game) local tables = 'Tournaments' local fields = '_pageName, start, end, prize, logoAll, logoLight, logoDark, iconAll, iconLight, iconDark, venue' local currentDate = os.date('%Y-%m-%d') local cargoArgs = { where = 'featured IS NULL AND _pageName LIKE "' .. game .. '/%" AND ( (start is NULL OR start < "' .. currentDate .. '") AND (end is NULL OR end > "' .. currentDate .. '") OR start > ' .. currentDate .. ' )', limit = 10 } local results = cargo.query(tables, fields, cargoArgs) if #results > 0 then local monthNames = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} local headerRow = mw.html.create('div'):addClass('tournament__header tournament__row'):node(mw.html.create('div'):wikitext('Date')):node(mw.html.create('div'):wikitext('Prize')):node(mw.html.create('div'):wikitext('Name')) local tournaments = mw.html.create('div'):addClass('tournament__container'):node(headerRow) local tournamentContainer = mw.html.create('div'):addClass('box__container'):node(mw.html.create('div'):addClass('box__title'):wikitext('Tournaments')):node(tournaments) for i = 1, #results do local result = results[i] local tournamentRow = mw.html.create('div'):addClass('tournament__row') local currentTime = os.time() local startTime = nil if result.start then startTime = mw.ustring.gsub(result.start, '(%d+)-(%d+)-(%d+)', function(year, month, day) return os.time({year=tonumber(year), month=tonumber(month), day=tonumber(day)}) end) end local endTime = nil if result['end'] then endTime = mw.ustring.gsub(result['end'], '(%d+)-(%d+)-(%d+)', function(year, month, day) return os.time({year=tonumber(year), month=tonumber(month), day=tonumber(day)}) end) end local date = mw.html.create('div') -- If live if (startTime ~= nil and os.difftime(currentTime, startTime) > 0) and (endTime == nil or os.difftime(currentTime, endTime) <= 0) then date:wikitext('LIVE') else local startDate = 'TBD' if result.start then local year, month, day = result.start:match("(%d+)-(%d+)-(%d+)") local monthName = monthNames[tonumber(month)] startDate = monthName .. " " .. day .. ", " .. year end local endDate = 'TBD' if result['end'] then year, month, day = result['end']:match("(%d+)-(%d+)-(%d+)") monthName = monthNames[tonumber(month)] endDate = monthName .. " " .. day .. ", " .. year end date:wikitext(startDate .. ' - ' .. endDate) end local prize = mw.html.create('div'):wikitext('$' .. prizeToString(result.prize)) local icon = result.iconAll ~= '' and result.iconAll or result.iconLight ~= '' and result.iconLight or result.iconDark ~= '' and result.iconDark or result.logoAll ~= '' and result.logoAll or result.logoDark ~= '' and result.logoDark or result.logoLight ~= '' and result.logoLight if not icon then icon = 'Tournament_placeholder.png' end local name = mw.html.create('div'):addClass('tournament__name'):node(mw.html.create('div'):wikitext('[[File:' .. icon .. '|25px]]')):node(mw.html.create('div'):wikitext('[[' .. result._pageName .. ']]')) -- featuredTournament:node(mw.html.create('div'):addClass('tc'):wikitext('[[File:' .. icon .. '|200px]]')) -- featuredTournament:node(mw.html.create('div'):addClass('tc'):wikitext('[[' .. result._pageName .. ']]')) tournaments:node(tournamentRow:node(date):node(prize):node(name)) end return tournamentContainer end return nil end return p
Summary:
Please note that all contributions to TwogPedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TwogPedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:GameLanding/Tournaments/doc
(
edit
)
No categories
Edit