Module:GeneralPortOperations: Difference between revisions

From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs)
No edit summary
NewZimiaGov (talk | contribs)
Undo revision 359969 by NewZimiaGov (talk)
Tag: Undo
Line 4: Line 4:
-- 1) Date logic
-- 1) Date logic
function p.getCurrentDate()
function p.getCurrentDate()
     local start  = os.time{year=1999,month=8,day=6}
     local startDate = os.time{year=1999, month=8, day=6}
     local elapsed= math.floor((os.time() - start)/86400)
     local secs, daysecs = os.time() - startDate, 86400
     local year   = math.floor(elapsed/183)
    local daysPerYear = 183
     local day   = (elapsed % 183) + 1
    local totalDays = math.floor(secs/ daysecs)
     local year = math.floor(totalDays / daysPerYear)
     local day = (totalDays % daysPerYear) + 1
     return year, day
     return year, day
end
end
Line 14: Line 16:
local function randomChoice(t) return t[math.random(#t)] end
local function randomChoice(t) return t[math.random(#t)] end


-- 3) Static data
-- 3) Fixed data sets
local cities = {
local cities = {
     "Vaeringheim","Somniumpolis","Delphica","Ephyra","Norsolyra",
     "Vaeringheim","Somniumpolis","Delphica","Ephyra","Norsolyra",
Line 20: Line 22:
     "Keybir-Aviv","Aegirheim","Bjornopolis"
     "Keybir-Aviv","Aegirheim","Bjornopolis"
}
}
local cityFlag = {
local cityFlags = {
     Vaeringheim="[[File:VaeringheimFlag.png|20px]]",
     Vaeringheim="[[File:VaeringheimFlag.png|20px]] Vaeringheim",
     Somniumpolis="[[File:SomniumpolisFlag.png|20px]]",
     Somniumpolis="[[File:SomniumpolisFlag.png|20px]] Somniumpolis",
     Delphica="[[File:DelphicaFlag.png|20px]]",
     Delphica="[[File:DelphicaFlag.png|20px]] Delphica",
     Ephyra="[[File:EphyraFlag.png|20px]]",
     Ephyra="[[File:EphyraFlag.png|20px]] Ephyra",
     Norsolyra="[[File:NorsolyraFlag.png|20px]]",
     Norsolyra="[[File:NorsolyraFlag.png|20px]] Norsolyra",
     ["Skýrophos"]="[[File:SkyrophosFlag.png|20px]]",
     ["Skýrophos"]="[[File:SkyrophosFlag.png|20px]] Skýrophos",
     Riddersborg="[[File:RiddersborgFlag.png|20px]]",
     Riddersborg="[[File:RiddersborgFlag.png|20px]] Riddersborg",
     Ardclach="[[File:ArdclachFlag.png|20px]]",
     Ardclach="[[File:ArdclachFlag.png|20px]] Ardclach",
     Jogi="[[File:JogiFlag.png|20px]]",
     Jogi="[[File:JogiFlag.png|20px]] Jogi",
     Sufriya="[[File:SufriyaFlag.png|20px]]",
     Sufriya="[[File:SufriyaFlag.png|20px]] Sufriya",
     ["Keybir-Aviv"]="[[File:KeybirAvivFlag.png|20px]]",
     ["Keybir-Aviv"]="[[File:KeybirAvivFlag.png|20px]] Keybir-Aviv",
     Aegirheim="[[File:AegirheimFlag.png|20px]]",
     Aegirheim="[[File:AegirheimFlag.png|20px]] Aegirheim",
     Bjornopolis="[[File:BjornopolisFlag.png|20px]]"
     Bjornopolis="[[File:BjornopolisFlag.png|20px]] Bjornopolis",
}
}


local vesselTypes = {"Cargo","Military","Ritual","Privateer"}
local vesselTypes     = { "Cargo", "Military", "Ritual", "Privateer" }
local cargoTypes = {"Agricultural","Mining/Manufacturing","Services","Unspecified"}
local cargoTypes     = { "Agricultural", "Mining/Manufacturing", "Services", "Unspecified" }
 
local ritualCults     = {
local ritualCults = {
     "Ordo Solis Invicti","Order of Aurora Mystica","Harmony Sanctum","Ignis Aeternum",
     "Ordo Solis Invicti","Order of Aurora Mystica","Harmony Sanctum","Ignis Aeternum",
     "Celestial Harmony Sect","Guild of Golden Shadows","Azure Sentinel Sect","Reverie Nebulous",
     "Celestial Harmony Sect","Guild of Golden Shadows","Azure Sentinel Sect","Reverie Nebulous",
Line 47: Line 48:
     "Sanctum Delphica","Ordo Amicitia","Temple Illuminata"
     "Sanctum Delphica","Ordo Amicitia","Temple Illuminata"
}
}
local militaryDivs = {
local militaryDivs   = {
     "Alpazkigz Division","Odiferia Division","Vaeringheim Division","Haifa Division",
     "Alpazkigz Division","Odiferia Division","Vaeringheim Division","Haifa Division",
     "Jeseri Division","Hatch Ministry Division","New South Jangsong Division","Haifan Bassaridia Division"
     "Jeseri Division","Hatch Ministry Division","New South Jangsong Division","Haifan Bassaridia Division"
}
}
 
local privateerCaptains = {
-- 3a) Company pools
     {first="Talvios", last="Karnis",    nick="Erebektos"},
local agriCompanies = {
    {first="Mirek",   last="Davros",   nick="Zammarion"},
     "Gladeseed Farmers' Union","Atterian Cattle Drivers","Noctic Fleet",
     {first="Ilion",   last="Quoros"},
     "Jogiani Merchants of Manwine","Keepers of the Grove of Zoe Elm",
     {first="Sevon",   last="Halek",     nick="Thamuthis"},
     "Sea-Elm Southern Meadery","Plains of Jogi","Ale of the Night Central Brewery",
     {first="Caldris", last="Onir",      nick="Votharion"},
     "Camel Herders of the Jangsong Province","Anterran Imports and Services",
     {first="Loras",   last="Tarnok"},
     "Merchant Guild of the Poppy Goddess","Grand Cave Bee Meadery",
    {first="Vaelen",  last="Koros"},
     "Cinammon Plains of Rouge","The Velvet Company","Seamstresses of Rouge",
     {first="Daskos", last="Meyron",   nick="Orontion"},
     "Salurian Temple of Sacred Horehound","Bulhanu Ranchers' Association",
     {first="Kyric",   last="Fenros",    nick="Mekharsan"},
     "Suncliff Fisheries","Ministers of Mistress Mugwort",
     {first="Omir",   last="Thalos"},
     "Blood Vineyards of the Far North","Norsolyrian Wisp Rice Farmers Association",
     {first="Baryon", last="Syrek",    nick="Satharkon"},
     "Giid-Lisea Ranching Import Company","Bird Keepers of Saluria",
     {first="Orien",   last="Damar"},
     "Hunters of the Giant Fanged Penguin","Knights Castle Reindeer Herders",
     {first="Tharkos", last="Nyros",    nick="Vathmenos"},
     "Lindley Whaling Company","Aminian Coffee Company"
     {first="Halion", last="Trevik"},
}
    {first="Kelvir",  last="Raan",      nick="Nabarrion"},
local miningCompanies = {
     {first="Lethan", last="Kohr"},
     "Baratar Corporation","Roving Wind Farm Corporation",
     {first="Zarik",   last="Tharn"},
     "Thalassian Temple Granite Export Cooperative","East Keltian Iron Company",
     {first="Varas",   last="Jorik",    nick="Tharnukhet"},
     "Mylecian Coal Ports","Merchants of the Valley of Diamonds",
     {first="Yasrek", last="Tymon"},
     "East Keltian Timber Company","Onceanic Boot Company",
     {first="Aethon", last="Morvek",   nick="Vathromen"},
     "Commune of the Garganid Apostles","Shï Collective","Order of the Sphinx",
     {first="Crivos", last="Elyen"},
     "Market Hanavusu","Somniant Stock Fund"
    {first="Saran",   last="Valic"},
}
    {first="Drevos", last="Helkan",   nick="Khamsuron"},
local serviceCompanies = {
     {first="Nyros",   last="Qalor"},
    "Lake Morovia Blockade Fund","Court of the Dark Harpy","Hatch Ministry",
     {first="Talen",   last="Vorric",   nick="Valkhoret"}
    "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"
}
}


-- 3b) Logos
-- 4) master product lists
local companyLogo = {
  ["Gladeseed Farmers' Union"]="Gladeseed420.png",
  ["Atterian Cattle Drivers"]="Atterian420.png",
  ["Noctic Fleet"]="Noctic420.png",
  ["Jogiani Merchants of Manwine"]="Jogiani420.png",
  ["Keepers of the Grove of Zoe Elm"]="KeepersoftheGrove.png",
  ["Sea-Elm Southern Meadery"]="SeaElm420.png",
  ["Plains of Jogi"]="PlainsofJogi.png",
  ["Ale of the Night Central Brewery"]="AleofNight420.png",
  ["Camel Herders of the Jangsong Province"]="CamelHerders420.png",
  ["Anterran Imports and Services"]="AnterranImports420.png",
  ["Merchant Guild of the Poppy Goddess"]="PoppyGoddess420.png",
  ["Grand Cave Bee Meadery"]="GrandCave420.png",
  ["Cinammon Plains of Rouge"]="CinammonPlains420.png",
  ["The Velvet Company"]="VelvetHome420.png",
  ["Seamstresses of Rouge"]="Seamstresses420.png",
  ["Salurian Temple of Sacred Horehound"]="SalurianTemple421.png",
  ["Bulhanu Ranchers' Association"]="Bulhanu421.png",
  ["Suncliff Fisheries"]="Suncliff421.png",
  ["Ministers of Mistress Mugwort"]="Mugwort421.png",
  ["Blood Vineyards of the Far North"]="BloodVineyards421.png",
  ["Norsolyrian Wisp Rice Farmers Association"]="Norsolyrian421.png",
  ["Giid-Lisea Ranching Import Company"]="GiidLisea421.png",
  ["Bird Keepers of Saluria"]="SaluriaBK421.png",
  ["Hunters of the Giant Fanged Penguin"]="FangedPenguin421.png",
  ["Knights Castle Reindeer Herders"]="KnightsCastle421.png",
  ["Lindley Whaling Company"]="LindleyWhalingCompany.png",
  ["Aminian Coffee Company"]="Aminian421.png",
  ["Baratar Corporation"]="Baratar420.png",
  ["Roving Wind Farm Corporation"]="RovingWind420.png",
  ["Thalassian Temple Granite Export Cooperative"]="ThalassianGranite420.png",
  ["East Keltian Iron Company"]="EKIron420.png",
  ["Mylecian Coal Ports"]="CoalPorts420.png",
  ["Merchants of the Valley of Diamonds"]="ValleyofDiamonds420.png",
  ["East Keltian Timber Company"]="EKTimber420.png",
  ["Onceanic Boot Company"]="OnceanicBoot421.png",
  ["Commune of the Garganid Apostles"]="Garganid421.png",
  ["Shï Collective"]="ShiCollective421.png",
  ["Order of the Sphinx"]="OrderofSphinx421.png",
  ["Market Hanavusu"]="MarketHanavusu421.png",
  ["Somniant Stock Fund"]="SomniantStockFund.png",
  ["Lake Morovia Blockade Fund"]="BlockadeFund420.png",
  ["Court of the Dark Harpy"]="CourtDarkHarpy.png",
  ["Hatch Ministry"]="HatchMinistry420.png",
  ["Maritime Guild of the Cult of Maskmakers"]="MaritimeGuild420.png",
  ["Ergonian Spy Agency"]="ErgonianSpy421.png",
  ["Temple Bank of the Reformed Stripping Path"]="TempleBankCrest.png",
  ["Couriers of the Lizard Queen"]="LizardQueen421.png",
  ["Temple University of Delphica"]="TempleUniversity421.png",
  ["La Sái Ebile"]="LaSie421.png",
  ["Hellhound Breeders of Dragevik"]="Dragevik421.png"
}
 
