「于世界交点之处,逢似曾相识之人」

本wiki目前不支持自由编辑,如果有兴趣参与wiki内容编辑,请加入WIKI建设群904200987(游戏交流勿加会被踢)
使用wiki的数据、图片、音频资源,或者搬运页面内容时,请注明出处。具体参照CC BY-NC-SA 4.0协议
感谢Hyacinth对本wiki提供的数据支持
编辑帮助BWIKI反馈

bugfix1001.2
全站通知:

模块:卡池图鉴

来自白荆回廊Wiki
跳到导航 跳到搜索

此模块的文档可以在模块:卡池图鉴/doc创建

local p = {}
local db = require('模块:卡池数据库')
local data = db.draw_data
local __get_timestamp_from_str_1 = require('模块:Utils').get_timestamp_from_str_1

p["同调者UP信息"] = function(frame)
  local nowdate = os.time()
  --local char_list = frame:callParserFunction { name = "#ask:[[分类:同调者]][[星级::6]]", args = {
	 --	"?姓名",
	 --	mainlabel = "-",
	 --	headers = "hide",
	 --	sort = "排序ID",
	 --	order = "desc",
	 --} }
	 local char_list = {"姜宁","旒珠","红珠小姐","逸虚","织雪","司旸","谛卡","拉波","茜茜","温留","龙和","十手卫","余音","玄戈","林","珑","米达斯","缇诗","明月尘","晴雪","景","提提亚","鸢","尤尼","伊琅相思","乐无异","风晴雪","言御","言雀","百里屠苏","红玉","岑缨","莫红袖","云无月","耶芙娜","昊苍","崔远之","瞳","卯绒绒","龙晴","紫都","北洛"}
	 local raw_latest_up_list = {}
	 for i, v in pairs(char_list) do
	 	local temp = { name = v, lastest_end_date = nil, end_day = nil,up_type = nil,count = 0 }
		
		for j, w in pairs(data) do
			if w["ratio_up_6"] ~= nil and #w["ratio_up_6"] == 1 and w["ratio_up_6"][1] == v then
				local end_date = __get_timestamp_from_str_1(w['close_time'])
				temp["count"] = temp["count"] + 1
				if temp["lastest_end_date"] == nil or temp["lastest_end_date"] < end_date then
					temp["lastest_end_date"] = end_date
					temp["up_type"] = w["type"]
				end
			end
		end
		temp["end_day"] = (nowdate - temp["lastest_end_date"]) / 24 / 3600
		raw_latest_up_list[i] = temp
	end
	 
    table.sort(raw_latest_up_list, function(a, b) return a["end_day"] < b["end_day"] end)

	local html = mw.html.create()

  html = html:tag('table'):addClass('wikitable')
				:tag('tr')
					:tag('th'):wikitext("同调者"):done()
    				:tag('th'):wikitext("UP次数"):done()
    				:tag('th'):wikitext("卡池类型"):done()
    				:tag('th'):wikitext("最近一次UP结束天数"):done()
    			:done()

  for _i, v in ipairs(raw_latest_up_list) do
    html = html:tag('tr')
					:tag('td'):wikitext("[[文件:角色 " .. v['name'] .. " 头像.png|50px|link=同调者/" .. v['name'] .. "]]"):done()
	    			:tag('td'):wikitext(v['count']):done()
	    			:tag('td'):wikitext(v['up_type']):done()
	    			:tag('td'):wikitext(string.format("%.1f", v['end_day']).." 天"):done()
    			:done()
  end
  html = html:done()

  mw.log(html)
  return tostring(html)
  
end

