Module:SouthernStraitCorridorOps: Difference between revisions

From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs)
Created page with "-- Module:SouthernStraitCorridorOps -- Unified daily operations wrapper for War League, Hatch Ministry, and Temple Bank missionary operations. -- This module does not rewrite the source modules. It invokes them and displays their outputs together. local p = {} -------------------------------------------------------------------------------- -- Helpers -------------------------------------------------------------------------------- local function yn(value, default) loc..."
 
NewZimiaGov (talk | contribs)
No edit summary
Line 1: Line 1:
-- Module:SouthernStraitCorridorOps
-- Module:SouthernStraitCorridorOps
-- Unified daily operations wrapper for War League, Hatch Ministry, and Temple Bank missionary operations.
-- Southern Strait-only daily operations wrapper.
-- This module does not rewrite the source modules. It invokes them and displays their outputs together.
-- Shows only Haifan Bassaridian / Southern Strait entries from:
-- 1) WarLeagueDivisionOpsBVR
-- 2) HatchMinistryDailyOps
-- 3) MissionaryDailyOpsBVR


local p = {}
local p = {}
Line 88: Line 91:


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Main combined view
-- Main Southern Strait-only view
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


Line 94: Line 97:
local args = (frame and frame.args) or {}
local args = (frame and frame.args) or {}


local showIntro     = yn(args.intro, true)
local showIntro = yn(args.intro, true)
local showLegend     = yn(args.legend or args.showlegend, false)
local showLegend = yn(args.legend or args.showlegend, false)


local includeWar    = yn(args.war or args.warleague, true)
local includeWar    = yn(args.war or args.warleague, true)
Line 113: Line 116:
if showIntro then
if showIntro then
table.insert(out, string.format(
table.insert(out, string.format(
"''Combined operational display for %s, drawing together War League deployments, Hatch Ministry privateer activity, and Temple Bank missionary operations.''",
"''Southern Strait-only operational display for %s, limited to Haifan Bassaridian / former Maritime Markets corridor entries.''",
label
label
))
))
table.insert(out, "")
table.insert(out, "")
table.insert(out, "This page is a wrapper display. The underlying operational rows remain generated by the individual War League, Hatch Ministry, and Temple Bank missionary systems.")
table.insert(out, "This display combines War League deployments, Hatch Ministry privateer activity, and Temple Bank missionary operations while excluding unrelated regional rows.")
end
end


----------------------------------------------------------------------------
----------------------------------------------------------------------------
-- War League
-- War League: Southern Strait-only
----------------------------------------------------------------------------
----------------------------------------------------------------------------


Line 128: Line 131:
year = year,
year = year,
day = day,
day = day,
rows = args.warrows or args.rows or "36",
rows = args.warrows or args.rows or "24",
showlegend = showLegend and "yes" or "no",
showlegend = showLegend and "yes" or "no",
flagsize = args.flagsize or "20",
flagsize = args.flagsize or "20",
zone = "SouthernStrait",
}
}


Line 145: Line 149:
local ok, body = safeCall("Module:WarLeagueDivisionOpsBVR", "makeTable", warArgs)
local ok, body = safeCall("Module:WarLeagueDivisionOpsBVR", "makeTable", warArgs)
table.insert(out, hr())
table.insert(out, hr())
table.insert(out, section("War League deployments", body))
table.insert(out, section("War League Southern Strait deployments", body))
end
end


----------------------------------------------------------------------------
----------------------------------------------------------------------------
-- Hatch Ministry
-- Hatch Ministry: Southern Strait-only
----------------------------------------------------------------------------
----------------------------------------------------------------------------


Line 157: Line 161:
day = day,
day = day,
legend = showLegend and "yes" or "no",
legend = showLegend and "yes" or "no",
zone = "SouthernStrait",
}
}