-- 3c) Product lists
local agriProducts = {
local agriProducts = {
  "Rice — Gladeseed Farmers' Union",
    "Rice — Gladeseed Farmers' Union",
  "Edible Algae — Gladeseed Farmers' Union",
    "Edible Algae — Gladeseed Farmers' Union",
  "Shrimp — Gladeseed Farmers' Union",
    "Shrimp — Gladeseed Farmers' Union",
  "Anterran Spicy Onion — Gladeseed Farmers' Union",
    "Anterran Spicy Onion — Gladeseed Farmers' Union",
  "Queen's Garlic — Gladeseed Farmers' Union",
    "Queen's Garlic — Gladeseed Farmers' Union",
  "Morovian Water Buffalo — Atterian Cattle Drivers",
    "Morovian Water Buffalo — Atterian Cattle Drivers",
  "Morovian Water Buffalo Beef — Atterian Cattle Drivers",
    "Morovian Water Buffalo Beef — Atterian Cattle Drivers",
  "Unprocessed Noctic-Rabrev Flower — Noctic Fleet",
    "Unprocessed Noctic-Rabrev Flower — Noctic Fleet",
  "Processed Noctic Rabrev Flower — Noctic Fleet",
    "Processed Noctic Rabrev Flower — Noctic Fleet",
  "Noctic-Rabrev Flower Concentrate — Noctic Fleet",
    "Noctic-Rabrev Flower Concentrate — Noctic Fleet",
  "Unprocessed Noctic-Rabrev Leaf — Noctic Fleet",
    "Unprocessed Noctic-Rabrev Leaf — Noctic Fleet",
  "Processed Noctic-Rabrev Leaf — Noctic Fleet",
    "Processed Noctic-Rabrev Leaf — Noctic Fleet",
  "Unprocessed Noctic-Rabrev Leaf Concentrate — Noctic Fleet",
    "Unprocessed Noctic-Rabrev Leaf Concentrate — Noctic Fleet",
  "Processed Noctic-Rabrev Leaf Concentrate — Noctic Fleet",
    "Processed Noctic-Rabrev Leaf Concentrate — Noctic Fleet",
  "Manwine — Jogiani Merchants of Manwine",
    "Manwine — Jogiani Merchants of Manwine",
  "Milkwine — Jogiani Merchants of Manwine",
    "Milkwine — Jogiani Merchants of Manwine",
  "Zoe Elm Resin (Unrefined) — Keepers of the Grove of Zoe Elm",
    "Zoe Elm Resin (Unrefined) — Keepers of the Grove of Zoe Elm",
  "Zoe Elm Resin (Refined) — 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",
    "Sea Elm Flavored Mead — Sea-Elm Southern Meadery",
  "Wheat — Plains of Jogi",
    "Wheat — Plains of Jogi",
  "Oats — Plains of Jogi",
    "Oats — Plains of Jogi",
  "Cereal — Plains of Jogi",
    "Cereal — Plains of Jogi",
  "Hay — Plains of Jogi",
    "Hay — Plains of Jogi",
  "Ale of the Night — Ale of the Night Central Brewery",
    "Ale of the Night — Ale of the Night Central Brewery",
  "Camels — Camel Herders of the Jangsong Province",
    "Camels — Camel Herders of the Jangsong Province",
  "Camel Meat — Camel Herders of the Jangsong Province",
    "Camel Meat — Camel Herders of the Jangsong Province",
  "Camel Milk — 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 — Camel Herders of the Jangsong Province",
  "Camel Hump Water Tea — Camel Herders of the Jangsong Province",
    "Camel Hump Water Tea — Camel Herders of the Jangsong Province",
  "Pearls — Anterran Imports and Services",
    "Pearls — Anterran Imports and Services",
  "Abalone — Anterran Imports and Services",
    "Abalone — Anterran Imports and Services",
  "Opium — Merchant Guild of the Poppy Goddess",
    "Opium — Merchant Guild of the Poppy Goddess",
  "Hash — Merchant Guild of the Poppy Goddess",
    "Hash — Merchant Guild of the Poppy Goddess",
  "Mead — Grand Cave Bee Meadery",
    "Mead — Grand Cave Bee Meadery",
  "Cinammon — Cinammon Plains of Rouge",
    "Cinammon — Cinammon Plains of Roue",
  "Velvet Worm Meat — The Velvet Company",
    "Velvet Worm Meat — The Velvet Company",
  "Velvet Worm Eggs — The Velvet Company",
    "Velvet Worm Eggs — The Velvet Company",
  "Silk — Seamstresses of Rouge",
    "Silk — Seamstresses of Rouge",
  "Horehound Mead — Salurian Temple of Sacred Horehound",
    "Horehound Mead — Salurian Temple of Sacred Horehound",
  "Horehound Beer — Salurian Temple of Sacred Horehound",
    "Horehound Beer — Salurian Temple of Sacred Horehound",
  "Sea Cow Beef — Bulhanu Ranchers' Association",
    "Sea Cow Beef — Bulhanu Ranchers' Association",
  "Atterian Armored Pufferfish — Suncliff Fisheries",
    "Atterian Armored Pufferfish — Suncliff Fisheries",
  "Morovian Saucer Eyed Giant Eel — Suncliff Fisheries",
    "Morovian Saucer Eyed Giant Eel — Suncliff Fisheries",
  "Amina Crab — Suncliff Fisheries",
    "Amina Crab — Suncliff Fisheries",
  "Mugwort Oil — Ministers of Mistress Mugwort",
    "Mugwort Oil — Ministers of Mistress Mugwort",
  "Ground Mugwort — Ministers of Mistress Mugwort",
    "Ground Mugwort — Ministers of Mistress Mugwort",
  "Mugwort Tincture — Ministers of Mistress Mugwort",
    "Mugwort Tincture — Ministers of Mistress Mugwort",
  "Blood InfusedRed Wine — Blood Vineyards of the Far North",
    "Blood InfusedRed Wine — Blood Vineyards of the Far North",
  "Wisp Rice — Norsolyrian Wisp Rice Farmers Association",
    "Wisp Rice — Norsolyrian Wisp Rice Farmers Association",
  "Giid-Lisea-Eda — Giid-Lisea Ranching Import Company",
    "Giid-Lisea-Eda — Giid Lisea Ranching Import Company",
  "Giid-Lisea-Eda Beef — Giid-Lisea Ranching Import Company",
    "Giid-Lisea-Eda Beef — Giid Lisea Ranching Import Company",
  "Vaeringheim Turkey Meat — Bird Keepers of Saluria",
    "Vaeringheim Turkey Meat — Bird Keepers of Saluria",
  "Salurian Swamp Quail Eggs — 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 — Hunters of the Giant Fanged Penguin",
  "Giant Fanged Penguin Blubber Oil Extract — Hunters of the Giant Fanged Penguin",
    "Giant Fanged Penguin Blubber Oil Extract — Hunters of the Giant Fanged Penguin",
  "Coffee — Aminian Coffee Company"
    "Coffee — Aminian Coffee Company"
}
}
local miningProducts = {
local miningProducts = {
  "Purple Granite — Thalassian Temple Granite Export Cooperative",
    "Purple Granite — Thalassian Temples Granite Export Cooperative",
  "Iron — East Keltian Iron Company",
    "Iron — East Keltian Iron Company",
  "Steel — East Keltian Iron Company",
    "Steel — East Keltian Iron Company",
  "Concrete — East Keltian Iron Company",
    "Concrete — East Keltian Iron Company",
  "Coal — Mylecian Coal Ports",
    "Coal — Mylecian Coal Ports",
  "Diamonds — Merchants of the Valley of Diamonds",
    "Diamonds — Merchants of the Valley of Diamonds",
  "Timber — East Keltian Timber Company",
    "Timber — East Keltian Timber Company",
  "Mens' Boots — Onceanic Boot Company",
    "Men’s Boots — Onceanic Boot Company",
  "Womens' Boots — Onceanic Boot Company",
    "Women’s Boots — Onceanic Boot Company",
  "Garganram Sign Plains Fertilizer — Commune of the Garganid Apostles",
    "Garganram Sign Plains Fertilizer — Commune of the Garganid Apostles",
  "Gold Necklaces — Shï Collective",
    "Gold Necklaces — Shï Collective",
  "Gold Rings — Shï Collective",
    "Gold Rings — Shï Collective",
  "Gold Bracelets — Shï Collective",
    "Gold Bracelets — Shï Collective",
  "Gold Earrings — Shï Collective",
    "Gold Earrings — Shï Collective",
  "Robes — Order of the Sphinx",
    "Robes — Order of the Sphinx",
  "Dresses — Order of the Sphinx",
    "Dresses — Order of the Sphinx",
  "Tarnkappes — Order of the Sphinx",
    "Tarnkappes — Order of the Sphinx",
  "Coats — Order of the Sphinx",
    "Coats — Order of the Sphinx",
  "Perfume — Market Hanavusu",
    "Perfume — Market Hanavusu",
  "Cologne — Market Hanavusu",
    "Cologne — Market Hanavusu",
  "Incense — Market Hanavusu",
    "Incense — Market Hanavusu",
  "Candles — Market Hanavusu"
    "Candles — Market Hanavusu"
}
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"
}
}


