Module:Ballpark

From Blaseball Wiki

Documentation for this module may be created at Module:Ballpark/doc

local p = {}

local models = {
  "Palmero",
  "Silverada",
  "Douglas",
  "Hillcrest",
  "Twede",
  "Rodeo",
  "Loge",
  "Pine",
  "Boreal",
}

function p.ballpark(frame)
  args = (frame:getParent() or {}).args or frame.args
  id = args.uuid
  info = mw.ext.externaldata.getWebData({
    url = "https://api.sibr.dev/chronicler/v2/entities?type=stadium&id=" .. id,
    data = "data=$.items[0].data",
    format = "json",
    "use jsonpath",
    ["cache seconds"] = 3600,
    "use stale cache"
  }).data
  mods = {}
  for i, mod in ipairs(info.mods) do
    table.insert(mods, frame:expandTemplate{ title = "Modif", args = { mod }})
  end
  template_args = {}
  for key, value in pairs(args) do
    template_args[key] = value
  end
  template_args.title = info.name
  template_args.iconfull = frame:expandTemplate{ title = "BallparkIconSelector", args = { id, align = "", size = "35px" }  }
  template_args.nickname = args.nickname or info.nickname
  template_args.flag = models[info.model + 1]
  template_args.renovation = table.concat(mods)
  template_args.team = "[[" .. mw.ext.cargo.query("Teams", "name", {
    where = 'UUID="' .. info.teamId .. '"',
  })[1].name .. "]]"
  return frame:expandTemplate{ title = "Ballpark", args = template_args }
end

return p