Module:GeneralPortSecurityLog

From MicrasWiki
Revision as of 19:30, 23 April 2025 by NewZimiaGov (talk | contribs) (Created page with "-- Module:GeneralPortSecurityLog local p = {} local function getCurrentDate() local startDate = os.time({year = 1999, month = 8, day = 6}) local currentDate = os.time() local daysPerYear = 183 local totalDaysElapsed = math.floor((currentDate - startDate) / 86400) local year = math.floor(totalDaysElapsed / daysPerYear) local day = (totalDaysElapsed % daysPerYear) + 1 return year, day end local function randomChoice(t) return t[math.random...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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

-- Module:GeneralPortSecurityLog
local p = {}

local function getCurrentDate()
    local startDate = os.time({year = 1999, month = 8, day = 6})
    local currentDate = os.time()
    local daysPerYear = 183
    local totalDaysElapsed = math.floor((currentDate - startDate) / 86400)
    local year = math.floor(totalDaysElapsed / daysPerYear)
    local day = (totalDaysElapsed % daysPerYear) + 1
    return year, day
end

local function randomChoice(t)
    return t[math.random(#t)]
end

function p.generateSecurityLog()
    local year, day = getCurrentDate()
    local dateStr = string.format("Day %d, Y.%d", day, year)

    local patrolRotations = math.random(3, 8)
    local navalEvent = randomChoice({"None", "Live-Fire Exercise", "Sonar Calibration Run", "Emergency Recall: Cultic Violation", "Naval Formation Drill"})
    local surveillanceStatus = randomChoice({"Standard Sweep", "Heightened Alert", "Grid Lockdown – Suspicious Contact", "Night Watch Routine"})

    local threats = {}
    for _ = 1, math.random(0, 3) do
        table.insert(threats, randomChoice({"Suspected Pirate Vessel", "Cargo Smuggler Identified", "Illicit Ritual Materials Detected", "Unknown Submersible"}))
    end

    local interdictions = math.random(0, 4)
    local reinspections = math.random(0, 6)

    local restrictedEntries = {}
    for _ = 1, math.random(1, 5) do
        table.insert(restrictedEntries, string.format("%s vessel granted access to high-security zone", randomChoice({"Naval", "Cultic"})))
    end

    local log = "{| class=\"wikitable\" style=\"width:100%\"\n"
    log = log .. string.format("! colspan=2 | General Port of Lake Morovia – Security Operations Log (%s)\n", dateStr)
    log = log .. "|-\n"
    log = log .. string.format("| '''Hatch Ministry Patrol Rotations''' || %d\n", patrolRotations)
    log = log .. "|-\n"
    log = log .. string.format("| '''Naval Activity''' || %s\n", navalEvent)
    log = log .. "|-\n"
    log = log .. string.format("| '''Surveillance Grid Status''' || %s\n", surveillanceStatus)
    log = log .. "|-\n"
    log = log .. string.format("| '''Detected Threats''' || %s\n", (#threats > 0 and table.concat(threats, ", ") or "None"))
    log = log .. "|-\n"
    log = log .. string.format("| '''Interdictions Conducted''' || %d\n", interdictions)
    log = log .. "|-\n"
    log = log .. string.format("| '''Customs Reinspections''' || %d\n", reinspections)
    log = log .. "|-\n"
    log = log .. string.format("| '''Restricted Zone Access''' || <ul><li>%s</li></ul>\n", table.concat(restrictedEntries, "</li><li>"))
    log = log .. "|}"

    return log
end

function p.dailySecuritySummary()
    local year, day = getCurrentDate()
    local header = string.format("'''General Port of Lake Morovia: Security Log – Day %d, Year %d PSSC'''\n", day, year)
    return header .. p.generateSecurityLog()
end

return p