-- 3d) Privateer captains
-- 5) Pick a random privateer name
local privateers = {
    {first="Talvios",last="Karnis",nick="Erebektos"},
    {first="Mirek",  last="Davros",nick="Zammarion"},
    -- …etc.—use your full list here…
}
local function getRandomPrivateer()
local function getRandomPrivateer()
     local c = randomChoice(privateers)
     local c= randomChoice(privateerCaptains)
     if c.nick and math.random()<0.25 then
     if c.nick and math.random()<0.25 then
         return string.format("Captain %s “%s” %s",c.first,c.nick,c.last)
         return string.format("Captain %s “%s” %s",c.first,c.nick,c.last)
Line 236: Line 186:
end
end


-- 4) Determine Owner/Operator
-- 6) Attach Owner/Operator
local function getOwner(vt,ct)
local function getOwner(vtype, cargotype)
     if     vt=="Ritual"    then return randomChoice(ritualCults)
     if vtype=="Ritual"    then return randomChoice(ritualCults) end
     elseif vt=="Military"  then return randomChoice(militaryDivs)
     if vtype=="Military"  then return randomChoice(militaryDivs) end
     elseif vt=="Privateer" then return getRandomPrivateer()
     if vtype=="Privateer" then return getRandomPrivateer() end
     elseif vt=="Cargo" then
     -- Cargo
        if     ct=="Agricultural"         then return randomChoice(agriCompanies)
    if cargotype=="Agricultural" then return randomChoice(serviceCompanies) end
        elseif ct=="Mining/Manufacturing" then return randomChoice(miningCompanies)
    if cargotype=="Agricultural" then return "Gladeseed Farmers' Union" end
        elseif ct=="Services"            then return randomChoice(serviceCompanies)
    if cargotype=="Mining/Manufacturing" then
        end
        return randomChoice{ "Baratar Corporation","Roving Wind Farm Corporation",
            "Thalassian Temples 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" }
     end
     end
    if cargotype=="Services" then return randomChoice(serviceCompanies) end
     return "Independent Consortium"
     return "Independent Consortium"
