Module:GeneralPortOperations
From MicrasWiki
Documentation for this module may be created at Module:GeneralPortOperations/doc
-- Module:GeneralPortDailyLog
local p = {}
-- 1) Date logic
function p.getCurrentDate()
local start = os.time{year=1999,month=8,day=6}
local elapsed = math.floor((os.time() - start) / 86400)
local year = math.floor(elapsed / 183)
local day = (elapsed % 183) + 1
return year, day
end
-- 2) Helpers
local function randomChoice(t) return t[math.random(#t)] end
-- normalize a name into a file-base (strip non-alphanumerics)
local function normalize(str)
return (str:gsub("%W", "")) -- remove everything not a letter/number/underscore
end
-- return the 20px-logo wikitext for any company/cult/division name
local function logoFor(name)
return string.format("[[File:%sLogo.png|20px]]", normalize(name))
end
-- 3) City list + flags
local cities = {
"Vaeringheim","Somniumpolis","Delphica","Ephyra","Norsolyra",
"Skýrophos","Riddersborg","Ardclach","Jogi","Sufriya",
"Keybir-Aviv","Aegirheim","Bjornopolis","Luminaria","Serena",
"Lunalis Sancta","Sylvapolis","Symphonara","Aurelia","Ferrum Citadel",
"Catonis Atrium","Pyralis","Nexa","Acheron","Saluria","Erythros",
"Aetherium","Koinonía","Aureum","Odiferia","Odiferian Tribes",
"Hafaan","Jeseri","New South Jangsong Division","Hatch Ministry Division",
"Alpazkigz Division","Haifan Bassaridia Division","Thorsalon",
"Pelagia","Myrene","Thyrea","Halicarn","Tel-Amin","Diamandis",
"Lewisburg","Thermosalem","Akróstadium","Lykopolis"
}
local cityFlag = {}
for _,c in ipairs(cities) do
cityFlag[c] = string.format("[[File:%sFlag.png|20px]]", normalize(c))
end
-- 4) Vessel & Cargo types
local vesselTypes = {"Cargo","Military","Ritual","Privateer"}
local cargoTypes = {"Agricultural","Mining/Manufacturing","Services","Unspecified"}
-- 5) Ritual cults & military divisions
local ritualCults = {
"Ordo Solis Invicti","Order of Aurora Mystica","Harmony Sanctum","Ignis Aeternum",
"Celestial Harmony Sect","Guild of Golden Shadows","Azure Sentinel Sect","Reverie Nebulous",
"Eon Fellowship","Order of the Umbral Oracle","Mystery of the Verdant Embrace","Conclave Illuminara",
"Sanctum Vitalis","Temple Alabaster","Court of the Ironclad","Accord Concordia",
"Mystery of the Stygian Veil","Sylvan Fellowship","Mystery of Red Mirth","Rex Catonis",
"Sanctum Delphica","Ordo Amicitia","Temple Illuminata"
}
local militaryDivs = {
"Alpazkigz Division","Odiferia Division","Vaeringheim Division","Haifa Division",
"Jeseri Division","Hatch Ministry Division","New South Jangsong Division","Haifan Bassaridia Division"
}
-- 6) Company pools
local agriCompanies = {
"Gladeseed Farmers' Union","Atterian Cattle Drivers","Noctic Fleet",
"Jogiani Merchants of Manwine","Keepers of the Grove of Zoe Elm",
"Sea-Elm Southern Meadery","Plains of Jogi","Ale of the Night Central Brewery",
"Camel Herders of the Jangsong Province","Anterran Imports and Services",
"Merchant Guild of the Poppy Goddess","Grand Cave Bee Meadery",
"Cinammon Plains of Rouge","The Velvet Company","Seamstresses of Rouge",
"Salurian Temple of Sacred Horehound","Bulhanu Ranchers' Association",
"Suncliff Fisheries","Ministers of Mistress Mugwort",
"Blood Vineyards of the Far North","Norsolyrian Wisp Rice Farmers Association",
"Giid-Lisea Ranching Import Company","Bird Keepers of Saluria",
"Hunters of the Giant Fanged Penguin","Knights Castle Reindeer Herders",
"Lindley Whaling Company","Aminian Coffee Company"
}
local miningCompanies = {
"Baratar Corporation","Roving Wind Farm Corporation",
"Thalassian Temple Granite Export Cooperative","East Keltian Iron Company",
"Mylecian Coal Ports","Merchants of the Valley of Diamonds",
"East Keltian Timber Company","Onceanic Boot Company",
"Commune of the Garganid Apostles","Shï Collective","Order of the Sphinx",
"Market Hanavusu","Somniant Stock Fund"
}
local serviceCompanies = {
"Lake Morovia Blockade Fund","Court of the Dark Harpy","Hatch Ministry",
"Maritime Guild of the Cult of Maskmakers","Ergonian Spy Agency",
"Temple Bank of the Reformed Stripping Path","Couriers of the Lizard Queen",
"Temple University of Delphica","La Sái Ebile","Hellhound Breeders of Dragevik"
}
-- 7) Product lists
local agriProducts = {
"Rice — Gladeseed Farmers' Union","Edible Algae — Gladeseed Farmers' Union",
"Shrimp — Gladeseed Farmers' Union","Anterran Spicy Onion — Gladeseed Farmers' Union",
"Queen's Garlic — Gladeseed Farmers' Union","Morovian Water Buffalo — Atterian Cattle Drivers",
"Morovian Water Buffalo Beef — Atterian Cattle Drivers",
"Unprocessed Noctic-Rabrev Flower — Noctic Fleet",
"Processed Noctic Rabrev Flower — Noctic Fleet",
"Noctic-Rabrev Flower Concentrate — Noctic Fleet",
"Unprocessed Noctic-Rabrev Leaf — Noctic Fleet",
"Processed Noctic-Rabrev Leaf — Noctic Fleet",
"Unprocessed Noctic-Rabrev Leaf Concentrate — Noctic Fleet",
"Processed Noctic-Rabrev Leaf Concentrate — Noctic Fleet",
"Manwine — Jogiani Merchants of Manwine","Milkwine — Jogiani Merchants of Manwine",
"Zoe Elm Resin (Unrefined) — Keepers of the Grove of Zoe Elm",
"Zoe Elm Resin (Refined) — Keepers of the Grove of Zoe Elm",
"Sea Elm Flavored Mead — Sea-Elm Southern Meadery","Wheat — Plains of Jogi",
"Oats — Plains of Jogi","Cereal — Plains of Jogi","Hay — Plains of Jogi",
"Ale of the Night — Ale of the Night Central Brewery",
"Camels — Camel Herders of the Jangsong Province",
"Camel Meat — Camel Herders of the Jangsong Province",
"Camel Milk — Camel Herders of the Jangsong Province",
"Camel Hump Water — Camel Herders of the Jangsong Province",
"Camel Hump Water Tea — Camel Herders of the Jangsong Province",
"Pearls — Anterran Imports and Services","Abalone — Anterran Imports and Services",
"Opium — Merchant Guild of the Poppy Goddess","Hash — Merchant Guild of the Poppy Goddess",
"Mead — Grand Cave Bee Meadery","Cinammon — Cinammon Plains of Rouge",
"Velvet Worm Meat — The Velvet Company","Velvet Worm Eggs — The Velvet Company",
"Silk — Seamstresses of Rouge","Horehound Mead — Salurian Temple of Sacred Horehound",
"Horehound Beer — Salurian Temple of Sacred Horehound",
"Sea Cow Beef — Bulhanu Ranchers' Association",
"Atterian Armored Pufferfish — Suncliff Fisheries",
"Morovian Saucer Eyed Giant Eel — Suncliff Fisheries",
"Amina Crab — Suncliff Fisheries","Mugwort Oil — Ministers of Mistress Mugwort",
"Ground Mugwort — Ministers of Mistress Mugwort",
"Mugwort Tincture — Ministers of Mistress Mugwort",
"Blood InfusedRed Wine — Blood Vineyards of the Far North",
"Wisp Rice — Norsolyrian Wisp Rice Farmers Association",
"Giid-Lisea-Eda — Giid-Lisea Ranching Import Company",
"Giid-Lisea-Eda Beef — Giid-Lisea Ranching Import Company",
"Vaeringheim Turkey Meat — Bird Keepers of Saluria",
"Salurian Swamp Quail Eggs — Bird Keepers of Saluria",
"Giant Fanged Penguin Blubber — Hunters of the Giant Fanged Penguin",
"Giant Fanged Penguin Blubber Oil Extract — Hunters of the Giant Fanged Penguin",
"Coffee — Aminian Coffee Company"
}
local miningProducts = {
"Purple Granite — Thalassian Temple Granite Export Cooperative",
"Iron — East Keltian Iron Company","Steel — East Keltian Iron Company",
"Concrete — East Keltian Iron Company","Coal — Mylecian Coal Ports",
"Diamonds — Merchants of the Valley of Diamonds",
"Timber — East Keltian Timber Company","Mens' Boots — Onceanic Boot Company",
"Womens' Boots — Onceanic Boot Company",
"Garganram Sign Plains Fertilizer — Commune of the Garganid Apostles",
"Gold Necklaces — Shï Collective","Gold Rings — Shï Collective",
"Gold Bracelets — Shï Collective","Gold Earrings — Shï Collective",
"Robes — Order of the Sphinx","Dresses — Order of the Sphinx",
"Tarnkappes — Order of the Sphinx","Coats — Order of the Sphinx",
"Perfume — Market Hanavusu","Cologne — Market Hanavusu",
"Incense — Market Hanavusu","Candles — Market Hanavusu"
}
-- 8) Privateer captains
local privateers = {
{first="Talvios", last="Karnis", nick="Erebektos"},
{first="Mirek", last="Davros",nick="Zammarion"},
{first="Ilion", last="Quoros"},
{first="Sevon", last="Halek", nick="Thamuthis"},
{first="Caldris", last="Onir", nick="Votharion"},
{first="Loras", last="Tarnok"},
{first="Vaelen", last="Koros"},
{first="Daskos", last="Meyron",nick="Orontion"},
{first="Kyric", last="Fenros",nick="Mekharsan"},
{first="Omir", last="Thalos"},
{first="Baryon", last="Syrek", nick="Satharkon"},
{first="Orien", last="Damar"},
{first="Tharkos", last="Nyros", nick="Vathmenos"},
{first="Halion", last="Trevik"},
{first="Kelvir", last="Raan", nick="Nabarrion"},
{first="Lethan", last="Kohr"},
{first="Zarik", last="Tharn"},
{first="Varas", last="Jorik", nick="Tharnukhet"},
{first="Yasrek", last="Tymon"},
{first="Aethon", last="Morvek",nick="Vathromen"},
{first="Crivos", last="Elyen"},
{first="Saran", last="Valic"},
{first="Drevos", last="Helkan",nick="Khamsuron"},
{first="Nyros", last="Qalor"},
{first="Talen", last="Vorric",nick="Valkhoret"}
}
local function getRandomPrivateer()
local c = randomChoice(privateers)
if c.nick and math.random()<0.25 then
return string.format("Captain %s “%s” %s", c.first,c.nick,c.last)
else
return string.format("Captain %s %s", c.first,c.last)
end
end
-- 9) Determine Owner/Operator
local function getOwner(vt,ct)
if vt=="Ritual" then return randomChoice(ritualCults)
elseif vt=="Military" then return randomChoice(militaryDivs)
elseif vt=="Privateer" then return getRandomPrivateer()
elseif vt=="Cargo" then
if ct=="Agricultural" then return randomChoice(agriCompanies)
elseif ct=="Mining/Manufacturing" then return randomChoice(miningCompanies)
elseif ct=="Services" then return randomChoice(serviceCompanies)
end
end
return "Independent Consortium"
end
-- 10) Build the table
function p.generateShipTable()
math.randomseed(os.time())
local year, day = p.getCurrentDate()
local ships = {}
for i=1, math.random(50,80) do
local hr, mn = math.random(0,23), math.random(0,59)
local vt = randomChoice(vesselTypes)
local ct = randomChoice(cargoTypes)
-- collect products if Agricultural or Mining
local prodList = {}
if ct=="Agricultural" then
for _=1, math.random(1,3) do table.insert(prodList, randomChoice(agriProducts)) end
elseif ct=="Mining/Manufacturing" then
for _=1, math.random(1,3) do table.insert(prodList, randomChoice(miningProducts)) end
end
local owner = getOwner(vt,ct)
local home = randomChoice(cities)
table.insert(ships,{
date = string.format("Day %d, Y.%d", day, year),
time = string.format("%02d:%02d", hr, mn),
sort = hr*60 + mn,
vid = "VM-"..math.random(10000,99999),
home = cityFlag[home].." "..home,
typ = vt,
ownerCell = logoFor(owner).." "..owner,
cargotype = ct,
products = prodList,
berth = math.random(1,124),
teus = math.random(100,1000),
tonnage = string.format("%.2f", math.random()*19000+1000),
queue = string.format("%.2f", math.random()*5.5+0.5),
turnaround = string.format("%.2f", math.random()*32+4),
error = (math.random()<0.2 and randomChoice{
"Cargo Mislabeling","Improper Documentation",
"Surveillance Anomaly","Inspection Failure",
"Unregistered Ritual Cargo"
}) or "None"
})
end
table.sort(ships, function(a,b) return a.sort<b.sort end)
local out = {
'{| class="wikitable sortable"',
'! Date !! Time !! Vessel ID !! Home City !! Type !! Owner/Operator !! Cargo Type !! Products !! Berth !! TEUs !! Tonnage (t) !! Queue (hrs) !! Turnaround (hrs) !! Error'
}
for _,s in ipairs(ships) do
-- build product cell
local prodCell = "#N/A"
if #s.products>0 then
prodCell = "<ul>"
for _,entry in ipairs(s.products) do
local name,comp = entry:match("^(.-)%s+%—%s+(.+)$")
if comp then
prodCell = prodCell .. string.format(
"<li>%s %s — %s</li>",
logoFor(comp), name, comp
)
else
prodCell = prodCell .. "<li>"..entry.."</li>"
end
end
prodCell = prodCell .. "</ul>"
end
table.insert(out, string.format(
"|-\n| %s || %s || %s || %s || %s || %s || %s || %s || %d || %d || %s || %s || %s || %s",
s.date, s.time, s.vid, s.home, s.typ,
s.ownerCell, s.cargotype, prodCell,
s.berth, s.teus, s.tonnage, s.queue, s.turnaround, s.error
))
end
table.insert(out,"|}\n\n'''Error Key:'''")
table.insert(out,"* '''Cargo Mislabeling:''' Manifest ≠ actual goods")
table.insert(out,"* '''Improper Documentation:''' Missing or outdated papers")
table.insert(out,"* '''Surveillance Anomaly:''' Unexpected heat or movement signature")
table.insert(out,"* '''Inspection Failure:''' Failed customs or hatch review")
table.insert(out,"* '''Unregistered Ritual Cargo:''' Religious items not pre-cleared by the Temple Bank")
return table.concat(out,"\n")
end
function p.dailyReport()
local y,d = p.getCurrentDate()
local hdr = string.format(
"'''General Port of Lake Morovia: Operational Log – Day %d, Year %d PSSC'''", d, y
)
return hdr.."\n"..p.generateShipTable()
end
return p