Line 165: Line 170:
local ok, body = safeCall("Module:HatchMinistryDailyOps", "dailyReport", hatchArgs)
local ok, body = safeCall("Module:HatchMinistryDailyOps", "dailyReport", hatchArgs)
table.insert(out, hr())
table.insert(out, hr())
table.insert(out, section("Hatch Ministry privateer operations", body))
table.insert(out, section("Hatch Ministry Southern Strait privateer operations", body))
end
end


----------------------------------------------------------------------------
----------------------------------------------------------------------------
-- Temple Bank / Missionary Operations
-- Temple Bank / Missionary Operations: Haifan only
----------------------------------------------------------------------------
----------------------------------------------------------------------------


Line 176: Line 181:
year = year,
year = year,
day = day,
day = day,
region = args.missionaryregion or args.region or "Haifan",
region = "Haifan",
showlegend = showLegend and "yes" or "no",
showlegend = showLegend and "yes" or "no",
includeThreat = args.includeThreat or args.includethreat or "no",
includeThreat = args.includeThreat or args.includethreat or "no",
Line 190: Line 195:
local ok, body = safeCall("Module:MissionaryDailyOpsBVR", "makeTable", missionaryArgs)
local ok, body = safeCall("Module:MissionaryDailyOpsBVR", "makeTable", missionaryArgs)
table.insert(out, hr())
table.insert(out, hr())
table.insert(out, section("Temple Bank missionary operations", body))
table.insert(out, section("Temple Bank Southern Strait missionary operations", body))
end
end


Line 196: Line 201:
table.insert(out, hr())
table.insert(out, hr())
table.insert(out, "=== Combined legend ===")
table.insert(out, "=== Combined legend ===")
table.insert(out, "* '''War League deployments''' show military/security responses, force allocations, oversight, and compliance notes.")
table.insert(out, "* '''War League Southern Strait deployments''' show Haifan Bassaridian / former Maritime Markets security rows only.")
table.insert(out, "* '''Hatch Ministry privateer operations''' show privateer-led port, sea, rail, anti-smuggling, and escort work.")
table.insert(out, "* '''Hatch Ministry Southern Strait privateer operations''' show Haifan home-port privateers only.")
table.insert(out, "* '''Temple Bank missionary operations''' show cult-specific missionary formations, tasking, severity, and Temple Bank notes.")
table.insert(out, "* '''Temple Bank Southern Strait missionary operations''' show Haifan Bassaridian missionary rows only.")
end
end


Line 210: Line 215:
function p.southernStrait(frame)
function p.southernStrait(frame)
local args = (frame and frame.args) or {}
local args = (frame and frame.args) or {}
args.region = args.region or "Haifan"
args.missionaryregion = args.missionaryregion or "Haifan"
args.title = args.title or "Southern Strait Corridor Daily Operations"
args.title = args.title or "Southern Strait Corridor Daily Operations"
return p.makeTable({ args = args })
return p.makeTable({ args = args })
Line 221: Line 224:
args.missionary = "no"
args.missionary = "no"
args.war = "yes"
args.war = "yes"
args.title = args.title or "War League Daily Operations"
args.title = args.title or "War League Southern Strait Daily Operations"
return p.makeTable({ args = args })
return p.makeTable({ args = args })
end
end
Line 230: Line 233:
args.missionary = "no"
args.missionary = "no"
args.hatch = "yes"
args.hatch = "yes"
args.title = args.title or "Hatch Ministry Daily Operations"
args.title = args.title or "Hatch Ministry Southern Strait Daily Operations"
return p.makeTable({ args = args })
return p.makeTable({ args = args })
end
end
Line 239: Line 242:
args.hatch = "no"
args.hatch = "no"
args.missionary = "yes"
args.missionary = "yes"
args.region = args.region or "Haifan"
args.title = args.title or "Temple Bank Southern Strait Missionary Daily Operations"
args.missionaryregion = args.missionaryregion or args.region
args.title = args.title or "Temple Bank Missionary Daily Operations"
return p.makeTable({ args = args })
return p.makeTable({ args = args })
end
end