end
end


-- 5) Build the ship table
-- 7) Build the table
function p.generateShipTable()
function p.generateShipTable()
    math.randomseed(os.time())
    local year, day = p.getCurrentDate()
     local ships = {}
     local ships = {}
     for i=1,math.random(50,80) do
     for i=1,math.random(50,80) do
         local hr, mn = math.random(0,23), math.random(0,59)
         local hr, mn = math.random(0,23), math.random(0,59)
         local vt = randomChoice(vesselTypes)
        local t = hr*60+mn
         local ct = randomChoice(cargoTypes)
         local vt= randomChoice(vesselTypes)
 
         local ct= randomChoice(cargoTypes)
        -- pick up to 3 products if Cargo+Agr/Mfg
         local prodList={}
         local prods = {}
         if ct=="Agricultural" then
         if vt=="Cargo" and ct=="Agricultural" then
             for _=1,math.random(1,3) do
             for _=1,math.random(1,3) do
                 prods[#prods+1] = randomChoice(agriProducts)
                 prodList[#prodList+1]=randomChoice(agriProducts)
             end
             end
         elseif vt=="Cargo" and ct=="Mining/Manufacturing" then
         elseif ct=="Mining/Manufacturing" then
             for _=1,math.random(1,3) do
             for _=1,math.random(1,3) do
                 prods[#prods+1] = randomChoice(miningProducts)
                 prodList[#prodList+1]=randomChoice(miningProducts)
             end
             end
         end
         end
 
         ships[#ships+1]={
        local owner = getOwner(vt,ct)
             date       = string.format("Day %d, Y.%d",p.getCurrentDate()),
        local logo  = companyLogo[owner] and ("[[File:"..companyLogo[owner].."|20px]] ") or ""
             time       = string.format("%02d:%02d",hr,mn),
 
             sort       = t,
         ships[#ships+1] = {
             vid         = "VM-"..math.random(10000,99999),
             date       = string.format("Day %d, Y.%d", day, year),
             home       = cityFlags[randomChoice(cities)],
             time       = string.format("%02d:%02d",hr,mn),
             type       = vt,
             sort       = hr*60 + mn,
             owner      = getOwner(vt,ct),
             vid       = "VM-"..math.random(10000,99999),
             cargotype   = ct,
             home       = cityFlag[randomChoice(cities)],
             products   = prodList,
             typ       = vt,
             berth       = math.random(1,124),
             ownerCell  = logo..owner,
             teus       = math.random(100,1000),
             cargotype = ct,
             tonnage     = string.format("%.2f",math.random()*19000+1000),
             products   = prods,
             queue       = string.format("%.2f",math.random()*5.5+0.5),
             berth     = math.random(1,124),
             turnaround = string.format("%.2f",math.random()*32+4),
             teus       = math.random(100,1000),
             error       = (math.random()<0.2 and randomChoice{
             tonnage   = string.format("%.2f",math.random()*19000+1000),
                "Cargo Mislabeling","Improper Documentation",
             queue     = string.format("%.2f",math.random()*5.5+0.5),
                "Surveillance Anomaly","Inspection Failure",
             turnaround = string.format("%.2f",math.random()*32+4),
                "Unregistered Ritual Cargo"
             error     = (math.random()<0.2 and randomChoice{
            }) or "None"
                            "Cargo Mislabeling","Improper Documentation",
                            "Surveillance Anomaly","Inspection Failure",
                            "Unregistered Ritual Cargo"
                        }) or "None"
         }
         }
     end
     end
 
     table.sort(ships,function(a,b) return a.sort<b.sort end)
     table.sort(ships, function(a,b) return a.sort<b.sort end)


     local out = {
     local out = {
      '{| class="wikitable sortable"',
        '{| class="wikitable sortable"',
      '! Date !! Time !! Vessel ID !! Home City !! Type !! Owner/Operator !! Cargo Type !! Products !! Berth !! TEUs !! Tonnage (t) !! Queue (hrs) !! Turnaround (hrs) !! Error'
        '! 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
     for _,s in ipairs(ships) do
         local prodCell = "#N/A"
         local prodCell = "#N/A"
         if #s.products>0 then
         if #s.products>0 then
             prodCell = "<ul>"
             prodCell = "<ul>"
             for _,pr in ipairs(s.products) do
             for _,p in ipairs(s.products) do prodCell=prodCell.."<li>"..p.."</li>" end
                prodCell = prodCell.."<li>"..pr.."</li>"
            end
             prodCell = prodCell.."</ul>"
             prodCell = prodCell.."</ul>"
         end
         end
         out[#out+1] = string.format(
         out[#out+1] = string.format(
          "|-\n| %s || %s || %s || %s || %s || %s || %s || %s || %d || %d || %s || %s || %s || %s",
            "|-\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.date,s.time,s.vid,s.home,s.type,s.owner,s.cargotype,
          s.ownerCell, s.cargotype, prodCell,
            prodCell,s.berth,s.teus,s.tonnage,s.queue,s.turnaround,s.error
          s.berth, s.teus, s.tonnage, s.queue, s.turnaround, s.error
         )
         )
     end
     end
     out[#out+1] = "|}\n\n'''Error Key:'''"
     out[#out+1] = "|}\n\n'''Error Key:'''"
     out[#out+1] = "* '''Cargo Mislabeling:''' Manifest ≠ actual goods"
     out[#out+1] = "* '''Cargo Mislabeling:''' Manifest ≠ actual goods"
Line 330: Line 270:
     out[#out+1] = "* '''Inspection Failure:''' Customs/hatch failure"
     out[#out+1] = "* '''Inspection Failure:''' Customs/hatch failure"
     out[#out+1] = "* '''Unregistered Ritual Cargo:''' Not pre-cleared by Temple Bank"
     out[#out+1] = "* '''Unregistered Ritual Cargo:''' Not pre-cleared by Temple Bank"
 
     return table.concat(out,"\n")
     return table.concat(out, "\n")
end
end


function p.dailyReport()
function p.dailyReport()
     local y,d = p.getCurrentDate()
     local y,d = p.getCurrentDate()
     local hdr = string.format(
     return string.format(
      "'''General Port of Lake Morovia: Operational Log – Day %d, Year %d PSSC'''", d, y
        "'''General Port of Lake Morovia: Operational Log – Day %d, Year %d PSSC'''","\n"
    )
    )..p.generateShipTable()
    return hdr.."\n"..p.generateShipTable()
end
end


return p
return p

Revision as of 02:11, 24 April 2025

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

-- Module:GeneralPortDailyLog
local p = {}

-- 1) Date logic
function p.getCurrentDate()
    local startDate = os.time{year=1999, month=8, day=6}
    local secs, daysecs = os.time() - startDate, 86400
    local daysPerYear = 183
    local totalDays = math.floor(secs/ daysecs)
    local year = math.floor(totalDays / daysPerYear)
    local day = (totalDays % daysPerYear) + 1
    return year, day
end

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

-- 3) Fixed data sets
local cities = {
    "Vaeringheim","Somniumpolis","Delphica","Ephyra","Norsolyra",
    "Skýrophos","Riddersborg","Ardclach","Jogi","Sufriya",
    "Keybir-Aviv","Aegirheim","Bjornopolis"
}
local cityFlags = {
    Vaeringheim="[[File:VaeringheimFlag.png|20px]] Vaeringheim",
    Somniumpolis="[[File:SomniumpolisFlag.png|20px]] Somniumpolis",
    Delphica="[[File:DelphicaFlag.png|20px]] Delphica",
    Ephyra="[[File:EphyraFlag.png|20px]] Ephyra",
    Norsolyra="[[File:NorsolyraFlag.png|20px]] Norsolyra",
    ["Skýrophos"]="[[File:SkyrophosFlag.png|20px]] Skýrophos",
    Riddersborg="[[File:RiddersborgFlag.png|20px]] Riddersborg",
    Ardclach="[[File:ArdclachFlag.png|20px]] Ardclach",
    Jogi="[[File:JogiFlag.png|20px]] Jogi",
    Sufriya="[[File:SufriyaFlag.png|20px]] Sufriya",
    ["Keybir-Aviv"]="[[File:KeybirAvivFlag.png|20px]] Keybir-Aviv",
    Aegirheim="[[File:AegirheimFlag.png|20px]] Aegirheim",
    Bjornopolis="[[File:BjornopolisFlag.png|20px]] Bjornopolis",
}

local vesselTypes     = { "Cargo", "Military", "Ritual", "Privateer" }
local cargoTypes      = { "Agricultural", "Mining/Manufacturing", "Services", "Unspecified" }
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"
}
local privateerCaptains = {
    {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"}
}

-- 4) master 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 Roue",
    "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 Temples 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",
    "Men’s Boots — Onceanic Boot Company",
    "Women’s 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"
}
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"
}

-- 5) Pick a random privateer name
local function getRandomPrivateer()
    local c= randomChoice(privateerCaptains)
    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

-- 6) Attach Owner/Operator
local function getOwner(vtype, cargotype)
    if vtype=="Ritual"    then return randomChoice(ritualCults) end
    if vtype=="Military"  then return randomChoice(militaryDivs) end
    if vtype=="Privateer" then return getRandomPrivateer() end
    -- Cargo
    if cargotype=="Agricultural" then return randomChoice(serviceCompanies) end
    if cargotype=="Agricultural" then return "Gladeseed Farmers' Union" end
    if cargotype=="Mining/Manufacturing" then
        return randomChoice{ "Baratar Corporation","Roving Wind Farm Corporation",
            "Thalassian Temples 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" }
    end
    if cargotype=="Services" then return randomChoice(serviceCompanies) end
    return "Independent Consortium"
end

-- 7) Build the table
function p.generateShipTable()
    local ships = {}
    for i=1,math.random(50,80) do
        local hr, mn = math.random(0,23), math.random(0,59)
        local t = hr*60+mn
        local vt= randomChoice(vesselTypes)
        local ct= randomChoice(cargoTypes)
        local prodList={}
        if ct=="Agricultural" then
            for _=1,math.random(1,3) do
                prodList[#prodList+1]=randomChoice(agriProducts)
            end
        elseif ct=="Mining/Manufacturing" then
            for _=1,math.random(1,3) do
                prodList[#prodList+1]=randomChoice(miningProducts)
            end
        end
        ships[#ships+1]={
            date        = string.format("Day %d, Y.%d",p.getCurrentDate()),
            time        = string.format("%02d:%02d",hr,mn),
            sort        = t,
            vid         = "VM-"..math.random(10000,99999),
            home        = cityFlags[randomChoice(cities)],
            type        = vt,
            owner       = getOwner(vt,ct),
            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
        local prodCell = "#N/A"
        if #s.products>0 then
            prodCell = "<ul>"
            for _,p in ipairs(s.products) do prodCell=prodCell.."<li>"..p.."</li>" end
            prodCell = prodCell.."</ul>"
        end
        out[#out+1] = 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.type,s.owner,s.cargotype,
            prodCell,s.berth,s.teus,s.tonnage,s.queue,s.turnaround,s.error
        )
    end
    out[#out+1] = "|}\n\n'''Error Key:'''"
    out[#out+1] = "* '''Cargo Mislabeling:''' Manifest ≠ actual goods"
    out[#out+1] = "* '''Improper Documentation:''' Missing/outdated papers"
    out[#out+1] = "* '''Surveillance Anomaly:''' Odd heat/motion signature"
    out[#out+1] = "* '''Inspection Failure:''' Customs/hatch failure"
    out[#out+1] = "* '''Unregistered Ritual Cargo:''' Not pre-cleared by Temple Bank"
    return table.concat(out,"\n")
end

function p.dailyReport()
    local y,d = p.getCurrentDate()
    return string.format(
        "'''General Port of Lake Morovia: Operational Log – Day %d, Year %d PSSC'''","\n"
    )..p.generateShipTable()
end

return p