模块:Flag

来自乐园数据管理室

此模块的文档可以在模块:Flag/doc创建

local p = {}
local QueryHelper = require("Module:Xb2QueryHelper")
local html = require("Module:Html")
local loadJson = require("Module:JSON").loadJson

-- 优先在JSON:ScenarioFlag中寻找匹配文本,找不到时去找FLAG下页面文本
function p.scenario(id)
  if id == 0 then
    return ""
  end

  local Scenario = loadJson("ScenarioFlag")
  if #Scenario[id] > 0 then
    return Scenario[id]
  end

  local title = mw.title.new("Scenario/" .. id, "FLAG")
  local content = title:getContent()
  if content then
    return content
  end

  return "[[" .. title.fullText .. "|" .. id .. "]]"
end

function p.quest(id, ira)
  if id <= 1000 then
    return nil
  end

  local questTitle, phase = QueryHelper.getQuestTitleByQuestId(id, ira)
  if questTitle == nil then
    return nil
  end

  local ns = "任务"
  if id > 6000 then
    ns = "佣兵团任务"
  end
  if ira then
    ns = "黄金之国任务"
  end
  local title = mw.title.new(questTitle, ns)
  if title.exists then
    return "[[" .. title.fullText .. "|" .. title.text .. "]]", phase
  else
    return nil
  end
end

return p