return p
return p

Revision as of 23:49, 28 May 2026

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

-- Module:SouthernStraitCorridorOps
-- Southern Strait-only daily operations wrapper.
-- Shows only Haifan Bassaridian / Southern Strait entries from:
-- 1) WarLeagueDivisionOpsBVR
-- 2) HatchMinistryDailyOps
-- 3) MissionaryDailyOpsBVR

local p = {}

--------------------------------------------------------------------------------
-- Helpers
--------------------------------------------------------------------------------

local function yn(value, default)
	local v = tostring(value or ""):lower()
	if v == "" then return default end
	if v == "no" or v == "n" or v == "0" or v == "false" then return false end
	if v == "yes" or v == "y" or v == "1" or v == "true" then return true end
	return default
end

local function makeFrame(args)
	return { args = args or {} }
end

local function safeRequire(moduleName)
	local ok, mod = pcall(require, moduleName)
	if ok and mod then
		return mod, nil
	end
	return nil, "Could not load " .. tostring(moduleName)
end

local function safeCall(moduleName, funcName, args)
	local mod, err = safeRequire(moduleName)
	if not mod then
		return false, "''" .. err .. ".''"
	end

	if type(mod[funcName]) ~= "function" then
		return false, "''" .. tostring(moduleName) .. " has no public function named " .. tostring(funcName) .. ".''"
	end

	local ok, result = pcall(function()
		return mod[funcName](makeFrame(args))
	end)

	if not ok then
		return false, "''Error while invoking " .. tostring(moduleName) .. "." .. tostring(funcName) .. ": " .. tostring(result) .. "''"
	end

	return true, tostring(result or "")
end

local function doyToMonthDom(doy)
	doy = tonumber(doy) or 1
	if doy < 1 then doy = 1 end
	if doy > 183 then doy = 183 end

	if doy <= 61 then
		return 1, doy
	elseif doy <= 122 then
		return 2, doy - 61
	else
		return 3, doy - 122
	end
end

local function dateLabel(args)
	local y = tonumber(args.year or args.psscyear)
	local d = tonumber(args.day or args.dayofyear)

	if y and d then
		local m, dom = doyToMonthDom(d)
		return string.format("%d/%d/%d PSSC", dom, m, y)
	end

	return "current PSSC date"
end

local function section(title, body)
	local out = {}
	table.insert(out, "===" .. title .. "===")
	table.insert(out, body or "''No output.''")
	return table.concat(out, "\n")
end

local function hr()
	return "\n----\n"
end

--------------------------------------------------------------------------------
-- Main Southern Strait-only view
--------------------------------------------------------------------------------

