Module:MissionaryDailyOpsBVR
From MicrasWiki
Documentation for this module may be created at Module:MissionaryDailyOpsBVR/doc
--------------------------------------------------------------------------------
-- WX (Ops Alert) integration from Module:BassaridiaForecast
-- Used to display a city-level ops badge + bump severity + append weather-driven tasking.
--------------------------------------------------------------------------------
local wxOk, wx = pcall(require, "Module:BassaridiaForecast")
if not wxOk then wx = nil end
local function wxColor(level)
level = tonumber(level) or 0
if level == 3 then return "#f8d7da" end
if level == 2 then return "#ffe5cc" end
if level == 1 then return "#fff3cd" end
return "#d4edda"
end
local function opsCell(cityName, year, dayOfYear)
if not wx or type(wx.getOpsData) ~= "function" then return "n/a", nil end
local op = wx.getOpsData(cityName, year, dayOfYear)
if not op or not op.alert then return "n/a", nil end
local lvl = tonumber(op.alert.level) or 0
local label = tostring(op.alert.label or "Green")
local cond = tostring(op.condition or "")
local bg = wxColor(lvl)
local cell = string.format(
"<span style='background:%s;padding:2px 6px;border:1px solid #ccc;border-radius:10px;white-space:nowrap;'>%s</span>%s",
bg, label, (cond ~= "" and ("<br/><span style='font-size:90%;'>" .. cond .. "</span>") or "")
)
return cell, op
end
local function bumpSevWeather(sev, op)
if not op or not op.alert then return sev end
local lvl = tonumber(op.alert.level) or 0
local imp = op.impacts or {}
-- Only Orange/Red force severity bumps (Yellow stays informational)
if lvl == 2 and sev == "green" then sev = "yellow" end
if lvl >= 3 then sev = "red" end
-- Hard constraints should always push to at least yellow
if (imp.ground == "Hazard" or imp.sea == "Closed" or imp.air == "No-Go") and sev == "green" then
sev = "yellow"
end
return sev
end
local function weatherTaskOverlay(op)
if not op or not op.alert then return "" end
local lvl = tonumber(op.alert.level) or 0
if lvl < 2 then return "" end -- only Orange/Red appends operational language
local haz = tostring(op.alert.hazard or "weather disruption")
local imp = op.impacts or {}
local cond = tostring(op.condition or "")
local base = " Weather-driven tasking: " .. haz .. " (" ..
string.format("Gnd %s / Sea %s / Air %s", imp.ground or "OK", imp.sea or "OK", imp.air or "OK") .. ")."
if cond == "Storm" or cond == "Rain" then
return base .. " Queue stabilization at clinics/relief points; rumor containment bulletins posted; shrine-district patrol lanes marked."
elseif cond == "Blizzard" or cond == "Snow" then
return base .. " Warming-shelter checks; fuel and medicine custody verification; travel guidance posted at shrine gates."
elseif cond == "Fog" then
return base .. " Navigation warnings and crowd guidance in canal/port corridors; panic narratives suppressed early."
elseif cond == "Dust" then
return base .. " Mask discipline, indoor refuge advisories, and vendor hygiene enforcement prioritized."
else
return base .. " Welfare checks and public messaging prioritized."
end
end