LLWiki正在建设中,欢迎加入我们!
“模块:Sifitem”的版本间差异
跳转到导航
跳转到搜索
小 (在判断颜色时转换arg2为小写) |
|||
第1行: | 第1行: | ||
-- Module:Sifitem |
|||
-- Made with ♥ by User:Leranjun |
-- Made with ♥ by User:Leranjun |
||
-- This module implements {{tl|Sifitem}}. |
|||
-- Please refrain from invoking this module directly. |
|||
local p = {} |
local p = {} |
||
第9行: | 第5行: | ||
local getArgs = require("Module:Arguments").getArgs |
local getArgs = require("Module:Arguments").getArgs |
||
local AKA = {["金币"] = "g", |
|||
local FILES = mw.loadData("Module:Sifitem/data") |
|||
["pt"] = "友情pt", |
|||
local BORDER_KW = {["有底"] = true, ["有框"] = true, ["粉底"] = true, ["底"] = true, ["框"] = true} |
|||
["爱心"] = "loveca", ["心"] = "loveca", |
|||
local COLORS = { |
|||
[" |
["lp50"] = "方糖", |
||
["糖罐50%"] = "糖罐50", ["lp50%"] = "糖罐50", |
|||
"Smile", |
|||
" |
["果冻"] = "糖浆", ["lp5"] = "糖浆", |
||
["糖罐100%"] = "糖罐100", ["lp100%"] = "糖罐100", |
|||
}, |
|||
["exp御守"] = "经验提升御守", ["经验御守"] = "经验提升御守", ["exp提升御守"] = "经验提升御守", |
|||
["red"] = { |
|||
["金币御守"] = "金币提升御守", ["g御守"] = "金币提升御守", |
|||
["aka"] = "smile" |
|||
["绊点御守"] = "绊点提升御守", ["绊御守"] = "绊点提升御守", |
|||
}, |
|||
["钥匙"] = "活动剧情解锁钥匙", ["剧情钥匙"] = "活动剧情解锁钥匙", |
|||
["pure"] = { |
|||
["优等生招募券"] = "招募券", ["绿券"] = "招募券", ["薄荷券"] = "招募券", |
|||
"Pure", |
|||
["补助券"] = "辅助券", ["蓝券"] = "辅助券", ["机票"] = "辅助券", |
|||
"#2da55a" |
|||
["sr交换券"] = "活动sr交换券", |
|||
}, |
|||
[" |
["彩贴纸"] = "u贴纸", ["彩贴"] = "u贴纸", |
||
["金贴纸"] = "ss贴纸", ["金贴"] = "ss贴纸", |
|||
["银贴纸"] = "s贴纸", ["银贴"] = "s贴纸", |
|||
}, |
|||
["粉贴纸"] = "贴纸", ["粉贴"] = "贴纸", ["n贴纸"] = "贴纸", ["r贴纸"] = "贴纸", |
|||
["cool"] = { |
|||
["专用贴纸"] = "活动ur觉醒专用贴纸", ["活动ur专用贴纸"] = "活动ur觉醒专用贴纸", |
|||
"Cool", |
|||
["剧情"] = "活动剧情" |
|||
}, |
|||
["blue"] = { |
|||
["aka"] = "cool" |
|||
}, |
|||
["all"] = { |
|||
"", |
|||
"#9a55cc" |
|||
}, |
|||
["purple"] = { |
|||
["aka"] = "all" |
|||
} |
|||
} |
} |
||
local ITEMS = {["g"] = {before = "", after = " G"}, |
|||
local LEVELS = { |
|||
[" |
["友情pt"] = {file = "友情pt", after = " pt"}, |
||
[" |
["loveca"] = {file = "Loveca", after = "个", default = 1}, |
||
["体力恢复道具"] = {file = "体力恢复道具【LP50】", after = "个", default = 1}, |
|||
["sr"] = "Item icon 14", |
|||
[" |
["方糖"] = {file = "方糖【LP50】", after = "块", default = 1}, |
||
["糖罐50"] = {file = "糖罐【LP50%】", after = "个", default = 1}, |
|||
["n"] = "Item icon 85" |
|||
["糖浆"] = {file = "糖浆【LP5】", after = "个", default = 1}, |
|||
["糖罐100"] = {file = "糖罐【LP100%】", after = "个", default = 1}, |
|||
["经验提升御守"] = {after = "个", default = 1}, |
|||
["金币提升御守"] = {after = "个", default = 1}, |
|||
["绊点提升御守"] = {after = "个", default = 1}, |
|||
["活动剧情解锁钥匙"] = {after = "把", default = 1}, |
|||
["称号"] = {before = "称号“", after = "”", force2 = true}, |
|||
["背景"] = {before = "【背景】"}, |
|||
["表情"] = {before = "【表情】"}, |
|||
["招募券"] = {after = "张", default = 1}, |
|||
["辅助券"] = {after = "张", default = 1}, |
|||
["活动sr交换券"] = {switch = { |
|||
["缪斯"] = " μ's", ["μ's"] = " μ's", ["μ"] = " μ's", ["μ’s"] = " μ's", ["缪"] = " μ's", |
|||
["aqours"] = " Aqours", ["水"] = " Aqours" |
|||
}, after = "枚", default = 1}, |
|||
["u贴纸"] = {after = "枚", default = 1}, |
|||
["ss贴纸"] = {after = "枚", default = 1}, |
|||
["s贴纸"] = {after = "枚", default = 1}, |
|||
["贴纸"] = {after = "枚", default = 1}, |
|||
["活动ur觉醒专用贴纸"] = {after = "枚", default = 1}, |
|||
["活动剧情"] = {} |
|||
} |
} |
||
local function notempty(s) |
|||
return (s and s ~= "") |
|||
end |
|||
function p.main(frame) |
function p.main(frame) |
||
local args = getArgs(frame, {removeBlanks = false}) |
|||
return p._main(args) |
|||
end |
end |
||
function p._main(args, frame) |
function p._main(args, frame) |
||
local arg1, arg2, arg3 = mw.ustring.lower(args[1] or ""), args[2], |
local arg1, arg2, arg3 = mw.ustring.lower(args[1] or ""), args[2], args[3] |
||
local |
local item = AKA[arg1] or arg1 |
||
local data = ITEMS[item] |
|||
if not data then |
|||
return "" |
|||
end |
|||
local file = data.file or mw.ustring.upper(item) |
|||
if (FILES[arg1]) then |
|||
local r = "<span class=\"game-item\">[[file:SIF "..file |
|||
if (data.switch) then |
|||
r = r..(data.switch[arg3] or "") |
|||
end |
|||
local src = "" |
|||
if (data.switch) then |
|||
src = (data[data.switch[arg3]] or data[1]) |
|||
else |
|||
if (BORDER_KW[arg3] and data[2]) then |
|||
src = data[2] |
|||
else |
|||
src = data[1] |
|||
end |
|||
end |
|||
src = frame:callParserFunction("filepath", src .. ".png") |
|||
r = r .. tostring(mw.html.create("img"):attr("src", src):css("width", "24px")) .. " " .. data.before |
|||
local after = {} |
|||
if (data.after[1]) then |
|||
after = data.after |
|||
else |
|||
after[1] = data.after |
|||
end |
|||
if (arg2 ~= "0") then |
|||
if (data.force2 or notempty(arg2)) then |
|||
r = r .. arg2 .. after[1] |
|||
else |
|||
r = r .. (data.default or "1") .. after[1] |
|||
end |
|||
else |
|||
if (data.force2) then |
|||
r = r .. "{{{2}}}" |
|||
end |
|||
r = r .. (after[2] or "") |
|||
end |
|||
elseif (COLORS[arg1]) then |
|||
local data = COLORS[arg1] |
|||
if (data.aka) then |
|||
data = COLORS[data.aka] |
|||
end |
|||
r = r .. frame:preprocess("[[File:sif" .. data[1] .. ".png|20px|link=]] ") |
|||
r = r .. frame:expandTemplate {title = "color", args = {data[2], (arg2 or data[1])}} |
|||
else |
else |
||
r = r..(arg3 and " 有框" or "") |
|||
src = frame:callParserFunction("filepath", src .. ".png") |
|||
r = r .. tostring(mw.html.create("img"):attr("src", src):css("width", "24px")) .. " " |
|||
if (notempty(arg2) or notempty(arg3)) then |
|||
local color = "" |
|||
if (COLORS[mw.ustring.lower(arg2)]) then |
|||
color = COLORS[mw.ustring.lower(arg2)][2] |
|||
elseif (COLORS[arg3]) then |
|||
color = COLORS[arg3][2] |
|||
else |
|||
color = "black" |
|||
end |
|||
local content = "" |
|||
if (COLORS[arg3]) then |
|||
content = frame:preprocess("'''" .. arg2 .. "'''") |
|||
else |
|||
content = frame:preprocess("'''" .. arg3 .. "'''") |
|||
end |
|||
r = r .. frame:expandTemplate {title = "color", args = {color, content}} |
|||
end |
|||
end |
end |
||
r = r..".png|40px|link=]</span> "..(data.before or file)..(arg2 or data.default)..(data.after or "") |
|||
return r |
return r |
||
end |
end |
2021年1月3日 (日) 06:10的版本
-- Made with ♥ by User:Leranjun local p = {} local getArgs = require("Module:Arguments").getArgs local AKA = {["金币"] = "g", ["pt"] = "友情pt", ["爱心"] = "loveca", ["心"] = "loveca", ["lp50"] = "方糖", ["糖罐50%"] = "糖罐50", ["lp50%"] = "糖罐50", ["果冻"] = "糖浆", ["lp5"] = "糖浆", ["糖罐100%"] = "糖罐100", ["lp100%"] = "糖罐100", ["exp御守"] = "经验提升御守", ["经验御守"] = "经验提升御守", ["exp提升御守"] = "经验提升御守", ["金币御守"] = "金币提升御守", ["g御守"] = "金币提升御守", ["绊点御守"] = "绊点提升御守", ["绊御守"] = "绊点提升御守", ["钥匙"] = "活动剧情解锁钥匙", ["剧情钥匙"] = "活动剧情解锁钥匙", ["优等生招募券"] = "招募券", ["绿券"] = "招募券", ["薄荷券"] = "招募券", ["补助券"] = "辅助券", ["蓝券"] = "辅助券", ["机票"] = "辅助券", ["sr交换券"] = "活动sr交换券", ["彩贴纸"] = "u贴纸", ["彩贴"] = "u贴纸", ["金贴纸"] = "ss贴纸", ["金贴"] = "ss贴纸", ["银贴纸"] = "s贴纸", ["银贴"] = "s贴纸", ["粉贴纸"] = "贴纸", ["粉贴"] = "贴纸", ["n贴纸"] = "贴纸", ["r贴纸"] = "贴纸", ["专用贴纸"] = "活动ur觉醒专用贴纸", ["活动ur专用贴纸"] = "活动ur觉醒专用贴纸", ["剧情"] = "活动剧情" } local ITEMS = {["g"] = {before = "", after = " G"}, ["友情pt"] = {file = "友情pt", after = " pt"}, ["loveca"] = {file = "Loveca", after = "个", default = 1}, ["体力恢复道具"] = {file = "体力恢复道具【LP50】", after = "个", default = 1}, ["方糖"] = {file = "方糖【LP50】", after = "块", default = 1}, ["糖罐50"] = {file = "糖罐【LP50%】", after = "个", default = 1}, ["糖浆"] = {file = "糖浆【LP5】", after = "个", default = 1}, ["糖罐100"] = {file = "糖罐【LP100%】", after = "个", default = 1}, ["经验提升御守"] = {after = "个", default = 1}, ["金币提升御守"] = {after = "个", default = 1}, ["绊点提升御守"] = {after = "个", default = 1}, ["活动剧情解锁钥匙"] = {after = "把", default = 1}, ["称号"] = {before = "称号“", after = "”", force2 = true}, ["背景"] = {before = "【背景】"}, ["表情"] = {before = "【表情】"}, ["招募券"] = {after = "张", default = 1}, ["辅助券"] = {after = "张", default = 1}, ["活动sr交换券"] = {switch = { ["缪斯"] = " μ's", ["μ's"] = " μ's", ["μ"] = " μ's", ["μ’s"] = " μ's", ["缪"] = " μ's", ["aqours"] = " Aqours", ["水"] = " Aqours" }, after = "枚", default = 1}, ["u贴纸"] = {after = "枚", default = 1}, ["ss贴纸"] = {after = "枚", default = 1}, ["s贴纸"] = {after = "枚", default = 1}, ["贴纸"] = {after = "枚", default = 1}, ["活动ur觉醒专用贴纸"] = {after = "枚", default = 1}, ["活动剧情"] = {} } function p.main(frame) local args = getArgs(frame, {removeBlanks = false}) return p._main(args) end function p._main(args, frame) local arg1, arg2, arg3 = mw.ustring.lower(args[1] or ""), args[2], args[3] local item = AKA[arg1] or arg1 local data = ITEMS[item] if not data then return "" end local file = data.file or mw.ustring.upper(item) local r = "<span class=\"game-item\">[[file:SIF "..file if (data.switch) then r = r..(data.switch[arg3] or "") else r = r..(arg3 and " 有框" or "") end r = r..".png|40px|link=]</span> "..(data.before or file)..(arg2 or data.default)..(data.after or "") return r end return p