p["首页卡池"] = function(frame)
  local nowdate = os.time()
  local expdate = os.time() + 7 * 24 * 3600 --提前七天预告卡池开始
  local tableData = {}
  for i, v in pairs(data) do
    local open_time = __get_timestamp_from_str_1(v['open_time'])
    local close_time = __get_timestamp_from_str_1(v['close_time'])
    if open_time <= expdate and close_time >= nowdate then
	  local temp = v
	  temp["is_open"] = 1
      if open_time > nowdate then
      	temp["is_open"] = 0
      	table.insert(tableData, temp)
      else
        table.insert(tableData, temp)
      end
    end
  end

local typeParam = {
  	['定向共鸣'] = 1,
  	['特别共鸣·UP'] = 2,
  	['常态共鸣·UP'] = 3,
  	['定向潜航'] = 4,
  	['先觉潜航'] = 5,
  	['识海甄录'] = 6,
  	
  }
  table.sort(tableData, function(a, b)
  	if a.open_time == b.open_time then
  		if a.close_time == b.close_time then
  			return a.type < b.type
  		else 
  			return a.close_time < b.close_time
  		end
  	else
    	return a.open_time < b.open_time
    end
  end)


  local html = mw.html.create()

  html = html:tag('div'):cssText('display:flex;flex-wrap:wrap;gap:8px;margin:8px 0;')

  for _i, v in ipairs(tableData) do
    html = html:node(p.create_draw_card(v, "home"))
  end
  html = html:done()

  return tostring(html)
end

p["卡池图鉴"] = function(frame)
  local tableData = data
  local typeParam = {
  	['定向共鸣'] = 1,
  	['特别共鸣·UP'] = 2,
  	['常态共鸣·UP'] = 3,
  	['定向潜航'] = 4,
  	['先觉潜航'] = 5,
  	
  }
  table.sort(tableData, function(a, b)
  	if a.open_time == b.open_time then
    	return a.type > b.type
  	else
    	return a.open_time > b.open_time
    end
  end)

  local html = mw.html.create()
  html = html:tag('div'):attr('id', 'CardSelectTr'):addClass('draw-container')

  for _i, v in ipairs(tableData) do
    html = html:node(p.create_draw_card(v, "divsort"))
  end
  html = html:done()

  return tostring(html)
end

p["卡池/个"] = function(frame)
  local draw = frame.args[1]
  local index = frame.args[2]
  if index == nil or index == "" then
  	index = 1
  else 
  	index = tonumber(index)
  end	
  
  local output_data_temp = {}
  for _i, v in ipairs(data) do
    if v['name'] == draw then
      table.insert(output_data_temp, v)
    end
  end
  if output_data_temp[index] == nil then
    return ''
  end

  local html = p.create_draw_card(output_data_temp[index], "item")
  return tostring(html)
end

