置顶公告:【置顶】关于临时开启评论区所有功能的公告(2022.10.22) | 【置顶】关于本站Widget恢复使用的公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:碧蓝航线

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [查看] [编辑] [历史] [刷新]

该模块作为碧蓝航线系列条目的重要模块,编辑请尽量使用原生编辑页面,并且保存前请务必预览Template:碧蓝航线的显示情况。

关于{{碧蓝航线links}}

逻辑代码位于模块:碧蓝航线Ships

数据位于模块:碧蓝航线Ships/Data

目前数据由脚本自动更新,有编辑组专人负责。

  1. local module = {}
  2. local translist_favor = {
  3. [0] = { ["好感度1"] = "好感度-失望", ["好感度2"] = "好感度-陌生", ["好感度3"] = "好感度-友好", ["好感度4"] = "好感度-喜欢", ["好感度5"] = "好感度-爱" },
  4. [97] = { ["好感度1"] = "好感度-未知", ["好感度2"] = "好感度-调率", ["好感度3"] = "好感度-理解", ["好感度4"] = "好感度-同步", ["好感度5"] = "好感度-共鸣" },
  5. [107] = { ["好感度1"] = "好感度-失望", ["好感度2"] = "好感度-普通", ["好感度3"] = "好感度-友好", ["好感度4"] = "好感度-协作", ["好感度5"] = "好感度-应援" },
  6. }
  7. local tranform_favor = function (ship_info, arg_name)
  8. return (translist_favor[ship_info.nation] or translist_favor[0])[arg_name]
  9. end
  10. local arglist = {
  11. {"获得", "登录", "查看详情", { "主界面[1-9][0-9]?", list = true, display = "主界面" }, "触摸", "摸头", "特殊触摸", "任务提醒", "任务完成", "邮件提醒", "回港", "委托完成", "强化成功", "旗舰开战", "胜利MVP", "失败",
  12. "技能", "HP告急", "彩蛋", { "彩蛋[1-9][0-9]?", list = true, display = "彩蛋" }, { "20%d%d情人节礼物", noaudio = true } },
  13. {"简介", { "好感度[1-5]", ["display"] = tranform_favor }, "好感度-失望", "好感度-陌生", "好感度-友好", "好感度-喜欢", "好感度-爱", "誓约", "掉落描述" },
  14. {"获得", "登录", "查看详情", { "主界面[1-9][0-9]?" }, "触摸", "摸头", "特殊触摸", "任务提醒", "任务完成", "邮件提醒", "回港", "委托完成", "简介", "好感度-失望", "好感度-陌生", "好感度-友好", "好感度-喜欢", "好感度-爱", "誓约", "强化成功",
  15. "旗舰开战", "胜利MVP", "失败", "技能", "HP告急", "彩蛋", { "彩蛋[1-9]", list = true, display = "彩蛋" } }
  16. }
  17. local hidelist = { ["礼物-喜欢"] = true, ["礼物-不喜欢"] = true, ["礼物-喜欢语音"] = true, ["礼物-不喜欢语音"] = true }
  18. local g_frame = nil
  19. function get_arg(name)
  20. return g_frame.args[name] and mw.text.trim(g_frame.args[name]) or ''
  21. end
  22. function bkcolor(level)
  23. if level == 1 then
  24. return "#d0d0d0"
  25. elseif level == 2 then
  26. return"#aae6fd"
  27. elseif level == 3 then
  28. return"#b9a7db"
  29. elseif level == 4 then
  30. return"#f9f593"
  31. elseif level == 5 then
  32. return"rgba(162, 214, 245,0.8)"
  33. elseif level == 6 then
  34. return"#d3aa4f"
  35. elseif level == 7 then
  36. return"#dcceff"
  37. elseif level == 14 then
  38. return"#9e5c22"
  39. elseif level == 13 then
  40. return"#a676fc"
  41. else
  42. return"#d0d0d0"
  43. end
  44. end
  45. shipmodule = nil
  46. function shipModule()
  47. if not shipmodule then
  48. shipmodule = require("Module:碧蓝航线Ships")
  49. end
  50. return shipmodule
  51. end
  52. function module.LinesUnit(frame)
  53. local parent = frame:getParent()
  54. local index = nil
  55. if parent then
  56. index = mw.ustring.match(parent:getTitle(), "^Template:碧蓝航线台词([1-3])$")
  57. if index then frame = parent end
  58. else
  59. index = frame.args["index"]
  60. end
  61. g_frame = frame
  62. if index then index = tonumber(index) else return end
  63. local num_level = frame:callParserFunction("#var", "levelnum", "")
  64. if num_level == "" then
  65. local obj_title = mw.title.getCurrentTitle()
  66. if obj_title.namespace == 0 then
  67. local name = mw.ustring.match(obj_title.text,"^碧蓝航线:(.+)")
  68. num_level = shipModule().innerlevel(name)
  69. end
  70. else
  71. num_level = tonumber(num_level)
  72. end
  73. if index == 3 and get_arg('改造') ~= '' then
  74. num_level = num_level + 1
  75. end
  76. local color_bkg = bkcolor(num_level)
  77. local hasAudio, hasDouble = false, false
  78. local used = { }
  79. local incorrect = { }
  80. local Incorrect_Add = function(key, group)
  81. if mw.title.getCurrentTitle().namespace ~= 0 then return end
  82. group = group or "模板参数不正确"
  83. if not incorrect[1] then table.insert(incorrect, "[[Category:碧蓝航线:" .. group .. "]]") end
  84. table.insert(incorrect, "[[Category:碧蓝航线:" .. group .. "/" .. key .. "]]")
  85. end
  86. local html = mw.html.create()
  87. local box = html:tag("table"):addClass("customers"):attr("width", "100%"):css("border-collapse", "separate"):css("border-spacing", "0 0.3em"):css("background-color", "rgba(235,248,255,0.5)"):css("border-radius", "0.3em")
  88. local Work_Audio = function(arg_name)
  89. local arg_audio = mw.text.trim(frame.args[arg_name])
  90. if arg_audio == "" then return "" end
  91. local arg_split = mw.text.split(arg_audio, ";", true)
  92. for index, file_audio in ipairs(arg_split) do
  93. local file_path = frame:callParserFunction("filepath", file_audio)
  94. if file_path == "" then
  95. Incorrect_Add(arg_name, "语音文件不存在")
  96. arg_split[index] = '<div class="error">语音文件不存在:' .. file_audio .. '</div>'
  97. else
  98. arg_split[index] = frame:extensionTag("sm2", file_audio)
  99. end
  100. end
  101. arg_audio = table.concat(arg_split)
  102. return arg_audio
  103. end
  104. local InsertItem = function(item, title, noaudio)
  105. local tr_item = box:tag("tr")
  106. tr_item:tag("td"):css("background", color_bkg):css("text-align", "center"):css("width", "110px"):css("border-top-left-radius","0.2em"):css("border-bottom-left-radius","0.2em"):tag("b"):wikitext(title or item)
  107. if mw.ustring.find(frame.args[item], "<u>") then hasDouble = true end
  108. local text = mw.ustring.gsub(frame.args[item], "(.+)\n\n+", "<p>%1</p>")
  109. tr_item:tag("td"):wikitext(text)
  110. local arg_audio = item .. "语音"
  111. if frame.args[arg_audio] and not noaudio then
  112. local text_audio = Work_Audio(arg_audio)
  113. if text_audio then
  114. hasAudio = true
  115. tr_item:tag("td"):attr("width", "40px"):wikitext(text_audio)
  116. elseif hasAudio then
  117. tr_item:tag("td")
  118. end
  119. used[arg_audio] = true
  120. elseif hasAudio then
  121. tr_item:tag("td")
  122. end
  123. used[item] = true
  124. end
  125. local InsertSubItems = function(itemlist, title, noaudio)
  126. local tr_item = box:tag("tr")
  127. tr_item:tag("td"):attr("rowspan", #itemlist):css("background", color_bkg):css("text-align", "center"):css("width", "110px"):css("border-top-left-radius","0.2em"):css("border-bottom-left-radius","0.2em"):tag("b"):wikitext(title or "")
  128. for idx, item in ipairs(itemlist) do
  129. if mw.ustring.find(frame.args[item], "<u>") then hasDouble = true end
  130. local text = mw.ustring.gsub(frame.args[item], "(.+)\n\n+", "<p>%1</p>")
  131. tr_item:tag("td"):wikitext(text)
  132. local arg_audio = item .. "语音"
  133. if frame.args[arg_audio] and not noaudio then
  134. local text_audio = Work_Audio(arg_audio)
  135. if text_audio then
  136. hasAudio = true
  137. tr_item:tag("td"):attr("width", "40px"):wikitext(text_audio)
  138. elseif hasAudio then
  139. tr_item:tag("td")
  140. end
  141. used[arg_audio] = true
  142. elseif hasAudio then
  143. tr_item:tag("td")
  144. end
  145. if itemlist[idx + 1] then tr_item = box:tag("tr") end
  146. used[item] = true
  147. end
  148. end
  149. if index == 1 and get_arg('登录欢迎语音') ~= '' then
  150. frame.args["登录欢迎"] = "碧蓝航线!"
  151. InsertItem("登录欢迎")
  152. end
  153. for _, item in ipairs(arglist[index]) do
  154. if type(item) == "table" then
  155. local pattern = item[1]
  156. local itemlist = { }
  157. for key, value in pairs(frame.args) do
  158. if mw.ustring.match(key, "^" ..pattern .. "$") and mw.text.trim(value) ~= "" then
  159. table.insert(itemlist, key)
  160. end
  161. end
  162. table.sort(itemlist)
  163. if item.list and itemlist[1] then
  164. InsertSubItems(itemlist, item.display, item.noaudio)
  165. elseif itemlist[1] then
  166. for _, name in ipairs(itemlist) do
  167. if type(item.display) == "table" then
  168. InsertItem(name, item.display[name] or name, item.noaudio)
  169. elseif type(item.display) == "function" then
  170. local ship_name = mw.ustring.match(mw.title.getCurrentTitle().text,"^碧蓝航线:(.+)")
  171. local ship_info = shipModule().get_data(ship_name or 'null')
  172. InsertItem(name, item.display(ship_info, name), item.noaudio)
  173. else
  174. InsertItem(name, name, item.noaudio)
  175. end
  176. end
  177. end
  178. else
  179. if frame.args[item] then
  180. if mw.text.trim(frame.args[item]) ~= "" then
  181. InsertItem(item)
  182. else
  183. used[item] = true
  184. if frame.args[item .. "语音"] then used[item .. "语音"] = true end
  185. end
  186. end
  187. end
  188. end
  189. local retn = tostring(html)
  190. if hasDouble then
  191. retn = '<ul class="margin-left-set" style="margin-left: 1.2em;"><li>下方有底线为誓约新增额外台词</li></ul>' .. retn
  192. end
  193. for key, value in pairs(frame.args) do
  194. if (not used[key] and (index ~= 3 or key ~= "改造") and not hidelist[key]) or (key == "登录欢迎") then
  195. Incorrect_Add(key)
  196. elseif mw.ustring.match(value, "[暂暫][无無]") then
  197. Incorrect_Add("暂无")
  198. elseif key == "彩蛋" and mw.ustring.match(value, "\n\n") then
  199. Incorrect_Add("彩蛋")
  200. end
  201. end
  202. if incorrect[1] then retn = retn .. table.concat(incorrect) end
  203. return retn
  204. end
  205. -- 阵营名称相关([[Template:碧蓝航线阵营]])
  206. local translist = { ["Eagle"] = "白[鹰鷹]", ["Royal"] = "皇家", ["Sakura"] = "重[樱櫻]", ["Metalblood"] = "[铁鐵]血", ["Eastern"] = "[东東]煌", ["North"] = "北方[联聯]合", ["Iris"] = "自由[鸢鳶]尾", ["Vichya"] = "[维維]希教廷",
  207. ["Sardinia"] = "撒丁", ["Neptunia"] = { "海王星", "hyperdimension" }, ["Utawarerumono"] = { "传颂", "傳頌" }, ["Kizuna"] = "绊爱", ["Hololive"] = 0, ["DOAXVV"] = { "维纳斯假期", "維納斯假期" },["META"] = 0, ["Bilibili"] = "哔哩哔哩", ["None"] = { "无阵营", "無陣營", "布里神教" }
  208. , ["iM@S"] = "偶像大师", ["SSSS"] = "SSSS", ["Tempesta"] = { "飓风", "颶風" }, ["Atelier Ryza"] = { "Atelier Ryza" }, ["闪乱神乐"] = { "闪乱神乐" }}
  209. local mapslist = { ["Eagle"] = "碧蓝航线-白鹰", ["Royal"] = "碧蓝航线-皇家", ["Sakura"] = "赤色中轴-重樱", ["Metalblood"] = "赤色中轴-铁血", ["Eastern"] = "碧蓝航线-东煌", ["North"] = "碧蓝航线-北方联合", ["Iris"] = "碧蓝航线-自由鸢尾", ["Vichya"] = "赤色中轴-维希教廷",
  210. ["Neptunia"] = "????-海王星", ["Utawarerumono"] = "????-传颂之物", ["Kizuna"] = "????-KizunaAI", ["Hololive"] = "????-hololive", ["DOAXVV"] = "????-维纳斯假期", ["Sardinia"] = "赤色中轴-撒丁帝国", ["Bilibili"] = "????-哔哩哔哩", ["None"] = "????-其他",["META"] = "META-???"
  211. , ["iM@S"] = "????-偶像大师", ["SSSS"] = "????-SSSS", ["Tempesta"] = "????-飓风", ["Atelier Ryza"] = "????-Atelier Ryza", ["闪乱神乐"] = "????-闪乱神乐"}
  212. function module.team_getcode(frame)
  213. local arg_input = mw.ustring.lower(frame.args[1])
  214. for key, value in pairs(translist) do
  215. if mw.ustring.find(arg_input, mw.ustring.lower(key)) then return key end
  216. if type(value) == "string" then
  217. if mw.ustring.find(arg_input, value) then return key end
  218. elseif type(value) == "table" then
  219. for _, item in pairs(value) do
  220. if mw.ustring.find(arg_input, item) then return key end
  221. end
  222. end
  223. end
  224. return "Unknow"
  225. end
  226. function module.team_normalize(frame)
  227. local code = module.team_getcode(frame)
  228. return mapslist[code] or "阵营信息"
  229. end
  230. local alphabet = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N" }
  231. function module.MapsGen(frame)
  232. local parent = frame:getParent()
  233. if parent and parent:getTitle() == "Template:碧蓝航线地图" then
  234. frame = parent
  235. end
  236. g_frame = frame
  237. local rows = frame.args["行数"]
  238. rows = rows and tonumber(rows) or 1
  239. local cols = frame.args["列数"]
  240. cols = cols and tonumber(cols) or 1
  241. local html = mw.html.create()
  242. local box = html:tag("table"):addClass("Azur_Maps"):css( {
  243. ["position"] = "relative",
  244. ["z-index"] = "2",
  245. ["margin"] = "0",
  246. ["border-collapse"] = "collapse",
  247. ["text-align"] = "center",
  248. ["color"] = "white",
  249. ["font-weight"] = "bold",
  250. } )
  251. local tr_line = box:tag("tr"):tag("td"):done()
  252. for col = 1, cols do
  253. tr_line:tag("td"):wikitext(alphabet[col])
  254. end
  255. local arg_list = { '起点', '敌人', '塞壬', 'BOSS', '潜艇' }
  256. local objects = {}
  257. for _, arg in ipairs(arg_list) do
  258. value = get_arg(arg)
  259. mw.log(arg, value)
  260. if (value ~= '') then
  261. objects[arg] = frame:expandTemplate{ title = '碧蓝航线地图/Item', args = { arg } }
  262. list_pos = mw.text.split(value, ',')
  263. for _, pos in ipairs(list_pos) do
  264. objects[pos] = objects[arg]
  265. end
  266. end
  267. end
  268. local arg_name = ""
  269. for row = 1, rows do
  270. tr_line = box:tag("tr")
  271. tr_line:tag("td"):wikitext(tostring(row))
  272. for col = 1, cols do
  273. arg_name = tostring(row) .. alphabet[col]
  274. tr_line:tag("td"):wikitext(objects[arg_name] or frame.args[arg_name])
  275. end
  276. end
  277. return html
  278. end
  279. return module