模块:Hydrogina/sandbox/EventShopList2
跳转到导航
跳转到搜索
可在模块:Hydrogina/sandbox/EventShopList2/doc创建此模块的帮助文档
local p = {}
function get_unit_sanity(str)
t={}
t['采购凭证']=1.3599
t['家具零件']=0.5864
t['经验']=0.0038
t['D32钢']=278.38
t['聚合剂']=261.33
t['双极纳米片']=220.03
t['异铁块']=117.56
t['三水锰矿']=103.95
t['聚酸酯块']=98.694
t['酮阵列']=98.186
t['改量装置']=97.704
t['五水研磨石']=95.18
t['RMA70-24']=93.577
t['炽合金块']=87.617
t['聚合凝胶']=84.13
t['糖聚块']=77.989
t['白马醇']=68.328
t['提纯源岩']=59.905
t['高级作战记录']=7.7189
t['碳素组']=6.8538
t['寻访凭证']=450
t['合成玉']=0.75
t['近卫双芯片']=203.67
t['狙击双芯片']=203.67
t['医疗双芯片']=203.67
t['先锋双芯片']=192.23
t['辅助双芯片']=192.22
t['重装双芯片']=180.78
t['术师双芯片']=180.78
t['特种双芯片']=180.78
t['全新装置']=39.53
t['凝胶']=36.835
t['RMA70-12']=34.959
t['酮凝集组']=30.398
t['研磨石']=29.954
t['轻锰矿']=29.418
t['异铁组']=29.162
t['扭转醇']=25.398
t['聚酸酯组']=23.182
t['炽合金']=21.599
t['固源岩组']=15.843
t['糖组']=11.437
t['技巧概要·卷3']=10.112
t['碳素']=4.2761
t['中级作战记录']=3.8594
t['赤金']=1.5437
t['近卫芯片组']=39.995
t['狙击芯片组']=39.995
t['医疗芯片组']=39.995
t['先锋芯片组']=34.273
t['辅助芯片组']=34.27
t['重装芯片组']=28.548
t['术师芯片组']=28.548
t['特种芯片组']=28.548
t['装置']=9.9313
t['酮凝集']=7.6484
t['异铁']=7.3393
t['聚酸酯']=5.8443
t['技巧概要·卷2']=3.9776
t['固源岩']=3.2076
t['糖']=2.9082
t['碳']=1.6985
t['初级作战记录']=1.5437
t['芯片助剂']=122.39
t['招聘许可']=14.462
t['近卫芯片']=19.997
t['重装芯片']=19.997
t['狙击芯片']=19.997
t['辅助芯片']=19.997
t['先锋芯片']=14.274
t['术师芯片']=14.274
t['医疗芯片']=14.274
t['特种芯片']=14.274
t['破损装置']=3.2862
t['双酮']=2.5252
t['异铁碎片']=2.4222
t['酯原料']=1.9239
t['技巧概要·卷1']=1.5645
t['源岩']=1.045
t['代糖']=0.9452
t['基础作战记录']=0.7718
t['龙门币']=0.004
t['应急理智顶液']=100
t['近卫遗产信物']=244.782
return t[str]
end
function get_unit_num(str)
if(string.find(str, "×"))then
target = "×%d+"
rtn=string.sub(str, string.find(str, target))
rtn=string.sub(rtn,3)
else
rtn="1"
end
return rtn;
end
function get_name(str)
rtn=string.gsub(str,"<small>.*</small>","")
rtn=string.gsub(rtn,"<.*>.*</.*>","")
rtn=string.gsub(rtn,"{{.*}}","")
rtn=string.gsub(rtn," ","")
rtn=string.gsub(rtn,"×%d+","")
rtn=string.gsub(rtn,"''''''","")
return rtn;
end
function p.list(frame)
local args = (frame == mw.getCurrentFrame() and frame.args) or frame
local token_name = mw.text.trim(args["token_alias"] or "")
local token_icon_file = mw.text.trim(args["token_icon"] or "道具_" .. token_name .. ".png")
local token_icon_size = mw.text.trim(args["token_icon_size"] or "30px")
local data_str = mw.text.trim(args["data"] or "")
local token_icon = string.format("[[File:%s|%s|link=]]", token_icon_file, token_icon_size)
local selectall_str = frame:callParserFunction{name = '#Widget:ShopItemSelectAll', args = {item = token_name}}
res_table = {}
table.insert(res_table, '{| class="wikitable sortable" style="white-space:normal;display:table;"\n')
table.insert(res_table, string.format('!%s!!序号!!阶段!!可兑换道具!!库存!!%s单价!!数量!!等效理智单价!!等效理智!!性价比\n', selectall_str,token_icon))
--style="width:5.0em;"| style="width:6.0em;"| style="width:1.5em;"| width:600px;max-width:100%;
local data_table = mw.text.split(data_str, "\n", true)
local colorTable = {["金"]="#ffbb78",["紫"]="#e995ff",["蓝"]="#95c1ff",["灰"]="gainsboro",}
local stagename=""
local i_num=0
for i = 1, #data_table do
local datum_table = mw.text.split(data_table[i], ";;", true)
local name = mw.text.trim(datum_table[2] or "")
if datum_table[1]=='X' then
--table.insert(res_table, '|-\n')
--table.insert(res_table, string.format("!colspan=8|%s\n", name))
stagename=name
else
i_num=i_num+1
local color = mw.text.trim(datum_table[5] or "")
local checkbox_str = ""
local num_limit = tonumber(mw.text.trim(datum_table[3] or ""))
local unit_price = tonumber(mw.text.trim(datum_table[4] or ""))
if num_limit ~= nil and unit_price ~= nil then
checkbox_str = frame:expandTemplate{title = "商店列表复选框", args = { token_name, num_limit * unit_price, ((datum_table[1] == '1') and "是" or "否")}}
end
local num_limit_str = (num_limit ~= nil) and num_limit or mw.text.trim(datum_table[3] or "——")
local unit_price_str = (unit_price ~= nil) and tostring(unit_price) or mw.text.trim(datum_table[4] or "——")
maincolor_str=""
if color~="" then
maincolor_str=string.format('style="background:%s"|', colorTable[color] or color)
end
table.insert(res_table, '|-\n')
--table.insert(res_table, (color ~= "") and (string.format('|-style="background:%s"\n', color)) or ('|-\n'))
--local unit_num = mw.text.trim(datum_table[6] or "")
local unit_num_str = get_unit_num(name)--"unit_num"--tostring(42)
local item_name = get_name(name)
local unit_sanity = get_unit_sanity(item_name)
local unit_sanity_str ="" --item_name--""
local sanity_str = "" --tostring(42)
local cp_str = "" --tostring(42)
if(unit_sanity)then
unit_sanity_str =tostring(unit_sanity)
sanity=tonumber(unit_num_str)*unit_sanity
sanity_str=string.format("%.2f",sanity)--tostring(sanity)
cp=sanity/tonumber(unit_price_str)
cp_str =string.format("%.2f",cp)--tostring(cp)
end
--local unit_sanity_str = "unit_sanity"--tostring(42)
table.insert(res_table, string.format("|%s||%s||%s||%s%s||%s||%s||%s||%s||%s||%s\n", checkbox_str,tostring(i_num) ,stagename,maincolor_str,name, num_limit_str, unit_price_str,unit_num_str,unit_sanity_str,sanity_str,cp_str))
end
end
local total_str = frame:callParserFunction{name = '#Widget:ShopItemTotalCost', args = {item = token_name}}
table.insert(res_table, '|-\n')
table.insert(res_table, string.format('| ||colspan="2"|勾选项目总价||%s\'\'\'%s\'\'\'\n', token_icon, total_str))
table.insert(res_table, '|}')
return table.concat(res_table)
end
return p