function p.makeTable(frame)
	local args = (frame and frame.args) or {}

	local showIntro  = yn(args.intro, true)
	local showLegend = yn(args.legend or args.showlegend, false)

	local includeWar     = yn(args.war or args.warleague, true)
	local includeHatch   = yn(args.hatch or args.hatchministry, true)
	local includeMission = yn(args.missionary or args.templebank, true)

	local year = args.year or args.psscyear
	local day  = args.day or args.dayofyear

	local title = args.title or "Southern Strait Corridor Daily Operations"
	local label = dateLabel(args)

	local out = {}

	table.insert(out, "==" .. title .. "==")

	if showIntro then
		table.insert(out, string.format(
			"''Southern Strait-only operational display for %s, limited to Haifan Bassaridian / former Maritime Markets corridor entries.''",
			label
		))
		table.insert(out, "")
		table.insert(out, "This display combines War League deployments, Hatch Ministry privateer activity, and Temple Bank missionary operations while excluding unrelated regional rows.")
	end

	----------------------------------------------------------------------------
	-- War League: Southern Strait-only
	----------------------------------------------------------------------------

	if includeWar then
		local warArgs = {
			year = year,
			day = day,
			rows = args.warrows or args.rows or "24",
			showlegend = showLegend and "yes" or "no",
			flagsize = args.flagsize or "20",
			zone = "SouthernStrait",
		}

		if args.division and tostring(args.division) ~= "" then
			warArgs.division = args.division
		elseif args.wardivision and tostring(args.wardivision) ~= "" then
			warArgs.division = args.wardivision
		end

		if args.seed and tostring(args.seed) ~= "" then
			warArgs.seed = args.seed
		end

		local ok, body = safeCall("Module:WarLeagueDivisionOpsBVR", "makeTable", warArgs)
		table.insert(out, hr())
		table.insert(out, section("War League Southern Strait deployments", body))
	end

	----------------------------------------------------------------------------
	-- Hatch Ministry: Southern Strait-only
	----------------------------------------------------------------------------

	if includeHatch then
		local hatchArgs = {
			year = year,
			day = day,
			legend = showLegend and "yes" or "no",
			zone = "SouthernStrait",
		}

		if args.captain and tostring(args.captain) ~= "" then
			hatchArgs.captain = args.captain
		end

		local ok, body = safeCall("Module:HatchMinistryDailyOps", "dailyReport", hatchArgs)
		table.insert(out, hr())
		table.insert(out, section("Hatch Ministry Southern Strait privateer operations", body))
	end

	----------------------------------------------------------------------------
	-- Temple Bank / Missionary Operations: Haifan only
	----------------------------------------------------------------------------

	if includeMission then
		local missionaryArgs = {
			year = year,
			day = day,
			region = "Haifan",
			showlegend = showLegend and "yes" or "no",
			includeThreat = args.includeThreat or args.includethreat or "no",
			showEcon = args.showEcon or args.showecon or "no",
		}

		if args.missionarylimit and tostring(args.missionarylimit) ~= "" then
			missionaryArgs.limit = args.missionarylimit
		elseif args.limit and tostring(args.limit) ~= "" then
			missionaryArgs.limit = args.limit
		end

		local ok, body = safeCall("Module:MissionaryDailyOpsBVR", "makeTable", missionaryArgs)
		table.insert(out, hr())
		table.insert(out, section("Temple Bank Southern Strait missionary operations", body))
	end

	if showLegend then
		table.insert(out, hr())
		table.insert(out, "=== Combined legend ===")
		table.insert(out, "* '''War League Southern Strait deployments''' show Haifan Bassaridian / former Maritime Markets security rows only.")
		table.insert(out, "* '''Hatch Ministry Southern Strait privateer operations''' show Haifan home-port privateers only.")
		table.insert(out, "* '''Temple Bank Southern Strait missionary operations''' show Haifan Bassaridian missionary rows only.")
	end

	return table.concat(out, "\n")
end

--------------------------------------------------------------------------------
-- Shortcut views
--------------------------------------------------------------------------------

function p.southernStrait(frame)
	local args = (frame and frame.args) or {}
	args.title = args.title or "Southern Strait Corridor Daily Operations"
	return p.makeTable({ args = args })
end

function p.warOnly(frame)
	local args = (frame and frame.args) or {}
	args.hatch = "no"
	args.missionary = "no"
	args.war = "yes"
	args.title = args.title or "War League Southern Strait Daily Operations"
	return p.makeTable({ args = args })
end

function p.hatchOnly(frame)
	local args = (frame and frame.args) or {}
	args.war = "no"
	args.missionary = "no"
	args.hatch = "yes"
	args.title = args.title or "Hatch Ministry Southern Strait Daily Operations"
	return p.makeTable({ args = args })
end

function p.missionaryOnly(frame)
	local args = (frame and frame.args) or {}
	args.war = "no"
	args.hatch = "no"
	args.missionary = "yes"
	args.title = args.title or "Temple Bank Southern Strait Missionary Daily Operations"
	return p.makeTable({ args = args })
end

return p