Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Check winner by scores
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!
require('strict') local p = {} local function format_score(s) s = mw.ustring.gsub(s or '', '^[%s\']*([%d%.]+)[%s\']*[βββ%-][%s\']*([%d%.]+)', '%1β%2') s = mw.ustring.gsub(s, '^%s*([%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1β%2') s = mw.ustring.gsub(s, '^%s*(%[%[[^%[%]]*%|[%d%.]+)%s*%-%s*([%d%.]+)', '%1β%2') s = mw.ustring.gsub(s, '^%s*(%[[^%[%]%s]*%s+[%d%.]+)%s*%-%s*([%d%.]+)', '%1β%2') s = mw.ustring.gsub(s, '^%s*(%[%[[^%[%]]*%|[%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1β%2') s = mw.ustring.gsub(s, '^%s*(%[[^%[%]%s]*%s+[%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1β%2') return s end function p.main(frame) local getArgs = require('Module:Arguments').getArgs local args = getArgs(frame, { parentFirst = true }) local n1 = args[1] or 'X' local n2 = args[2] or 'X' local s = args['sc'] or (n1..'β'..n2) s = format_score(s) -- following codes obtained from Module:Sports results -- delink if necessary if s:match('^%s*%[%[[^%[%]]*%|([^%[%]]*)%]%]') then s = s:match('^%s*%[%[[^%[%]]*%|([^%[%]]*)%]%]') end if s:match('^%s*%[[^%[%]%s]*%s([^%[%]]*)%]') then s = s:match('^%s*%[[^%[%]%s]*%s([^%[%]]*)%]') end -- get the scores local s1 = tonumber(mw.ustring.gsub( s or '', '^%s*([%d][%d%.]*)%s*β%s*([%d][%d%.]*).*', '%1' ) or nil) or mw.ustring.gsub(s or '', '^([WL]*)β([WL]*).*', '%1' ) or '' local s2 = tonumber(mw.ustring.gsub( s or '', '^%s*([%d][%d%.]*)%s*β%s*([%d][%d%.]*).*', '%2' ) or nil) or mw.ustring.gsub(s or '', '^([WL]*)β([WL]*).*', '%2' ) or '' if type(s1) == 'number' and type(s2) == 'number' then return (s1 > s2) and 'W' or ((s2 > s1) and 'L' or 'T') elseif s1:match('[WL]') and s2:match('[WL]') and s1 ~= s2 then return s1 else return string.format("''%s''", 'Result unknown') end end return p
Summary:
Please note that all contributions to Stockhub 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
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:High-use
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:TOC limit
(
edit
)
Template:Tl2
(
edit
)
Module:Arguments
(
edit
)
Module:Check winner by scores/doc
(
edit
)
Module:Effective protection level
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Yesno
(
edit
)