模組:沙盒/Lopullinen
外观
测试区
[编辑]- 0
- 0
- 0
- 0
50級或以上維基ACG獎
- Nostalgiacn:1107分
- Jacklamf1d14:757分
- SilverReaper:619分
40至49級維基ACG獎
30至39級維基ACG獎
- Hopefuljr:397分
- Venuesmathis:327分
- Easterlies:301分
20至29級維基ACG獎
- BlackShadowG:291分
- Ericliu1912:275分
- SuperGrey:273分
- EzrealChen:256分
- Sekaimeisakugekijou:249分
- Mike8411251995:215分
10至19級維基ACG獎
- Fglffer:189分
- BrianBYBYBY:187分
- Yumeto:184分
- For Each element In group ... Next:176分
- Rogidomain:166分
- Hinadori:163分
- Summerize:161分
- Eky:160分
- Cp111:145分
- Yans1230:143分
- Game1524:140分
- 深鸣:138分
- T.A Shirakawa:131分
- Fs155117:119分
- Prince of Erebor:119分
- Milkypine:118分
- RalfX:117分
- Leungkaiyin:113分
- Dqwyy:106分
5至9級維基ACG獎
- Sadiosdo:99分
- Onlymyself65536:98分
- 金肅:93分
- Jarodalien:90分
- Wing1438:90分
- A02:85分
- HoweyYuan:83分
- TX55:82分
- MilkyDefer:81分
- 1j1z2:73分
- P1ayer:71分
- 香港散步:69分
- Gundamfox:60分
- Kly:59分
- Oowashi:59分
- Wangxuan8331800:59分
- Ryokie38:58分
- Chiefwei:57分
- Leon3289:55分
- Liaon98:55分
- Sysywjel:55分
- Loldoubao:54分
- Bowleerin:52分
- 人间百态:52分
- 影之诗:52分
- 楓名:52分
- Chibc:50分
- Fyd09:50分
4級維基ACG獎
- Altt311:47分
- Ivysia:45分
- 我不喝拿鐵:45分
- About123:44分
- Franklsf95:44分
- Iqeqicq:44分
- Steven81514:44分
- Gbcat:43分
- Knuckmew:42分
- 胡葡萄:42分
- Akito17:41分
- Red16:40分
- Xmhaoyu:40分
3級維基ACG獎
- Asukav396:39分
- Ccc75624:39分
- Dnssgh:38分
- IAF~zhwiki:38分
- Shakiestone:38分
- Yypear:38分
- ZABORGER:35分
- Hwoarang17:34分
- Kslcjds:34分
- 街角遇見貓:34分
- Factrecordor:33分
- Niceboat:33分
- Catzilla:32分
- Minbean:32分
- Msh.spike:32分
- Fantasy Machine:31分
- Huangdan2060:31分
- Kivary:31分
- Sophiezoy:31分
- Wongpong:31分
- -Zest:30分
- 919sth.:30分
- Asdsk123:30分
- SourceII:30分
2級維基ACG獎
- Gslin:29分
- Mint2005:29分
- Signmin:29分
- 120242pp:28分
- Cdjhook:28分
- Sinaskn:28分
- Zheengzjjin:28分
- Anilro:27分
- Edwardtp:27分
- NaruTaku:27分
- WildDagger:27分
- Cookai1205:26分
- Flamelai:25分
- Idangyang:25分
- 江舟孤雪:25分
- FoundKey:24分
- Jnlin:24分
- Matthaeus:23分
- PhiLiP:23分
- 威因:23分
- 林佩錡:23分
- JuneAugust:22分
- Tgbyhn123:22分
- Theodore Xu:22分
- Tony110886:22分
- Luojie-dune:21分
- 屠麟傲血:21分
- Davidzdh:20分
- Lff985:20分
- PkmX:20分
- VegBird3:20分
- Zollac:20分
1級維基ACG獎
- ASHillocks:19分
- Peryton:19分
- 影 綾奈:19分
- Saber568438:18分
- Ted1lll1:18分
- ZhWikiRage:18分
- BrockF5:17分
- Delacour:17分
- Prince Max:17分
- Airbunny:16分
- BreakdownDiode:16分
- CCSX:16分
- Loveyouchun:16分
- MargokDN:16分
- Menjuriak:16分
- Olaf8940:16分
- Rogeryu:16分
- Suezou:16分
- Ad2003:15分
- Hal_0005:15分
- Johnleung2000s:15分
- KOKUYO:15分
- Lssrn:15分
- Wiki79540:15分
- Wirepole:15分
- Woc2006:15分
- Johnkeats:14分
- Ray1118x:14分
- 一太子一:14分
- 希望之光300:14分
- 虚空幻翼:14分
- JeanHavoc:13分
- Mikepanhu:13分
- Tonyxp:13分
- Zanhsieh:13分
- Zilong0419:13分
- 腐屍王:13分
- Billeccentrec:12分
- Brookqi:12分
- Chia 777:12分
- Yzyzsun:12分
- 夢甜芯:12分
- 櫻賀悠鈴:12分
- 赤目之夢兒:12分
- AdomiZ:11分
- Camouflaged Mirage:11分
- Cxnasya:11分
- Hihipk:11分
- Ks.magi:11分
- Achanhk:10分
- Bmwman:10分
- C933103:10分
- Chenchaoyi:10分
- Cwek:10分
- Dee2 Chan:10分
- Fantasticfears:10分
- Lpxws:10分
- MONEY972008:10分
- Mouse20080706:10分
- Nefrezx:10分
- Patvoiiage:10分
- Suiseiseki:10分
- Yaobinman:10分
- 小文人:10分
备忘录
[编辑]-- 获取页面信息
mw.title.getCurrentTitle().text -- 獲取頁面標題,不含命名空間
-- 调用Mediawiki模板
mw.getCurrentFrame():expandTemplate{ title = "template", args = { "arg1", "arg2", name = "arg3" } } -- {{template|args1|args2|name=args3}}
mw.getCurrentFrame():callParserFunction{ name = "#tag", args = { "nowiki", "some text" } } -- {{#tag:nowiki|some text}}
-- 字符串处理
_, _, capture1, capture2 = mw.ustring.find(source_text, "(.+)blah blah(.+)") -- 分組捕獲
new_string = mw.ustring.gsub(old_string, ptn, replacement) -- 替换
require("strict")
local strf = mw.ustring.format
local getArgs = require('Module:Arguments').getArgs
--- @alias Username string
--- @alias Score number
--- @alias Level number
--- @alias RecordMapping table<Username, Score>
--- @alias Wikitext string
--- @class UserScore
--- @field user Username
--- @field score Score
--- @class UserScoreDelta
--- @field user Username
--- @field current Score
--- @field delta Score
--- For setting the score ranking thresholds.
--- @type Level[]
local LEVEL_NODES = { math.huge, 50, 40, 30, 20, 10, 5, 4, 3, 2, 1, 0 }
--- @type RecordMapping
local CURRENT_RECORD_MAPPING = mw.loadData("Module:ACGaward/list/old")
--- Return a normalized username or current page base name if nil.
--- @param user Username | nil @Optional username to be normalized.
--- @return Username @The normalized username or current page base name.
local function fetch_username(user)
if user == nil then
return mw.title.getCurrentTitle().baseText
end
local username = user -- TODO: To be normalized.
return username
end
--- Return name and recorded score from the given record mapping.
--- If the username is not recorded, the score will be 0.
--- @param mapping RecordMapping @Mapping of username to score.
--- @param user Username | nil @Optional username to look up.
--- @return Username, Score
local function get_record(mapping, user)
local name = fetch_username(user)
return name, (mapping[name] or 0)
end
--- Convert an internal score to the integer score.
--- @param score Score @The score might have a decimal part.
--- @return Score @The score as an integer.
local function calculate_public_score(score)
return math.floor(score)
end
--- Convert a score to its corresponding ACG-award level.
--- @param score Score @The score to convert to its level.
--- @return Level @The level as an integer.
local function calculate_level(score)
return math.floor(score / 10)
end
--- Get a normalized score for a user from record mapping.
--- @param mapping RecordMapping @Mapping of username to score.
--- @param user Username | nil @Optional username to look up.
--- @return Score
local function get_score(mapping, user)
local _, score = get_record(mapping, user)
return calculate_public_score(score)
end
--- Get a normalized level for a user from record mapping.
--- @param mapping RecordMapping @Mapping of username to score.
--- @param user Username | nil @Optional username to look up.
--- @return Level
local function get_level(mapping, user)
local _, score = get_record(mapping, user)
return calculate_level(score)
end
--- Get a list sorted by score in descending order.
--- @param mapping RecordMapping
--- @return UserScore[]
local function get_sorted_user_score_list(mapping)
local result = {}
for k, v in pairs(mapping) do
local item = { user = k, score = calculate_public_score(v) }
table.insert(result, item)
end
local sorter = function(a, b)
if a.score == b.score then
return a.user < b.user
end
return a.score > b.score
end
table.sort(result, sorter)
return result
end
--- Create wikicode ranking for users within level bounds.
--- @param list UserScore[] @Sequence of UserScore tuples to include.
--- @param lbound Level @The lower bound of level (included).
--- @param ubound Level @The upper bound of level (excluded).
--- @param start number @Starting number for the ordered list.
--- @return Wikitext @Formatted wikicode for the subset ranking.
local function create_subset_ranking(list, lbound, ubound, start)
if #list == 0 then
return
end
local lines = {}
-- header
local header
if ubound == math.huge then
header = tostring(lbound) .. "級或以上維基ACG獎"
elseif ubound - lbound == 1 then
header = tostring(lbound) .. "級維基ACG獎"
else
header = tostring(lbound) .. "至" .. tostring(ubound - 1) .. "級維基ACG獎"
end
header = "<b>" .. header .. "</b>"
table.insert(lines, header)
-- list body
local line = strf('<ol start="%s">', start)
table.insert(lines, line)
for _, v in ipairs(list) do
line = strf("<li>[[User:%s|%s]]:%s分", v.user, v.user, v.score)
table.insert(lines, line)
end
table.insert(lines, "</ol>")
-- return
return table.concat(lines, '\n')
end
--- Build a complete ranking of users grouped by level in wikicode.
--- @param mapping RecordMapping
--- @return Wikitext
local function build_ranking(mapping)
local score_list = get_sorted_user_score_list(mapping)
local subset_ranking_parts = {}
-- loop
local sub_score_list = {}
local rank = 0
local node_index = 1
for i, user in ipairs(score_list) do
local user_level = calculate_level(user.score)
while user_level < LEVEL_NODES[node_index] do
local subset_ranking = create_subset_ranking(
sub_score_list,
LEVEL_NODES[node_index],
LEVEL_NODES[node_index - 1],
rank
)
table.insert(subset_ranking_parts, subset_ranking)
-- reset for the next level
sub_score_list = {}
rank = i
node_index = node_index + 1
end
table.insert(sub_score_list, user)
end
return table.concat(subset_ranking_parts, '\n')
end
local p = {}
local function makeInvokeFunc(funcName)
return function(frame)
local args = getArgs(frame)
return p[funcName](args)
end
end
p.score = makeInvokeFunc("_score")
function p._score(args)
local mapping = CURRENT_RECORD_MAPPING
local user = args[1]
return get_score(mapping, user)
end
p.level = makeInvokeFunc("_level")
function p._level(args)
local mapping = CURRENT_RECORD_MAPPING
local user = args[1]
return get_level(mapping, user)
end
p.ranking = makeInvokeFunc("_ranking")
function p._ranking(args)
local mapping = CURRENT_RECORD_MAPPING
return build_ranking(mapping)
end
return p