function p.create_draw_card(draw_data, mode)
  local html = mw.html.create()
  local ratio_up_6 = mw.html.create()
  local ratio_up_5 = mw.html.create()

  if draw_data["type"] == "定向共鸣" or draw_data["type"] == "常态共鸣·UP" or draw_data["type"] == "特别共鸣·UP" then
    for _k, x in ipairs(draw_data['ratio_up_6'] or {}) do
      ratio_up_6 = ratio_up_6:tag("div"):addClass('draw-ratio-up-img-char'):cssText("background:linear-gradient(180deg, #3b3550, #a7353a 53%);")
          :wikitext("[[文件:角色_" .. x .. "_头像.png|x50px|link=同调者/" .. x .. "]]")
          :done()
    end
    for _k, x in ipairs(draw_data['ratio_up_5'] or {}) do
      ratio_up_5 = ratio_up_5:tag("div"):addClass('draw-ratio-up-img-char'):cssText("background:linear-gradient(180deg, #885550, #c9a36a 53%)")
          :wikitext("[[文件:角色_" .. x .. "_头像.png|x50px|link=同调者/" .. x .. "]]")
          :done()
    end
  elseif draw_data["type"] == "定向潜航" or draw_data["type"] == "先觉潜航" then
    if draw_data['ratio_up_6'] ~= nil then
      for _k, x in ipairs(draw_data['ratio_up_6']) do
      	if x == "未知" then
      		ratio_up_6 = ratio_up_6:tag("div"):addClass('draw-ratio-up-img-memory'):cssText("display:flex;align-items:center;justify-content:center;background:#999;color:#FFF;")
						          :tag("div"):wikitext("?"):done()
						          :tag("div"):cssText("position:absolute;bottom:0;right:0;display: flex; justify-content: end;width:90%;"):wikitext(
						            "[[文件:UI 烙痕缩略图2 稀有度 SSR.png|x44px|link=]]"):done()
						          :done()
      	else
	        ratio_up_6 = ratio_up_6:tag("div"):addClass('draw-ratio-up-img-memory')
	            :wikitext("[[文件:记忆烙痕_" .. x .. "_缩略图2.png|x44px|link=记忆烙痕/" .. x .. "]]")
	            :tag("div"):cssText("position:absolute;bottom:0;right:0;display: flex; justify-content: end;width:90%;"):wikitext(
	              "[[文件:UI 烙痕缩略图2 稀有度 SSR.png|x44px|link=记忆烙痕/" .. x .. "]]"):done()
	            :done()
        end
      end
    else
      ratio_up_6 = ratio_up_6:tag("div"):addClass('draw-ratio-up-img-memory'):cssText("display:flex;align-items:center;justify-content:center;background:#999;color:#FFF;")
          :tag("div"):wikitext("?"):done()
          :done()
    end
    for _k, x in ipairs(draw_data['ratio_up_5'] or {}) do
      ratio_up_5 = ratio_up_5:tag("div"):addClass('draw-ratio-up-img-memory')
          :wikitext("[[文件:记忆烙痕_" .. x .. "_缩略图2.png|x44px|link=记忆烙痕/" .. x .. "]]")
          :tag("div"):cssText("position:absolute;bottom:0;right:0;display: flex; justify-content: end;width:90%;"):wikitext(
            "[[文件:UI 烙痕缩略图2 稀有度 SR.png|x44px|link=记忆烙痕/" .. x .. "]]"):done()
          :done()
    end
  end

  html = html:tag('div'):addClass('draw-box')
  if mode == "divsort" then
    html = html:addClass('divsort'):attr('data-param1', draw_data["type"])
  end

  html = html:tag("div"):addClass("draw-item")
  if mode == "home" and draw_data['is_open'] ~= 1 then
  	html = html:addClass("locked")
  end
  if mode ~= "home" then
  	local banner_img = "卡池banner_" .. draw_data["name"] 
  	if draw_data["name"] == "常态共鸣·云无月" and draw_data["open_time"] ~= "2024.03.14 04:00" then
  		banner_img =  banner_img .. "2"
  	end
  	if draw_data["name"] == "常态共鸣·瞳" and draw_data["open_time"] ~= "2024.04.25 04:00" then
  		banner_img =  banner_img .. "2"
  	end
  	if draw_data["type"] == '识海甄录' then
  		banner_img = '卡池banner_识海甄录·消夏归航'
  	end
    html = html:tag("div"):addClass("draw-banner-wrapper")
        :tag("div"):addClass("draw-banner")
        :wikitext("[[文件:" .. banner_img .. ".png|link=]]")
        :done()
        :done()
  end
  html = html:tag("div"):addClass("draw-content")
  if mode == "divsort" or mode == "home" then
    html = html:tag("div"):addClass("draw-name"):wikitext(draw_data["name"]):done()
  end
  html = html:tag("div"):addClass("draw-open"):wikitext(draw_data["open_time"] .. " ~ " .. draw_data["close_time"])
      :done()
  html = html:tag("div"):addClass("draw-ratio-up-wrapper")
      :tag("div"):addClass("draw-ratio-up-box"):node(ratio_up_6):node(ratio_up_5):done()
      :done()
  html = html:done()
      :done()
      :done()

  return html
end

return p