全站通知:
模块:数据库调用
刷
历
编
跳到导航
跳到搜索
local p = {}
-- 加载指定页面
local getJsonPage = require('模块:数据库内容')
---拆分字符串
---@param str string 被拆分的源字符串
---@param sep string 拆分的
function string.split(str, sep)
local result = {}
if str == nil or sep == nil or type(str) ~= "string" or type(sep) ~= "string" then
return result
end
if string.len(sep) == 0 then
return result
end
local pattern = string.format("([^%s]+)", sep)
--print(pattern)
string.gsub(
str,
pattern,
function(c)
result[#result + 1] = c
end
)
return result
end
function processPropData(frame, data)
-- 稀有度
frame:callParserFunction{
name = '#vardefine',
args = {'稀有度', data.rarity}
}
-- 稀有度颜色
local rColor
if data.rarity == "UR" then
rColor = "#f36009"
elseif data.rarity == "SSR" then
rColor = "#fdc116"
elseif data.rarity == "SR" then
rColor = "#ab27fd"
elseif data.rarity == "R" then
rColor = "#2773fd"
else
rColor = "#bbbbbb"
end
frame:callParserFunction{
name = '#vardefine',
args = {'稀有度颜色', rColor}
}
-- 分类
frame:callParserFunction{name = '#vardefine', args = {'分类', data.sort}}
-- 子分类
frame:callParserFunction{
name = '#vardefine',
args = {'子分类', data.sortSub}
}
-- 获取途径
frame:callParserFunction{
name = '#vardefine',
args = {'获取途径', data.acquisitionMode}
}
-- 信息(简介)
frame:callParserFunction{name = '#vardefine', args = {'信息', data.info}}
end
function procseeWeaponData(frame, data)
-- 武器类型
frame:callParserFunction{
name = '#vardefine',
args = {'装备类型', data.sort}
}
frame:callParserFunction{
name = '#vardefine',
args = {'装备阵营', data.factions}
}
local factionsPerk = ""
if data.factions == "铁盟" then
factionsPerk = "铁盟专属词缀"
elseif data.factions == "学会" then
factionsPerk = "学会专属词缀"
elseif data.factions == "黑月" then
factionsPerk = "黑月专属词缀"
elseif data.factions == "帝国" then
factionsPerk = "帝国专属词缀"
elseif data.factions == "阿妮塔" then
factionsPerk = "阿妮塔专属词缀"
elseif data.factions == "混沌海" then
factionsPerk = "混沌海专属词缀"
end
-- 创建变量 args1变量名 args2 变量值
frame:callParserFunction{
name = '#vardefine',
args = {'追加词缀库', factionsPerk}
}
frame:callParserFunction{
name = '#vardefine',
args = {'主词缀', data.mainPerk}
}
frame:callParserFunction{
name = '#vardefine',
args = {'装备数值类型', data.valueName}
}
frame:callParserFunction{
name = '#vardefine',
args = {'装备数值初始', data.value0}
}
frame:callParserFunction{
name = '#vardefine',
args = {'装备数值满级', data.valueMax}
}
frame:callParserFunction{
name = '#vardefine',
args = {'兑换途径', data.exchangeWay}
}
local str = [[
]]
local result
local exchangeWay_list = mw.text.split(data.exchangeWay,",")
local exchangeMaterialAll_list = mw.text.split(data.exchangeMaterial,",")
for i,exchangeWay in pairs(exchangeWay_list) do
if str ~= [[]] then
str = str..[[
|-
]]
end
str = str.."||[["..exchangeWay_list[i].."]]".."||"
local exchangeMaterial = mw.text.split(exchangeMaterialAll_list[i],"、")
for j, material in pairs(exchangeMaterial) do
material = mw.text.trim(material)
if material ~= '' then
result = mw.text.split(material,':')
if result[2] ~= nil and result[2] ~= "" then
str = str..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {result[1],result[2],["尺寸"]="中"}
})
else
str = str..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {result[1],["尺寸"]="中"}
})
end
end
end
end
frame:callParserFunction{
name = '#vardefine',
args = {'兑换表格', str}
}
end
function processInventoryData(frame, data)
-- 物品池
frame:callParserFunction{
name = '#vardefine',
args = {'物品池', DataToImg(frame, data.propInBox)}
}
frame:callParserFunction{
name = '#vardefine',
args = {'兑换途径', data.exchangeWay}
}
local str = [[
]]
local result
local exchangeWay_list = mw.text.split(data.exchangeWay,",")
local exchangeMaterialAll_list = mw.text.split(data.exchangeMaterial,",")
for i,exchangeWay in pairs(exchangeWay_list) do
if str ~= [[]] then
str = str..[[
|-
]]
end
str = str.."||[["..exchangeWay_list[i].."]]".."||"
local exchangeMaterial = mw.text.split(exchangeMaterialAll_list[i],"、")
for j, material in pairs(exchangeMaterial) do
material = mw.text.trim(material)
if material ~= '' then
result = mw.text.split(material,':')
if result[2] ~= nil and result[2] ~= "" then
str = str..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {result[1],result[2],["尺寸"]="中"}
})
else
str = str..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {result[1],["尺寸"]="中"}
})
end
end
end
end
frame:callParserFunction{
name = '#vardefine',
args = {'兑换表格', str}
}
end
function procseeGoodsData(frame, data)
-- 解锁方式
frame:callParserFunction{
name = '#vardefine',
args = {'解锁方式', data.unlockMode}
}
end
function procseeMaterialData(frame, data)
frame:callParserFunction{
name = '#vardefine',
args = {'回收价格', data.reward}
}
frame:callParserFunction{
name = '#vardefine',
args = {'回收途径', data.reward_way}
}
frame:callParserFunction{
name = '#vardefine',
args = {'使用途径', data.use_way}
}
end
function procseeTrainWeaponData(frame, data)
-- 超载核心等级
frame:callParserFunction{
name = '#vardefine',
args = {'超载核心等级', data.electric}
}
-- 熔炉核心等级
frame:callParserFunction{
name = '#vardefine',
args = {'熔炉核心等级', data.fire}
}
-- 冷凝核心等级
frame:callParserFunction{
name = '#vardefine',
args = {'冷凝核心等级', data.ice}
}
-- 混响核心等级
frame:callParserFunction{
name = '#vardefine',
args = {'混响核心等级', data.reverb}
}
-- 负能核心等级
frame:callParserFunction{
name = '#vardefine',
args = {'负能核心等级', data.negative}
}
-- 电力负荷
frame:callParserFunction{
name = '#vardefine',
args = {'电力负荷', data.powerLoad}
}
-- 速度降低
frame:callParserFunction{
name = '#vardefine',
args = {'速度降低', data.speedDroop}
}
-- 速度降低
frame:callParserFunction{
name = '#vardefine',
args = {'速度降低', data.speedDroop}
}
-- 武装效果
frame:callParserFunction{
name = '#vardefine',
args = {'武装效果', data.growUpEntry}
}
-- 撞击类型
frame:callParserFunction{
name = '#vardefine',
args = {'撞击类型', data.hitEventType}
}
-- 疲劳消耗
frame:callParserFunction{
name = '#vardefine',
args = {'疲劳消耗', data.weaponTired}
}
if string.find(data.hitEventType, "一般路障") then
frame:callParserFunction{
name = '#vardefine',
args = {'一般路障', "是"}
}
end
if string.find(data.hitEventType, "机械单位") then
frame:callParserFunction{
name = '#vardefine',
args = {'机械单位', "是"}
}
end
if string.find(data.hitEventType, "易燃易爆路障") then
frame:callParserFunction{
name = '#vardefine',
args = {'易燃易爆路障', "是"}
}
end
if string.find(data.hitEventType, "深眠者") then
frame:callParserFunction{
name = '#vardefine',
args = {'深眠者', "是"}
}
end
if string.find(data.hitEventType, "地面桦树生物") then
frame:callParserFunction{
name = '#vardefine',
args = {'地面桦树生物', "是"}
}
end
if string.find(data.hitEventType, "浮空桦树生物") then
frame:callParserFunction{
name = '#vardefine',
args = {'浮空桦树生物', "是"}
}
end
frame:callParserFunction{
name = '#vardefine',
args = {'兑换途径', data.exchangeWay}
}
local str = [[
]]
local result
local exchangeWay_list = mw.text.split(data.exchangeWay,",")
local exchangeMaterialAll_list = mw.text.split(data.exchangeMaterial,",")
for i,exchangeWay in pairs(exchangeWay_list) do
if str ~= [[]] then
str = str..[[
|-
]]
end
str = str.."||[["..exchangeWay_list[i].."]]".."||"
local exchangeMaterial = mw.text.split(exchangeMaterialAll_list[i],"、")
for j, material in pairs(exchangeMaterial) do
material = mw.text.trim(material)
if material ~= '' then
result = mw.text.split(material,':')
if result[2] ~= nil and result[2] ~= "" then
str = str..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {result[1],result[2],["尺寸"]="中"}
})
else
str = str..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {result[1],["尺寸"]="中"}
})
end
end
end
end
frame:callParserFunction{
name = '#vardefine',
args = {'兑换表格', str}
}
end
function procseeFurniture(frame, data)
-- 家具类型
frame:callParserFunction{
name = '#vardefine',
args = {'家具类型', data.type}
}
-- 占地面积
frame:callParserFunction{
name = '#vardefine',
args = {'占地面积', data.size}
}
-- 舒适度
frame:callParserFunction{
name = '#vardefine',
args = {'舒适度', data.comfort}
}
-- 评分类型
frame:callParserFunction{
name = '#vardefine',
args = {'评分类型', data.scoresType}
}
-- 评分
frame:callParserFunction{
name = '#vardefine',
args = {'评分', data.scores}
}
str = data.price
t = string.find(str,"、")
buyPrice = ""
if t ~= nil then
result2 = mw.text.split(str, "、")
for j, str4 in ipairs(result2) do
f = string.find(str4,":")
if f ~= nil then
result3 = mw.text.split(str4, ":")
str1 = result3[1]
str2 = result3[2]
buyPrice = buyPrice..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {str1,str2}
})
else
buyPrice = buyPrice..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {str4}
})
end
end
else
f = string.find(str,":")
if f ~= nil then
result2 = mw.text.split(str, ":")
buyPrice = buyPrice..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {result2[1],result2[2]}
})
end
end
-- 购买所需材料
frame:callParserFunction{
name = '#vardefine',
args = {'购买价格', buyPrice}
}
str = data.recycle
t = string.find(str,"、")
recyclePrice = ""
if t ~= nil then
result2 = mw.text.split(str, "、")
for j, str4 in ipairs(result2) do
f = string.find(str4,":")
if f ~= nil then
result3 = mw.text.split(str4, ":")
str1 = result3[1]
str2 = result3[2]
recyclePrice = recyclePrice..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {str1,str2}
})
else
recyclePrice = recyclePrice..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {str4}
})
end
end
else
f = string.find(str,":")
if f ~= nil then
result2 = mw.text.split(str, ":")
recyclePrice = recyclePrice..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {result2[1],result2[2]}
})
end
end
-- recycle
frame:callParserFunction{
name = '#vardefine',
args = {'回收价格', recyclePrice}
}
-- 宠物口粮消耗
frame:callParserFunction{
name = '#vardefine',
args = {'宠物口粮消耗', data.petFood}
}
-- 垃圾产出
frame:callParserFunction{
name = '#vardefine',
args = {'垃圾产出', data.wasteOutput}
}
-- 座椅票价
frame:callParserFunction{
name = '#vardefine',
args = {'座位票价', data.seatPrice}
}
-- 是否可以升级
frame:callParserFunction{
name = '#vardefine',
args = {'是否可以升级', data.upgrade}
}
str = data.upgradeCost
t = string.find(str,"、")
content = ""
if t ~= nil then
result2 = mw.text.split(str, "、")
for j, str4 in ipairs(result2) do
f = string.find(str4,":")
if f ~= nil then
result3 = mw.text.split(str4, ":")
str1 = result3[1]
str2 = result3[2]
content = content..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {str1,str2}
})
else
content = content..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {str4}
})
end
end
else
f = string.find(str,":")
if f ~= nil then
result2 = mw.text.split(str, ":")
content = content..mw.text.trim(frame:expandTemplate{
title = '道具图标',
args = {result2[1],result2[2]}
})
end
end
-- 升级所需材料
frame:callParserFunction{
name = '#vardefine',
args = {'升级所需材料', content}
}
if string.find(data.name,"坐便器") ~= nil then
-- 家具名
frame:callParserFunction{
name = '#vardefine',
args = {'家具名', data.name}
}
else
-- 家具名
frame:callParserFunction{
name = '#vardefine',
args = {'家具名', ""}
}
end
end
-- 道具类(拓展类以后再加)
function p.Prop(frame)
-- 获取输入参数
local input = frame.args["name"]
local pType = frame.args["type"]
-- 使用 string.gsub 进行替换操作
input = string.gsub(input, "β", "")
-- 检查输入参数是否存在
if not input then
input = "默认值" -- 如果不存在参数 i,则设置一个默认值
end
local cacheJson
if pType == "装备" then
cacheJson = getJsonPage.weapon
else
-- 缓存数据库
if pType == "道具" then
cacheJson = getJsonPage.inventory
else
if pType == "商品" then
cacheJson = getJsonPage.goods
else
if pType == "材料" then
cacheJson = getJsonPage.material
else
if pType == "列车武装" then
cacheJson = getJsonPage.trainWeapon
else
if pType == "家具" then
cacheJson = getJsonPage.furniture
else
cacheJson = getJsonPage.prop
end
end
end
end
end
end
for i, data in ipairs(cacheJson) do
if input == data.name then
if data.show == "FALSE" and pType ~="家具" then
else
if pType == "家具" then
procseeFurniture(frame, data)
end
processPropData(frame, data)
if pType == "道具" then
processInventoryData(frame, data)
end
if pType == "装备" then procseeWeaponData(frame, data) end
if pType == "商品" then procseeGoodsData(frame, data) end
if pType == "材料" then
procseeMaterialData(frame, data)
end
if pType == "列车武装" then
procseeTrainWeaponData(frame, data)
end
break
end
end
end
end
-- 家具类
function p.Furniture(frame)
-- 获取输入参数
local input = frame.args["name"]
local pType = frame.args["type"]
-- 使用 string.gsub 进行替换操作
input = string.gsub(input, "β", "")
-- 检查输入参数是否存在
if not input then
input = "默认值" -- 如果不存在参数 i,则设置一个默认值
end
local cacheJson
if pType == "家具" then
cacheJson = getJsonPage.furniture
else
cacheJson = getJsonPage.prop
end
for i, data in ipairs(cacheJson) do
if input == data.idCN then
processPropData(frame, data)
if pType == "家具" then
procseeFurniture(frame, data)
end
break
end
end
end
-- 获取家具占地
function p.GetFurnitureSize(frame)
-- 获取输入参数
local input = frame.args["name"]
-- 检查输入参数是否存在
if not input then
input = "默认值" -- 如果不存在参数 i,则设置一个默认值
end
local cacheJson
cacheJson = getJsonPage.furniture
for i, data in ipairs(cacheJson) do
if input == data.name then
return data.size
end
if input == data.idCN then
-- 占地面积
return data.size
end
end
end
function p.pushList(frame)
local pType = frame.args["type"]
local pSort = frame.args["sort"]
-- 检查输入参数是否存在
if not pType then
pType = "道具" -- 如果不存在参数 i,则设置一个默认值
end
if not pSort then
pSort = "" -- 如果不存在参数 i,则设置一个默认值
end
local output = ""
if pType == "装备" then
local cacheJson = getJsonPage.weapon
for i, data in ipairs(cacheJson) do
local formattedData = p.formatWeaponData(data)
if pSort == "一览" then
output = output ..
frame:expandTemplate{
title = '武器一览',
args = formattedData
}
else
output = output ..
frame:expandTemplate{
title = '武器一览/行',
args = formattedData
}
end
end
elseif pType == "商品" then
local cacheJson = getJsonPage.goods
for i, data in ipairs(cacheJson) do
local formattedData = p.formatGoodsData(data)
output = output ..
frame:expandTemplate{
title = '商品一览/行',
args = formattedData
}
end
elseif pType == "材料" then
local cacheJson = getJsonPage.material
for i, data in ipairs(cacheJson) do
local formattedData = p.formatMaterialData(data)
output = output ..
frame:expandTemplate{
title = '材料一览/行',
args = formattedData
}
end
elseif pType == "列车武装" then
local cacheJson = getJsonPage.trainWeapon
for i, data in ipairs(cacheJson) do
local formattedData = p.formatTrainWeaponData(data)
if pSort == "一览" then
output = output ..
frame:expandTemplate{
title = '列车武装一览',
args = formattedData
}
else
output = output ..
frame:expandTemplate{
title = '列车武装一览/行',
args = formattedData
}
end
end
elseif pType == "库存" then
local cacheJson = getJsonPage.inventory
for i, data in ipairs(cacheJson) do
local formattedData = p.formatPropData(data)
output = output ..
frame:expandTemplate{
title = '道具一览/行',
args = formattedData
}
end
elseif pType == "家具" then
local cacheJson = getJsonPage.furniture
for i, data in ipairs(cacheJson) do
if data["show"] ~= "FALSE" then
local formattedData = p.setFurnitureData(data)
output = output ..
frame:expandTemplate{
title = '家具一览/行',
args = formattedData
}
end
end
else
local cacheJson = getJsonPage.prop
for i, data in ipairs(cacheJson) do
if pType == data.sort then
local formattedData = p.formatPropData(data)
output = output ..
frame:expandTemplate{
title = '道具一览/行',
args = formattedData
}
end
end
end
return output
end
-- 输出成列表方式(调用模板:/行)
function p.pushRow(frame)
-- 获取输入类型
local pType = frame.args["type"]
-- 检查输入类型是否存在,防止为空
if not pType then
pType = "道具" -- 如果不存在参数 i,则设置一个默认值
end
-- 新建输出对象
local output = ""
-- 装备和列车武装使用各自的分页
if pType == "装备" then
local cacheJson = getJsonPage.material
for i, data in ipairs(cacheJson) do
local formattedData = p.formatMaterialData(data)
output = output ..
frame:expandTemplate{
title = '材料一览/行',
args = formattedData
}
end
elseif pType == "列车武装" then
local cacheJson = getJsonPage.weapon
for i, data in ipairs(cacheJson) do
local formattedData = p.formatWeaponData(data)
output = output ..
frame:expandTemplate{
title = '武器一览/行',
args = formattedData
}
end
-- 其他的三项(商品 道具 材料)使用统一的 图鉴内容/行
elseif pType == "商品" then
local cacheJson = getJsonPage.goods
for i, data in ipairs(cacheJson) do
local formattedData = p.setGoodsRowData(data)
output = output ..
frame:expandTemplate{
title = '图鉴内容/行',
args = formattedData
}
end
elseif pType == "材料" then
local cacheJson = getJsonPage.material
for i, data in ipairs(cacheJson) do
local formattedData = p.setPropAndMaterialRowData(data)
output = output ..
frame:expandTemplate{
title = '图鉴内容/行',
args = formattedData
}
end
elseif pType == "道具" then
local cacheJson = getJsonPage.inventory
for i, data in ipairs(cacheJson) do
local formattedData = p.setPropAndMaterialRowData(data)
output = output ..
frame:expandTemplate{
title = '图鉴内容/行',
args = formattedData
}
end
elseif pType == "家具" then
local cacheJson = getJsonPage.furniture
for i, data in ipairs(cacheJson) do
local formattedData = p.setFurnitureData(data)
output = output ..
frame:expandTemplate{
title = '家具一览/行',
args = formattedData
}
end
else
output = "输入type格式不明确"
end
return output
end
-- 设置家具行所需内容
function p.setFurnitureData(data)
-- 创建输出对象
local formattedData = {}
-- 指定键值对,对应data参数
formattedData["1"] = data["name"]
formattedData["2"] = data["type"]
formattedData["param2"] = data["type"]
formattedData["3"] = data["comfort"]
if data["comfort"] ~= nil and data["comfort"] ~= "" then
formattedData["param3"] = "舒适度"
end
formattedData["4"] = data["scoresType"]
formattedData["param4"] = data["scoresType"]
formattedData["5"] = data["scores"]
formattedData["6"] = DataToLinkText(data["acquisitionMode"], true)
formattedData["param6"] = DataToFilterTag(data["acquisitionMode"])
formattedData["7"] = data["show"]
return formattedData
end
-- 设置商品行所需内容
function p.setGoodsRowData(data)
-- 创建输出对象
local formattedData = {}
-- 指定键值对,对应data参数
formattedData["1"] = data["name"]
formattedData["2"] = data["sort"]
formattedData["param2"] = DataToFilterTag(data["sort"])
-- 当解锁方式不存在时 设置为默认解锁
if data["unlockMode"] == "" then
formattedData["3"] = "默认解锁"
formattedData["param3"] = "默认,默认解锁"
-- 当解锁方式存在时 按照条件获取
else
formattedData["3"] = DataToLinkText(data["unlockMode"], true)
formattedData["param3"] = DataToFilterTag(data["unlockMode"])
end
formattedData["4"] = DataToLinkText(data["acquisitionMode"], true)
formattedData["param4"] = DataToFilterTag(data["acquisitionMode"])
return formattedData
end
-- 设置材料/道具行所需内容
function p.setPropAndMaterialRowData(data)
-- 创建输出对象
local formattedData = {}
-- 指定键值对,对应data参数
formattedData["1"] = data["name"]
formattedData["2"] = data["rarity"]
formattedData["param2"] = data["rarity"]
formattedData["3"] = DataToLinkText(data["sort"])
formattedData["param3"] = DataToFilterTag(data["sort"])
formattedData["4"] = DataToLinkText(data["acquisitionMode"], true)
formattedData["param4"] = DataToFilterTag(data["acquisitionMode"])
if data['exchangeWay'] ~= nil then
formattedData["5"] = DataToLinkText(data["exchangeWay"], true)
if formattedData["4"] ~= "" then
formattedData["param4"] = formattedData["param4"] .. "," .. DataToFilterTag(data["exchangeWay"])
end
end
formattedData["7"] = data["show"]
return formattedData
end
-- 道具筛选
function p.formatPropData(data)
local formattedData = {}
-- 指定键值对,而不是循环
formattedData["1"] = data["name"]
formattedData["2"] = data["rarity"]
formattedData["3"] = data["sort"]
formattedData["4"] = DataToLinkText(data["tag"])
formattedData["tag"] = DataToFilterTag(data["tag"])
formattedData["5"] = DataToLinkText(data["acquisitionMode"])
formattedData["acqMode"] = DataToFilterTag(data["acquisitionMode"])
formattedData["6"] = data["info"]
formattedData["7"] = DataToLinkText(data["propInBox"])
return formattedData
end
-- 商品筛选
function p.formatGoodsData(data)
local formattedData = {}
-- 指定键值对,而不是循环
formattedData["1"] = data["name"]
formattedData["2"] = data["sort"]
formattedData["3"] = DataToFilterTag(data["sort"])
formattedData["4"] = DataToLinkText(data["acquisitionMode"], "、", "<br>")
formattedData["5"] = DataToFilterTag(data["acquisitionMode"])
if data["unlockMode"] == "" then
formattedData["6"] = "默认解锁"
formattedData["7"] = "默认,默认解锁"
else
formattedData["6"] = DataToLinkText(data["unlockMode"], "、", "<br>")
formattedData["7"] = DataToFilterTag(data["unlockMode"])
end
return formattedData
end
-- 武器筛选
function p.formatWeaponData(data)
local formattedData = {}
-- 指定键值对,而不是循环
formattedData["1"] = data["name"]
formattedData["2"] = data["rarity"]
formattedData["3"] = data["sort"]
formattedData["4"] = data["factions"]
formattedData["5"] = data["valueName"]
formattedData["6"] = data["value0"]
formattedData["7"] = data["valueMax"]
formattedData["8"] = data["mainPerk"]
-- 稀有度颜色
local rColor
if data.rarity == "UR" then
rColor = "#f36009"
elseif data.rarity == "SSR" then
rColor = "#fdc116"
elseif data.rarity == "SR" then
rColor = "#ab27fd"
elseif data.rarity == "R" then
rColor = "#2773fd"
else
rColor = "#bbbbbb"
end
formattedData["RColor"] = rColor
return formattedData
end
-- 材料筛选
function p.formatMaterialData(data)
local formattedData = {}
-- 指定键值对,而不是循环
formattedData["1"] = data["name"]
formattedData["2"] = data["sort"]
formattedData["3"] = DataToFilterTag(data["sort"])
formattedData["4"] = DataToLinkText(data["acquisitionMode"])
formattedData["5"] = DataToFilterTag(data["acquisitionMode"])
return formattedData
end
-- 列车武装
function p.formatTrainWeaponData(data)
local formattedData = {}
-- 指定键值对,而不是循环
formattedData["1"] = data["name"]
formattedData["2"] = data["rarity"]
formattedData["3"] = data["sort"]
formattedData["4"] = DataToFilterTag(data["sort"])
local getWay
if data["acquisitionMode"] ~= "" then
getWay = data["acquisitionMode"].."、"..data["exchangeWay"]
else
getWay = data["exchangeWay"]
end
formattedData["5"] = DataToLinkText(getWay,true)
formattedData["6"] = DataToFilterTag(getWay)
return formattedData
end
-- 图标模板
function p.formatImgData(item)
local formattedData = {}
-- 指定键值对,而不是循环
formattedData["1"] = item
formattedData["2"] = "小"
return formattedData
end
-- 从数据转换到筛选标签
function DataToFilterTag(data)
local outputStr = "" -- 将outputStr定义为一个字符串
if data == nil then
return outputStr
end
-- 将"、"替换为逗号
data = string.gsub(data, "、", ",")
-- 循环每个数组执行下一步
for word in string.gmatch(data, "[^,]+") do
-- 这里执行下一步操作
-- 任务
if string.find(word, "作战计划") then
outputStr = outputStr .. "作战计划,"
end
if string.find(word, "悬赏任务") then
outputStr = outputStr .. "悬赏任务,"
end
if string.find(word, "铁安局任务") then
outputStr = outputStr .. "铁安局任务,"
end
if string.find(word, "铁安局") then
outputStr = outputStr .. "铁安局,"
end
-- 城市相关
if string.find(word, "城市声望") then
outputStr = outputStr .. "城市声望,"
end
-- 城市地区
if string.find(word, "阿妮塔能源研究所") then
outputStr = outputStr .. "阿妮塔能源研究所,"
end
if string.find(word, "阿妮塔战备工厂") then
outputStr = outputStr .. "阿妮塔战备工厂,"
end
if string.find(word, "七号自由港") then
outputStr = outputStr .. "七号自由港,"
end
if string.find(word, "澄明数据中心") then
outputStr = outputStr .. "澄明数据中心,"
end
if string.find(word, "修格里城") then
outputStr = outputStr .. "修格里城,"
end
if string.find(word, "荒原站") then
outputStr = outputStr .. "荒原站,"
end
if string.find(word, "曼德矿场") then
outputStr = outputStr .. "曼德矿场,"
end
if string.find(word, "淘金乐园") then
outputStr = outputStr .. "淘金乐园,"
end
if string.find(word, "海角城") then
outputStr = outputStr .. "海角城,"
end
if string.find(word, "贡露城") then
outputStr = outputStr .. "贡露城,"
end
if string.find(word, "阿妮塔发射中心") then
outputStr = outputStr .. "阿妮塔发射中心,"
end
if string.find(word, "铁盟哨站") then
outputStr = outputStr .. "铁盟哨站,"
end
if string.find(word, "云岫桥基地") then
outputStr = outputStr .. "云岫桥基地,"
end
if string.find(word, "汇流塔") then
outputStr = outputStr .. "汇流塔,"
end
-- 行车沿线 战斗
if string.find(word, "行车沿线") then
outputStr = outputStr .. "行车沿线,"
end
if string.find(word, "异构厄枝") then
outputStr = outputStr .. "异构厄枝,"
end
if string.find(word, "桦树浮标") then
outputStr = outputStr .. "桦树浮标,"
end
if string.find(word, "混响浮标") then
outputStr = outputStr .. "混响浮标,"
end
-- Boss
if string.find(word, "鸣爆虫母") then
outputStr = outputStr .. "鸣爆虫母,"
end
if string.find(word, "寒潮浮囊体") then
outputStr = outputStr .. "寒潮浮囊体,"
end
if string.find(word, "尘鸣游磷") then
outputStr = outputStr .. "尘鸣游磷,"
end
if string.find(word, "昏恶巨象") then
outputStr = outputStr .. "昏恶巨象,"
end
if string.find(word, "凛川骨龙") then
outputStr = outputStr .. "凛川骨龙,"
end
if string.find(word, "混厄石芝") then
outputStr = outputStr .. "混厄石芝,"
end
-- 兑换商店
if string.find(word, "商城") then
outputStr = outputStr .. "商城,"
end
if string.find(word, "礼包") then
outputStr = outputStr .. "礼包,"
end
if string.find(word, "赴命奖章兑换") then
outputStr = outputStr .. "赴命奖章兑换,"
end
-- 制造加工
if string.find(word, "制造工作台") then
outputStr = outputStr .. "制造加工,"
end
if string.find(word, "车载炼矿机") then
outputStr = outputStr .. "制造加工,"
end
if string.find(word, "制造工作台") then
outputStr = outputStr .. "制造加工,"
end
if string.find(word, "车载加工车床") then
outputStr = outputStr .. "制造加工,"
end
if string.find(word, "车载缝纫机") then
outputStr = outputStr .. "制造加工,"
end
if string.find(word, "交易所") then
outputStr = outputStr .. "交易所,"
end
-- 商品相关
if string.find(word, "特产") then
outputStr = outputStr .. "特产,"
end
if string.find(word, "普通") then
outputStr = outputStr .. "普通,"
end
if string.find(word, "制造") then
outputStr = outputStr .. "制造,"
end
if string.find(word, "发展度") then
outputStr = outputStr .. "发展度,"
end
if string.find(word, "投资额度") then
outputStr = outputStr .. "投资额度,"
end
if string.find(word, "宠物") then
outputStr = outputStr .. "宠物,"
end
-- 家具相关
if string.find(word, "花鸟市场") then
outputStr = outputStr .. "花鸟市场,"
end
if string.find(word, "环游手册") then
outputStr = outputStr .. "环游手册,"
end
if string.find(word, "列车家具商店") then
outputStr = outputStr .. "列车家具商店,"
end
if string.find(word, "海豹券商店") then
outputStr = outputStr .. "海豹券商店,"
end
if string.find(word, "无垠号自带") then
outputStr = outputStr .. "无垠号自带,"
end
if string.find(word, "主线剧情赠送") then
outputStr = outputStr .. "主线剧情赠送,"
end
if string.find(word, "支线任务") then
outputStr = outputStr .. "支线任务奖励,"
end
if string.find(word, "活动") then
outputStr = outputStr .. "限时活动获取,"
end
if string.find(word, "环保声望等级") then
outputStr = outputStr .. "环保声望等级奖励,"
end
if string.find(word, "建设进度") then
outputStr = outputStr .. "建设进度奖励,"
end
if string.find(word, "科技中心") then
outputStr = outputStr .. "NPC兑换,"
end
if string.find(word, "红茶战争") then
outputStr = outputStr .. "活动,"
end
if string.find(word, "启程签到") then
outputStr = outputStr .. "活动,"
end
if string.find(word, "主线") then
outputStr = outputStr .. "主线,"
end
if string.find(word, "海岛管理局") then
outputStr = outputStr .. "海岛管理局,"
end
outputStr = outputStr .. word .. ","
end
-- 去掉最后一个逗号
outputStr = string.sub(outputStr, 1, -2)
return outputStr
end
-- 从数据转换到链接文本
function DataToLinkText(data, LineFeed)
-- 新建输出项
local outputStr = ""
if not LineFeed then LineFeed = false end
if data == nil then
return outputStr
end
-- 将"、"替换为逗号
data = string.gsub(data, "、", ",")
-- 循环每个数组执行下一步
for item in string.gmatch(data, "[^,]+") do
outputStr = outputStr .. "[[" .. item .. "]]"
if LineFeed == true then
outputStr = outputStr .. "<br>"
else
outputStr = outputStr .. "、"
end
end
if LineFeed == true then
-- 去掉最后一个<br>
outputStr = string.sub(outputStr, 1, -5)
else
-- 去掉最后一个顿号
outputStr = string.sub(outputStr, 1, -4)
end
return outputStr
end
-- 从数据转换到图标模板
function DataToImg(frame, data)
-- 新建输出项
local outputStr = ""
-- 将"、"替换为逗号
data = string.gsub(data, "、", ",")
-- 循环每个数组执行下一步
for item in string.gmatch(data, "[^,]+") do
local formattedData = p.formatImgData(item)
outputStr = outputStr ..
frame:expandTemplate{
title = '图标',
args = formattedData
}
end
return outputStr
end
return p -- 返回包含函数和数据的导出表