WIKI公告栏
欢迎各位引航者访问卡拉彼丘WIKI,由于游客访问页面会有一定的页面旧版缓存,建议你登陆B站账号进行浏览,如果您觉得本WIKI有帮助到你,欢迎推荐给身边的引航者。
欢迎各位引航者访问卡拉彼丘WIKI,由于游客访问页面会有一定的页面旧版缓存,建议你登陆B站账号进行浏览,如果您觉得本WIKI有帮助到你,欢迎推荐给身边的引航者。
全站通知:
模块:角色礼物
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:角色礼物/doc创建
local p = {}
local a = require("Module:ACandy")
local function getPageTitle()
return mw.title.getCurrentTitle().text
end
local data = mw.text.jsonDecode(mw.title.new('Module:角色礼物/Data.json'):getContent() or '{}')
local quality_map = {
["私服"] = 6,
["传说"] = 5,
["完美"] = 4,
["卓越"] = 3,
["精致"] = 2,
["优秀"] = 1
}
local char = ""
function compare(g1, g2)
if g1.Quality ~= g2.Quality or char == "" then
return quality_map[g1.Quality] > quality_map[g2.Quality]
end
return g1.Favorability[char] > g2.Favorability[char]
end
function sort_data()
temp = {}
for k, v in pairs(data) do
table.insert(temp, v)
end
table.sort(temp, compare)
return temp
end
--定义一个辅助函数,根据 Favorability 值设置背景颜色
local function createFavorabilityCell(value)
if value == 180 then
return a.td { style = "background-color: rgba(255, 140, 105, 0.6);text-align: center;", value }
else
return a.td { style = "text-align: center", value }
end
end
-- 角色页面礼物好感
p["角色礼物好感"] = function(frame)
local gifttype = frame.args["活动礼物"]
local name = getPageTitle()
local resultList = {}
char = name
data = sort_data()
for value, rolename in ipairs(data) do
if gifttype == nil then
if rolename.Activities == false then
local rolegiftsHTML = p.tablestyle(name, rolename.File, rolename.Name, rolename.Desc_string, rolename.Quality, rolename.Favorability, frame)
table.insert(resultList, rolegiftsHTML)
end
else
if rolename.Activities == true then
local rolegiftsHTML = p.tablestyle(name, rolename.File, rolename.Name, rolename.Desc_string, rolename.Quality, rolename.Favorability, frame)
table.insert(resultList, rolegiftsHTML)
end
end
end
local result = table.concat(resultList)
return result
end
function p.tablestyle(name, File, Name, Desc_string, Quality, Favorability, frame)
local rolegiftsHTML = tostring(a.tr {
a.td { style = "text-align: center;", a.Raw("[[文件:"), File, a.Raw("|70px|link=]]"),
a.br, a.Raw("'''"), Name , a.Raw("'''") },
a.td { class = "visible-md visible-sm visible-lg", Desc_string },
a.td { style = "text-align: center;", a.Raw(
frame:expandTemplate { title = "稀有度标签", args = { Quality } }) },
createFavorabilityCell(Favorability[name]),
})
return rolegiftsHTML
end
--誓约页面礼物好感表
p["礼物好感表"] = function(frame)
local gifttype = frame.args["活动礼物"]
local resultList = {}
local data = sort_data()
for value, rolegifts in ipairs(data) do
if gifttype == nil then
if rolegifts.Activities == false then
local rolegiftsHTML = p.tablestyle2(name, rolegifts.File, rolegifts.Name, rolegifts.Desc_string, rolegifts.Quality, rolegifts.Favorability, frame)
table.insert(resultList, rolegiftsHTML)
end
else
if rolegifts.Activities == true then
local rolegiftsHTML = p.tablestyle2(name, rolegifts.File, rolegifts.Name, rolegifts.Desc_string, rolegifts.Quality, rolegifts.Favorability, frame)
table.insert(resultList, rolegiftsHTML)
end
end
end
local result = table.concat(resultList)
return result
end
function p.tablestyle2(name, File, Name, Desc_string, Quality, Favorability, frame)
local rolegiftsHTML = tostring(a.tr {
a.td { style = "text-align: center;", a.Raw("[[文件:"), File, a.Raw("|70px|link=]]"),
a.br, a.Raw("'''"), Name , a.Raw("'''") },
a.td { class = "visible-md visible-sm visible-lg", Desc_string },
a.td { style = "text-align: center;", a.Raw(
frame:expandTemplate { title = "稀有度标签", args = { Quality } }) },
createFavorabilityCell(Favorability["米雪儿·李"]),
createFavorabilityCell(Favorability["奥黛丽·格罗夫"]),
createFavorabilityCell(Favorability["星绘"]),
createFavorabilityCell(Favorability["拉薇"]),
createFavorabilityCell(Favorability["心夏"]),
createFavorabilityCell(Favorability["玛德蕾娜·利里"]),
createFavorabilityCell(Favorability["伊薇特"]),
createFavorabilityCell(Favorability["香奈美"]),
createFavorabilityCell(Favorability["绯莎"])
})
return rolegiftsHTML
end
return p