Module:AutoUpdateAgPrices: Difference between revisions

From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs)
No edit summary
NewZimiaGov (talk | contribs)
No edit summary
 
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
---------------------------------------------------------
---------------------------------------------------------
-- Module:DailyPriceTable
-- Module:AutoUpdateAgPrices
-- Generates a table of daily-updated product prices,
-- Generates daily-updated agricultural-sector prices.
-- with each cell changing automatically once per day.
--
--
-- Features:
-- Features:
--  • Seeds randomness each day using localTime.year + localTime.yday
--  • Seeds randomness each day using localTime.year + localTime.yday
--  • No manual intervention required
--  • Tier prices derived from the final adjusted price
--  • Tier prices derived from the final adjusted price
--  • Minor event-based price boost for special days
--  • Minor event-based price boost for special days
--  • NEW (Dec 2025): Condensed display (Tier I headline) + collapsible full breakdown
--  • NEW (Dec 2025): Δ symbol column (↑ Low / ↓ High / • Standard)
--  • NEW (Dec 2025): Modes so editors can force full expanded output when updating
--
-- Usage:
--  {{#invoke:AutoUpdateAgPrices|generateTable}}
--    - default: summary + collapsed breakdown
--  {{#invoke:AutoUpdateAgPrices|generateTable|mode=summary}}
--    - summary only
--  {{#invoke:AutoUpdateAgPrices|generateTable|mode=breakdown}}
--    - breakdown only (collapsed by default)
--  {{#invoke:AutoUpdateAgPrices|generateTable|mode=breakdown|collapse=no}}
--    - breakdown only (expanded)
--  {{#invoke:AutoUpdateAgPrices|full}}
--    - breakdown only (expanded) convenience function
---------------------------------------------------------
---------------------------------------------------------


Line 16: Line 30:
-- 1. getCurrentDate
-- 1. getCurrentDate
--    Determines today's PSSC date and returns:
--    Determines today's PSSC date and returns:
--      * dateString in "day/month/year [PSSC]"
--      * dateString in "day/month/year [[PSSC]]"
--      * dayOfMonth (1..61 or 1..61 or 1..61)
--      * dayOfMonth (1..61)
--      * month (1=Atosiel, 2=Thalassiel, 3=Opsitheiel)
--      * month (1=Atosiel, 2=Thalassiel, 3=Opsitheiel)
---------------------------------------------------------
---------------------------------------------------------
local function getCurrentDate()
local function getCurrentDate()
    local startDate = os.time({year = 1999, month = 8, day = 6})
local startDate = os.time({ year = 1999, month = 8, day = 6 })
    local secondsInDay = 86400
local secondsInDay = 86400
    local daysPerYear = 183
local daysPerYear = 183
 
local currentDate = os.time()
    local currentDate = os.time()
local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay)
    local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay)


    local yearFraction = totalDaysElapsed / daysPerYear
local yearFraction = totalDaysElapsed / daysPerYear
    local psscYear = math.floor(yearFraction)
local psscYear = math.floor(yearFraction)
    local dayOfYear = math.floor((yearFraction - psscYear) * daysPerYear) + 1
local dayOfYear = math.floor((yearFraction - psscYear) * daysPerYear) + 1


    local month, dayOfMonth
local month, dayOfMonth
    if dayOfYear <= 61 then
if dayOfYear <= 61 then
        month = 1
month = 1
        dayOfMonth = dayOfYear
dayOfMonth = dayOfYear
    elseif dayOfYear <= 122 then
elseif dayOfYear <= 122 then
        month = 2
month = 2
        dayOfMonth = dayOfYear - 61
dayOfMonth = dayOfYear - 61
    else
else
        month = 3
month = 3
        dayOfMonth = dayOfYear - 122
dayOfMonth = dayOfYear - 122
    end
end


    return string.format("%d/%d/%d [[PSSC]]", dayOfMonth, month, psscYear), dayOfMonth, month
return string.format("%d/%d/%d [[PSSC]]", dayOfMonth, month, psscYear), dayOfMonth, month, psscYear, dayOfYear
end
end


Line 51: Line 64:
---------------------------------------------------------
---------------------------------------------------------
local products = {
local products = {
    {"Rice", "Gladeseed Farmers' Union", 9.00, "tons"},
{ "Rice", "Gladeseed Farmers' Union", 9.00, "tons" },
    {"Edible Algae", "Gladeseed Farmers' Union", 21.00, "tons"},
{ "Edible Algae", "Gladeseed Farmers' Union", 21.00, "tons" },
    {"Shrimp", "Gladeseed Farmers' Union", 15.00, "tons"},
{ "Shrimp", "Gladeseed Farmers' Union", 15.00, "tons" },
    {"Anterran Spicy Onion", "Gladeseed Farmers' Union", 18.00, "tons"},
{ "Anterran Spicy Onion", "Gladeseed Farmers' Union", 18.00, "tons" },
    {"Queen's Garlic", "Gladeseed Farmers' Union", 27.00, "tons"},
{ "Queen's Garlic", "Gladeseed Farmers' Union", 27.00, "tons" },
    {"Morovian Water Buffalo", "Atterian Cattle Drivers", .60, "head"},
{ "Morovian Water Buffalo", "Atterian Cattle Drivers", 0.60, "head" },
    {"Morovian Water Buffalo Beef", "Atterian Cattle Drivers", 5, "tons"},
{ "Morovian Water Buffalo Beef", "Atterian Cattle Drivers", 5.00, "tons" },
    {"Unprocessed Noctic-Rabrev Leaf Concentrate", "Noctic Fleet", .60, "barrels"},
{ "Morovian Water Buffalo Milk (raw)", "Atterian Cattle Drivers", 1.20, "barrels" },
    {"Processed Noctic-Rabrev Leaf Concentrate", "Noctic Fleet", .30, "barrels"},
{ "Morovian Water Buffalo Milk (cultured)", "Atterian Cattle Drivers", 1.60, "barrels" },
    {"Dried Noctic-Rabrev Petals",
{ "Morovian Water Buffalo Cheese (aged wheels)", "Atterian Cattle Drivers", 3.40, "wheels" },
{ "Morovian Water Buffalo Butter (salted)", "Atterian Cattle Drivers", 2.10, "crates" },
{ "Morovian Water Buffalo Hides (cured)", "Atterian Cattle Drivers", 2.80, "sheets" },
{ "Morovian Water Buffalo Horn Blanks", "Atterian Cattle Drivers", 1.10, "bundles" },
{ "Morovian Water Buffalo Tallow (rendered)", "Atterian Cattle Drivers", 1.75, "barrels" },
{ "Morovian Water Buffalo Bone Meal (fertilizer)", "Atterian Cattle Drivers", 0.95, "sacks" },
{ "Unprocessed Noctic-Rabrev Leaf Concentrate", "Noctic Fleet", .60, "barrels" },
{ "Processed Noctic-Rabrev Leaf Concentrate", "Noctic Fleet", .30, "barrels" },
{ "Dried Noctic-Rabrev Petals", "Noctic Fleet", 2.25, "kilograms" },
{ "Noctic-Rabrev Flower Oil Extract", "Noctic Fleet", .450, "liters" },
{ "Noctic-Rabrev Culinary Spice Blend", "Noctic Fleet", 1.75, "kilograms" },
{ "Sanctified Noctic Leaf (ritual-grade)", "Noctic Fleet", 9.00, "bundles" },
{ "Noctic Tincture (therapeutic dosage)", "Noctic Fleet", 2.50, "vials" },
{ "Noctic-Rabrev Infused Incense", "Noctic Fleet", 3.00, "packs" },
{ "Noctic Flower Lokum (sweet export)", "Noctic Fleet
}
}


---------------------------------------------------------
---------------------------------------------------------
---------------------------------------------------------
-- 2.5 City-Signal Integrations (WX / War / Hatch / Temple / Health)
---------------------------------------------------------
local forecastOk, forecast = pcall(require, "Module:BassaridiaForecast")
local warOk, war = pcall(require, "Module:WarLeagueDivisionOpsBVR")
local hatchOk, hatch = pcall(require, "Module:HatchMinistryDailyOps")
local outbreakOk, outbreaks = pcall(require, "Module:BassaridiaOutbreaks")
local function escapePattern(s)
s = tostring(s or "")
return s:gsub("([%%%^%$%(%)%.%[%]%*%+%-%?])", "%%%1")
end
-- Company HQ mapping (from General Port company table). For HQs that are not forecast cities,
-- city signals will simply not apply (safe fallback).
local companyHQOverrides = {
["Gladeseed Farmers' Union"] = "Vaeringheim",
["Atterian Cattle Drivers Company"] = "Somniumpolis",
["Atterian Cattle Drivers"] = "Somniumpolis",
["Keepers of the Grove of Zoe Elm"] = "Laceran Mountains",
["Plains of Jogi"] = "Jogi",
["Ale of the Night Central Brewery"] = "Jogi",
["Camel Herders of the Jangsong Province"] = "Manduay region",
["Grand Cave Bee Meadery"] = "Mylecia",
["Cinnamon Plains of Rouge"] = "Rouge",
["Cinammon Plains of Rouge"] = "Rouge",
["Cinammon Plains of Roue"] = "Rouge",
["Velvet Homestead"] = "Rouge",
["The Velvet Company"] = "Rouge",
["Commune of the Garganid Apostles"] = "Vaeringheim",
["Salurian Temple of Sacred Horehound"] = "Saluria",
["Bulhanu Ranchers' Association"] = "Somniumpolis",
["Suncliff Fisheries"] = "Skýrophos",
["Ministers of Mistress Mugwort"] = "Thorsalon",
["Blood Vineyards of the Far North"] = "Thorsalon",
["Norsolyrian Wisp Rice Farmers Association"] = "Norsolyra",
["Giid-Lisea Ranching Import Company"] = "Pyralis",
["Bird Keepers of Saluria"] = "Saluria",
["Hellhound Breeders of Dragevik"] = "Dragevik",
["Aminian Coffee Company"] = "Tel-Amin",
["Knights Castle Reindeer Herders"] = "Riddersborg",
["Lindley Whaling Company"] = "Ardclach",
["Granadita Collective"] = "Eastern southern Strait coastal villages",
["Herd Caton"] = "Catonis Atrium",
["Wasp Hunters of the Austral Isles"] = "Austral Isles",
["Sea-Elm Southern Meadery"] = "Blore Heath",
["Nefel Village"] = "Jogi",
["Diamonia Sugar Cooperatives"] = "Diamandis",
["Ouriana Lowlands Farmers' Association"] = "Bashkim",
["Ouriad River Fisheries Cooperative"] = "Ourid",
["Caspazani Livestock Company"] = "Bashkim",
["White Ruby Communes"] = "Notranskja",
["Fange Velvet"] = "Fanghorn",
["Lamian Ward"] = "Erythros",
["Sleva Farming Supply Cooperatives"] = "Slevik",
["Hrimmanes Woolhorse Company"] = "Eikbu",
["King's Home Fur Trappers' Cooperative"] = "Elijah's Rest",
["Caledonj Bay Fishermen’s’ Cooperatives"] = "Slevik",
["Grove Synaxis of Tel-Amin"] = "Tel-Amin",
["Wardens of the Fields of Callope"] = "Aureum",
["Pontic Esperance Homestead Association"] = "Mirovia",
["Nysaran Velai Farmers' League"] = "Nysara Velai",
["Reed Farms of the Upper Thyrsa"] = "Saruq Thyrsa",
["Kefayrûn Qarazir House"] = "Rumi-Kefaya",
-- Services/other companies that appear in the ag price list
["Noctic Fleet"] = "", -- Fleet-based; no fixed city
["Jogiani Merchants of Manwine"] = "Jogi",
["Anterran Imports and Services"] = "Alphaville",
["Merchant Guild of the Poppy Goddess"] = "Vaeringheim",
["Hunters of the Giant Fanged Penguin"] = "Gulf of Jangsong",
["Port of Corumia"] = "Corum",
["Lenaian Water Company"] = "Thal Qencha",
}
-- Cities we can detect from names (extend freely).
local knownCities = {
"Vaeringheim","Luminaria","Serena","Pyralis","Symphonara","Somniumpolis","Nexa",
"Lunalis Sancta","Sylvapolis","Acheron","Erythros","Catonis Atrium","Jogi","Tel-Amin",
"Lewisburg","Ardclach","Riddersborg","Slevik","Kaledonija","Skýrophos","Odiferia",
"Ourid","Bashkim","Tonar","Diamandis","Keybir-Aviv","Thermosalem","Saluria",
"Norsolyra","Rouge","Dragevik","Notranskja","Fanghorn","Eikbu","Sårensby","Aureum",
"Mylecia","Nysara Velai","Ferrum Citadel","Delphica","Bjornopolis","New Kingsland","Storesund","Rumi-Kefaya",
}
local function inferHQCity(companyName)
companyName = tostring(companyName or "")
if companyHQOverrides[companyName] ~= nil then
local v = companyHQOverrides[companyName]
if v == "" then return nil end
return v
end
for _, c in ipairs(knownCities) do
if companyName == c then return c end
end
for _, c in ipairs(knownCities) do
if companyName:find(c, 1, true) then return c end
end
-- Heuristics for common demonyms / aliases
if companyName:find("Aminian", 1, true) then return "Tel-Amin" end
return nil
end
local function productClass(productName)
    local n = (productName or ""):lower()
    -- Household and transport staples
    if n:find("rice")
        or n:find("wheat")
        or n:find("oats")
        or n:find("cereal")
        or n:find("hay")
        or n:find("bean")
        or n:find("tuber")
        or n:find("root store")
        or n:find("flour")
        or n:find("granary")
        or n:find("ration")
        or n:find("provision")
        or n:find("milk")
        or n:find("cheese")
        or n:find("butter")
        or n:find("meat")
        or n:find("mutton")
    then
        return "staple"
    end
    -- Agricultural and livestock inputs
    if n:find("fertilizer")
        or n:find("seed")
        or n:find("pellet")
        or n:find("inocul")
        or n:find("soil")
        or n:find("fodder")
        or n:find("feed")
        or n:find("bedding")
    then
        return "input"
    end
    -- Ritual and temple goods
    if n:find("ritual")
        or n:find("incense")
        or n:find("anoint")
        or n:find("sanctified")
        or n:find("temple")
    then
        return "ritual"
    end
    return "standard"
end
local function opsLevelToNumber(levelOrLabel)
local n = tonumber(levelOrLabel)
if n then return n end
local t = tostring(levelOrLabel or ""):lower()
if t:find("green") then return 0 end
if t:find("yellow") then return 1 end
if t:find("orange") then return 2 end
if t:find("red") then return 3 end
return 0
end
local function clamp(x, lo, hi)
if x < lo then return lo end
if x > hi then return hi end
return x
end
local function getForecastSignal(city, year, dayOfYear)
if not (forecastOk and forecast and type(forecast.getOpsData) == "function") then
return { mult = 0, note = nil, opsLevel = 0 }
end
local op = forecast.getOpsData(city, year, dayOfYear)
if not op or not op.alert or not op.impacts then
return { mult = 0, note = nil, opsLevel = 0 }
end
local m = 0
local ground = tostring(op.impacts.ground or "OK")
local sea    = tostring(op.impacts.sea or "OK")
local air    = tostring(op.impacts.air or "OK")
-- supply friction by mode
if ground == "Slow" then m = m + 0.02
elseif ground == "Hazard" then m = m + 0.05
elseif ground == "Closed" then m = m + 0.08 end
if sea == "Restricted" then m = m + 0.03
elseif sea == "Closed" then m = m + 0.06 end
if air == "Limited" then m = m + 0.01
elseif air == "No-Go" then m = m + 0.04 end
-- condition bump
local cond = tostring(op.condition or "")
local lc = cond:lower()
if lc:find("blizzard") then m = m + 0.05
elseif lc:find("storm") then m = m + 0.03
elseif lc:find("fog") then m = m + 0.02
elseif lc:find("rain") then m = m + 0.01 end
local opsLevel = opsLevelToNumber(op.alert.level)
local note = string.format("WX/Ops %s (%s; G:%s S:%s A:%s)", tostring(op.alert.label or ""), cond, ground, sea, air)
return { mult = m, note = note, opsLevel = opsLevel }
end
local function getWarLeagueSignalFromOps(opsLevel)
-- baseline posture from Ops Alert
local m = 0
if opsLevel == 1 then m = 0.01
elseif opsLevel == 2 then m = 0.03
elseif opsLevel >= 3 then m = 0.06 end
return { mult = m, note = (opsLevel > 0) and ("War posture +" .. string.format("%.0f%%", m*100)) or nil }
end
local function countCityInHatchReport(city, year, dayOfYear)
if not (hatchOk and hatch and type(hatch.dailyReport) == "function") then
return 0
end
local report = hatch.dailyReport({ args = { year = tostring(year), day = tostring(dayOfYear), legend = "no" } })
report = tostring(report or "")
local needle = "%[%[List_of_cities_in_Bassaridia_Vaeringheim#" .. escapePattern(city) .. "%|" .. escapePattern(city) .. "%]%]"
local c = 0
for _ in report:gmatch(needle) do c = c + 1 end
return c
end
local function getHatchSignal(city, year, dayOfYear)
local n = countCityInHatchReport(city, year, dayOfYear)
if n <= 0 then return { mult = 0, note = nil } end
local m = math.min(0.05, n * 0.005)
local note = string.format("Hatch activity %d (≈+%.1f%%)", n, m*100)
return { mult = m, note = note }
end
local function countCityInWarLeagueTable(city, seed)
if not (warOk and war and type(war.makeTable) == "function") then
return 0
end
local tbl = war.makeTable({ args = { rows = "36", seed = tostring(seed), showlegend = "no", flagsize = "0" } })
tbl = tostring(tbl or "")
local needle = "%[%[List_of_cities_in_Bassaridia_Vaeringheim#" .. escapePattern(city) .. "%|" .. escapePattern(city) .. "%]%]"
local c = 0
for _ in tbl:gmatch(needle) do c = c + 1 end
return c
end
local function getWarLeagueSignal(city, seed)
local n = countCityInWarLeagueTable(city, seed)
if n <= 0 then return { mult = 0, note = nil } end
-- mild friction per reported row involvement (cap)
local m = math.min(0.06, n * 0.002)
local note = string.format("War League activity %d (≈+%.1f%%)", n, m*100)
return { mult = m, note = note }
end
local function parseOutbreakSeverity(outText)
outText = tostring(outText or "")
local sev = outText:match('style="background:[^"]+"%s*|%s*([A-Z]+)%s*||')
if sev == "CRITICAL" or sev == "HIGH" or sev == "MEDIUM" or sev == "LOW" or sev == "NONE" then
return sev
end
return "NONE"
end
local function getHealthSignal(city)
if not (outbreakOk and outbreaks and type(outbreaks.outbreaksForCity) == "function") then
return { mult = 0, severity = "NONE", note = nil }
end
local txt = outbreaks.outbreaksForCity({ args = { city = city } })
local sev = parseOutbreakSeverity(txt)
local m = 0
if sev == "LOW" then m = 0.01
elseif sev == "MEDIUM" then m = 0.03
elseif sev == "HIGH" then m = 0.06
elseif sev == "CRITICAL" then m = 0.10 end
local note = (sev ~= "NONE") and ("Health " .. sev .. " (≈+" .. string.format("%.0f%%", m*100) .. ")") or nil
return { mult = m, severity = sev, note = note }
end
local function getTempleBankSignal(pClass, healthSeverity, opsLevel)
-- Temple Bank behavior: stabilize staples during health/ops stress; allow non-staples to rise.
local crisis = (healthSeverity == "MEDIUM" or healthSeverity == "HIGH" or healthSeverity == "CRITICAL" or (tonumber(opsLevel) or 0) >= 2)
if not crisis then return { mult = 0, note = nil } end
local m = 0
if pClass == "staple" then
if healthSeverity == "CRITICAL" then m = -0.06
elseif healthSeverity == "HIGH" then m = -0.04
else m = -0.02 end
if (tonumber(opsLevel) or 0) >= 3 then m = m - 0.01 end
return { mult = m, note = string.format("Temple Bank stabilization (%.0f%%)", m*100) }
else
if healthSeverity == "CRITICAL" then m = 0.04
elseif healthSeverity == "HIGH" then m = 0.03
else m = 0.015 end
if (tonumber(opsLevel) or 0) >= 3 then m = m + 0.01 end
return { mult = m, note = string.format("Temple Bank overhead (+%.0f%%)", m*100) }
end
end
-- 3. Special Date Events
-- 3. Special Date Events
---------------------------------------------------------
---------------------------------------------------------
local events = {
local events = {
    ["1,6"] = "Bayram al-Nur (Festival of Light) [Vaeringheim]",
["1,6"] = "Bayram al-Nur (Festival of Light) [Vaeringheim]",
    ["1,18"] = "Chag Or Hadash (Festival of New Light) [Luminaria]",
["1,18"] = "Chag Or Hadash (Festival of New Light) [Luminaria]",
    ["1,30"] = "Symposion Eirinis (Symposium of Harmony) [Serena]",
["1,30"] = "Symposion Eirinis (Symposium of Harmony) [Serena]",
    ["1,43"] = "Alev Günü (Day of Flame) [Pyralis]",
["1,43"] = "Alev Günü (Day of Flame) [Pyralis]",
    ["1,48"] = "Day of Abandonment [Vaeringheim]",
["1,48"] = "Day of Abandonment [Vaeringheim]",
    ["1,55"] = "Tikkun Tzel (Repair of Shadows) [Symphonara]",
["1,55"] = "Tikkun Tzel (Repair of Shadows) [Symphonara]",
    ["2,6"] = "Panegyris Chrysou (Golden Gathering) [Aurelia]",
["2,6"] = "Panegyris Chrysou (Golden Gathering) [Aurelia]",
    ["2,17"] = "Constitution Day [Luminaria]",
["2,17"] = "Constitution Day [Luminaria]",
    ["2,19"] = "Mehtap Dalgası (Moonlit Tide) [Vaeringheim]",
["2,19"] = "Mehtap Dalgası (Moonlit Tide) [Vaeringheim]",
    ["2,31"] = "Oneiro Foteino (Dream of Illumination) [Somniumpolis]",
["2,31"] = "Oneiro Foteino (Dream of Illumination) [Somniumpolis]",
    ["2,39"] = "Anniversary of victory in the New South Jangsong Campaign [Nexa]",
["2,39"] = "Anniversary of victory in the New South Jangsong Campaign [Nexa]",
    ["2,44"] = "Erev Galgal (Eve of Cycles) [Nexa]",
["2,44"] = "Erev Galgal (Eve of Cycles) [Nexa]",
    ["2,45"] = "Bassaridia Festival [Somniumpolis]",
["2,45"] = "Bassaridia Festival [Somniumpolis]",
    ["2,48"] = "Anniversary of victory in the Southern Lake Morovia Campaign [Somniumpolis]",
["2,48"] = "Anniversary of victory in the Southern Lake Morovia Campaign [Somniumpolis]",
    ["2,54"] = "Leilat al-Kamar (Night of the Moon) [Lunalis Sancta]",
["2,54"] = "Leilat al-Kamar (Night of the Moon) [Lunalis Sancta]",
    ["2,61"] = "Taşrakah (Reverence of the Stone) [Luminaria]",
["2,61"] = "Taşrakah (Reverence of the Stone) [Luminaria]",
    ["3,6"] = "Chag Tvuah (Festival of Harvest) [Sylvapolis]",
["3,6"] = "Chag Tvuah (Festival of Harvest) [Sylvapolis]",
    ["3,18"] = "Anagenesis Eirmos (Procession of Rebirth) [Acheron]",
["3,18"] = "Anagenesis Eirmos (Procession of Rebirth) [Acheron]",
    ["3,28"] = "Panagia Therizis (Holy Day of the Reaper) [Sylvapolis]",
["3,28"] = "Panagia Therizis (Holy Day of the Reaper) [Sylvapolis]",
    ["3,37"] = "Anniversary of victory in the Morovian Frontier Campaign [Acheron]",
["3,37"] = "Anniversary of victory in the Morovian Frontier Campaign [Acheron]",
    ["3,43"] = "Karnavali Thysias (Carnival of Celebration) [Erythros]",
["3,43"] = "Karnavali Thysias (Carnival of Celebration) [Erythros]",
    ["3,53"] = "Sefar Yashar (Straight Path Celebration) [Catonis Atrium]",
["3,53"] = "Sefar Yashar (Straight Path Celebration) [Catonis Atrium]",
 
 
}
}


Line 316: Line 1,020:
--    a special event occurs on that dateKey.
--    a special event occurs on that dateKey.
---------------------------------------------------------
---------------------------------------------------------
local function simulatePriceChange(basePrice, dayOfMonth, month)
local function simulatePriceChange(basePrice, dayOfMonth, month, psscYear, dayOfYear, city, productName, companyName, dailySeed)
    local dateKey = string.format("%d,%d", month, dayOfMonth)
local dateKey = string.format("%d,%d", month, dayOfMonth)
    local changeFactor = math.random(-20, 20) / 100
local changeFactor = math.random(-20, 20) / 100
    local explanation
local explanationParts = {}
 
if events[dateKey] then
changeFactor = changeFactor + 0.05 -- small boost for special events
table.insert(explanationParts, events[dateKey] .. ": Prices influenced by event dynamics")
else
table.insert(explanationParts, "General market fluctuations")
end
 
-- City-driven signals (weather, War League, Hatch, public health, Temple Bank)
local notes = {}
city = tostring(city or "")
local pClass = productClass(productName)
local cityAdd = 0
 
if city ~= "" then
local wx = getForecastSignal(city, psscYear, dayOfYear)
cityAdd = cityAdd + (wx.mult or 0)
if wx.note then table.insert(notes, wx.note) end
 
local wl0 = getWarLeagueSignalFromOps(wx.opsLevel or 0)
cityAdd = cityAdd + (wl0.mult or 0)
if wl0.note then table.insert(notes, wl0.note) end
 
-- War League operations table (deterministic, date-seeded)
local wl = getWarLeagueSignal(city, dailySeed)
cityAdd = cityAdd + (wl.mult or 0)
if wl.note then table.insert(notes, wl.note) end
 
local hm = getHatchSignal(city, psscYear, dayOfYear)
cityAdd = cityAdd + (hm.mult or 0)
if hm.note then table.insert(notes, hm.note) end
 
local ph = getHealthSignal(city)
cityAdd = cityAdd + (ph.mult or 0)
if ph.note then table.insert(notes, ph.note) end
 
local tb = getTempleBankSignal(pClass, ph.severity or "NONE", wx.opsLevel or 0)
cityAdd = cityAdd + (tb.mult or 0)
if tb.note then table.insert(notes, tb.note) end
end
 
cityAdd = clamp(cityAdd, -0.20, 0.20)
changeFactor = clamp(changeFactor + cityAdd, -0.35, 0.35)


    if events[dateKey] then
if #notes > 0 then
        explanation = events[dateKey] .. ": Prices influenced by event dynamics."
table.insert(explanationParts, "Local signals: " .. table.concat(notes, "; "))
        changeFactor = changeFactor + 0.05  -- small boost for special events
end
    else
        explanation = "General market fluctuations."
    end


    local newPrice = math.floor((basePrice * (1 + changeFactor)) * 100) / 100
local explanation = table.concat(explanationParts, ". ") .. "."
    return newPrice, changeFactor, explanation
local newPrice = math.floor((basePrice * (1 + changeFactor)) * 100) / 100
return newPrice, changeFactor, explanation
end
end


Line 340: Line 1,085:
---------------------------------------------------------
---------------------------------------------------------
local function determinePriceLevel(basePrice, adjustedPrice)
local function determinePriceLevel(basePrice, adjustedPrice)
    if adjustedPrice > basePrice then
if adjustedPrice > basePrice then
        return "Low"
return "Low"
    elseif adjustedPrice < basePrice then
elseif adjustedPrice < basePrice then
        return "High"
return "High"
    else
else
        return "Standard"
return "Standard"
    end
end
end
 
---------------------------------------------------------
-- Args helpers (for modes)
---------------------------------------------------------
local function getArgs(frame)
if type(frame) ~= "table" then
return {}
end
 
local args = {}
local fargs = frame.args or {}
 
local pargs = {}
if frame.getParent then
local parent = frame:getParent()
if parent and parent.args then
pargs = parent.args
end
end
 
for k, v in pairs(pargs) do
if v ~= nil and v ~= "" then
args[k] = v
end
end
for k, v in pairs(fargs) do
if v ~= nil and v ~= "" then
args[k] = v
end
end
 
return args
end
 
local function isNo(v)
v = tostring(v or ""):lower()
return (v == "no" or v == "n" or v == "false" or v == "0")
end
 
local function levelSymbol(priceLevel)
if priceLevel == "Low" then
return "↑"
elseif priceLevel == "High" then
return "↓"
else
return "•"
end
end
 
---------------------------------------------------------
-- 5.5 Consumer price helpers
--    Converts the Port agricultural ledger into ordinary
--    household market prices. The ledger values are units
--    redeemable per poli, so consumer prices move inversely:
--    higher adjusted quantity per poli = lower retail price.
---------------------------------------------------------
local productLookup = nil
 
local function getProductByName(name)
if productLookup == nil then
productLookup = {}
for _, product in ipairs(products) do
productLookup[product[1]] = product
end
end
return productLookup[name]
end
 
local function formatConsumerPriceFromNil(totalNil)
totalNil = math.floor((tonumber(totalNil) or 0) + 0.5)
if totalNil < 1 then totalNil = 1 end
 
local poli = math.floor(totalNil / 200)
local rem = totalNil % 200
local sik = math.floor(rem / 10)
local nilCoins = rem % 10
 
local parts = {}
if poli > 0 then table.insert(parts, tostring(poli) .. "₱̈") end
if sik > 0 then table.insert(parts, tostring(sik) .. "Ƨ̈") end
if nilCoins > 0 then table.insert(parts, tostring(nilCoins) .. "•") end
if #parts == 0 then return "1•" end
return table.concat(parts, " ")
end
 
local function consumerRow(productName, consumerUse, retailUnit, baseNil, note)
return {
productName = productName,
consumerUse = consumerUse,
retailUnit = retailUnit,
baseNil = baseNil,
note = note or ""
}
end
 
local consumerCatalog = {
-- Core staples and grain goods
consumerRow("Rice", "Daily grain staple", "1 kg sack", 25, "Core voucher staple and one of the most common household goods."),
consumerRow("Wisp Rice", "Specialty rice, porridge, festival meals", "1 kg sack", 40, "Northern specialty rice."),
consumerRow("Wisp Rice Flour (milled)", "Baking, noodles, porridge", "1 kg sack", 35, "Processed form of Wisp Rice."),
consumerRow("Wisp Rice Noodles (dried)", "Quick meals and soups", "500 g packet", 30, "Shelf-stable noodle packet."),
consumerRow("Wisp Rice Cakes (pressed)", "Snack and travel food", "small box", 25, "Prepared rice snack."),
consumerRow("Wisp Rice Porridge Mix (packaged)", "Breakfast food", "500 g packet", 20, "Common morning food."),
consumerRow("Wheat", "Bread, flour, flatbread", "1 kg sack", 20, "Jogi grain staple."),
consumerRow("Oats", "Porridge and breakfast", "1 kg sack", 18, "Cheap everyday grain."),
consumerRow("Cereal", "Breakfast meal and ration cakes", "1 kg packet", 22, "Basic household grain blend."),
consumerRow("Granary Flour (stone-milled)", "Household baking", "1 kg sack", 25, "Retail flour from Salain's Landing."),
consumerRow("Barley Flour (milled)", "Baking, thickening, porridge", "1 kg sack", 20, "Common baking and soup good."),
consumerRow("Granary Biscuit Rations", "Travel food, worker lunch", "1 box", 30, "Durable ration box."),
consumerRow("Cold-Steppe Barley", "Soup, porridge, brewing", "1 kg sack", 20, "Ouriana staple grain."),
consumerRow("Proso Millet", "Porridge, flatbread", "1 kg sack", 18, "Cheap small grain."),
consumerRow("Buckwheat", "Pancakes, porridge, noodles", "1 kg sack", 25, "Cold-region household grain."),
consumerRow("Cold-Hardy Lentils", "Stews and protein supplement", "1 kg sack", 25, "High-value pulse crop."),
consumerRow("Beans", "Stews and household meals", "1 kg sack", 25, "Common household protein."),
consumerRow("maize", "Meal, porridge, cakes", "1 kg sack", 20, "Granadita household staple."),
 
-- Vegetables, herbs, and cooking plants
consumerRow("Edible Algae", "Soups, patties, preserved food", "500 g bundle", 12, "Morovian canal and wetland staple."),
consumerRow("Anterran Spicy Onion", "Cooking base", "500 g bundle", 15, "Flavor base for everyday cooking."),
consumerRow("Queen's Garlic", "Cooking, medicine, sauces", "250 g braid", 15, "Household kitchen and medicinal good."),
consumerRow("Potatoes", "Staple vegetable", "2 kg sack", 25, "Basic Caledonian vegetable staple."),
consumerRow("White Beets", "Soups and pickles", "1 kg basket", 20, "Useful in soups and preserved foods."),
consumerRow("Onions", "Cooking base", "1 kg sack", 15, "Basic cooking vegetable."),
consumerRow("Cabbage", "Soup, pickles, stews", "1 head", 12, "Cheap fresh vegetable."),
consumerRow("Garlic Bulbs", "Cooking and household medicine", "1 bundle", 15, "Common household purchase."),
consumerRow("Dill", "Pickles, soups, fish dishes", "small bundle", 8, "Daily herb."),
consumerRow("Parsley", "Garnish and cooking herb", "small bundle", 8, "Daily herb."),
consumerRow("Wild Juniper Berries", "Seasoning and preserves", "small packet", 15, "Specialty seasoning."),
consumerRow("Thyme Bush Cuttings", "Cooking herb", "small bundle", 8, "Daily herb."),
consumerRow("Lettuce", "Fresh salad and wraps", "1 head", 12, "Fresh vegetable."),
consumerRow("Assorted Vegetables", "General household cooking", "1 kg basket", 25, "Mixed market vegetables."),
consumerRow("Mountain Sorrel", "Soups and sour greens", "small bundle", 10, "Fresh sour green."),
consumerRow("Steppe Rhubarb", "Stewed sweets and preserves", "500 g bundle", 20, "Seasonal tart vegetable."),
 
-- Meat, seafood, and preserved proteins
consumerRow("Shrimp", "Rice dishes and stews", "500 g basket", 35, "Frequent fresh protein."),
consumerRow("Atterian Armored Pufferfish", "Specialty fish", "500 g dressed portion", 65, "Usually prepared by approved sellers."),
consumerRow("Morovian Saucer Eyed Giant Eel", "Patties, smoked eel, festival meals", "500 g portion", 50, "Named eel product from the ledger."),
consumerRow("Amina Crab", "Stews and market meals", "500 g portion", 60, "Fresh crab portion."),
consumerRow("Fresh Tuna", "Fresh fish", "500 g portion", 50, "Fresh imported fish."),
consumerRow("Canned Tuna", "Shelf-stable household protein", "1 tin", 20, "Everyday preserved fish."),
consumerRow("Fish", "Everyday fish meals", "500 g portion", 30, "General fish category."),
consumerRow("Highland Grayling", "Fresh fish", "500 g portion", 40, "Ourid river fish."),
consumerRow("Mountain Whitefish", "Fresh fish", "500 g portion", 35, "Ourid river fish."),
consumerRow("Brown Trout", "Fresh fish, smoked fish", "500 g portion", 45, "Higher-value river fish."),
consumerRow("Salted Lamprey Filets", "Preserved fish", "250 g packet", 30, "Shelf-stable fish."),
consumerRow("Smoked Burbot", "Preserved fish", "250 g packet", 30, "Smoked fish packet."),
consumerRow("Morovian Water Buffalo Beef", "Household meat, special meals", "500 g cut", 85, "Common upgrade beyond baseline ration goods."),
consumerRow("Camel Meat", "Stews and dried strips", "500 g portion", 60, "Jangsong-linked protein."),
consumerRow("Sea Cow Beef", "Stews and preserved meat", "500 g cut", 75, "Somniumpolis-linked ranching product."),
consumerRow("Sea Cow Jerky (salted strips)", "Travel food and snacks", "250 g packet", 40, "Preserved meat."),
consumerRow("Sea Cow Sausage (smoked)", "Smoked household protein", "500 g link", 70, "Smoked sausage."),
consumerRow("Giid-Lisea-Eda Beef", "Imported red meat", "500 g cut", 90, "Higher-status imported meat."),
consumerRow("Frozen Mammoth Steaks", "Luxury meat", "250 g portion", 80, "Luxury frozen cut."),
consumerRow("Giid-Lisea Jerky (salted)", "Travel food", "250 g slab", 50, "Imported preserved meat."),
consumerRow("Vaeringheim Turkey Meat", "Poultry meals", "500 g portion", 60, "Common poultry meat."),
consumerRow("Salurian Swamp Quail Eggs", "Breakfast, baking, pickles", "12 eggs", 30, "Small premium eggs."),
consumerRow("Smoked Turkey Strips (trail packs)", "Trail food and snacks", "250 g packet", 40, "Preserved poultry."),
consumerRow("Reindeer Meat", "Northern meat, stews", "500 g portion", 60, "Northern meat product."),
consumerRow("Smoked Venison (Cold-Steppe Cure)", "Preserved meat", "250 g packet", 45, "Cold-steppe preserved meat."),
consumerRow("Seal Meat", "Northern preserved protein", "500 g portion", 50, "Northern protein."),
consumerRow("Whale Meat", "Preserved northern protein", "500 g portion", 70, "High-value northern protein."),
consumerRow("Caledonj Deep-Bay Lobster", "Special seafood meal", "500 g portion", 100, "Luxury seafood."),
consumerRow("Pickled Lobster Claws (Spiced)", "Preserved seafood", "1 jar", 60, "Specialty jarred seafood."),
consumerRow("Lobster Broth Concentrate", "Soup base", "1 bottle", 50, "Prepared soup base."),
consumerRow("Velvet Worm Meat", "Specialty protein", "250 g portion", 40, "Rouge specialty protein."),
consumerRow("Smoked Velvet Worm Strips", "Snack, breakfast hash", "250 g slab", 50, "Prepared specialty protein."),
consumerRow("Velvet Worm Broth Concentrate", "Soup base", "1 jar", 40, "Prepared broth concentrate."),
consumerRow("Live Maenic Snails (market-grade)", "Fresh cooking, market meals, festival dishes", "1 live snail", 45, "Large native snail raised in the reed farms of Saruq Thyrsa."),
consumerRow("Maenic Snail Meat (dressed)", "Stews, grilling, roasting, and market meals", "500 g dressed portion", 55, "Fresh dressed meat from farmed Maenic Snails."),
consumerRow("Reed-Smoked Maenic Snail Meat", "Preserved protein, snacks, and travel food", "250 g packet", 45, "Maenic Snail meat traditionally smoked over dried Thyrsan reeds."),
consumerRow("Thyrsan Brined Maenic Snail Meat", "Preserved food, mezze, stews, and market meals", "1 jar", 40, "Brined Maenic Snail meat prepared for household and ferry-market sale."),
consumerRow("Salt-Cured Maenic Snail Eggs", "Delicacy, festival food, and garnish", "small jar", 75, "Salt-cured eggs from farmed Maenic Snails; a high-value Saruq delicacy."),
consumerRow("Maenic Snail Broth Concentrate", "Soups, sauces, stews, and cooking stock", "1 jar", 35, "Concentrated broth produced from Maenic Snail processing."),
 
-- Milk, cheese, butter, fats, and oils
consumerRow("Morovian Water Buffalo Milk (raw)", "Drinking and cooking", "1 liter", 15, "Everyday dairy."),
consumerRow("Morovian Water Buffalo Milk (cultured)", "Breakfast, sauces, cooking", "500 ml jar", 18, "Cultured dairy."),
consumerRow("Morovian Water Buffalo Cheese (aged wheels)", "Bread, meals, snacks", "250 g wedge", 30, "Aged cheese wedge."),
consumerRow("Morovian Water Buffalo Butter (salted)", "Cooking and bread", "250 g block", 25, "Salted butter."),
consumerRow("Camel Milk", "Drinking and cultured dairy", "1 liter", 25, "Specialized dairy."),
consumerRow("Sea Cow Milk (raw)", "Drinking and cooking", "1 liter", 20, "Raw dairy."),
consumerRow("Sea Cow Cheese (aged wheels)", "Meals and snacks", "250 g wedge", 35, "Aged cheese."),
consumerRow("Sea Cow Butter (salted)", "Cooking", "250 g block", 25, "Salted butter."),
consumerRow("Sea Cow Oil (lamp/cooking grade)", "Lamp and cooking oil", "500 ml bottle", 30, "Dual household oil."),
consumerRow("Cream Butter", "Cooking and bread", "250 g block", 30, "Imported cream butter."),
consumerRow("Aged Cheese", "Table cheese", "250 g wedge", 40, "Imported aged cheese."),
consumerRow("Rendered Poultry Fat (cooking)", "Cooking fat", "250 g jar", 20, "Rendered fat."),
consumerRow("Pressed Sunflower Oil", "Cooking oil", "500 ml bottle", 30, "Household cooking oil."),
consumerRow("Assorted Oils", "Cooking oil", "500 ml bottle", 30, "Mixed cooking oil."),
consumerRow("Hemp Oil", "Cooking, lamp, salve base", "250 ml bottle", 35, "Specialty oil."),
consumerRow("Whale Oil", "Lamp oil", "500 ml flask", 25, "Northern lamp oil."),
consumerRow("Seal Oil", "Lamp oil and northern cooking use", "500 ml flask", 20, "Northern oil."),
 
-- Fruit, sugar, honey, sweets, and preserves
consumerRow("Tropical Fruit", "Fresh fruit", "1 kg basket", 40, "Southern fruit basket."),
consumerRow("Melusinian Orchard Apples (fresh)", "Fresh fruit", "1 kg basket", 30, "Fresh Tel-Amin apples."),
consumerRow("Coral-Grove Dried Apple Rings", "Snack and travel food", "250 g packet", 25, "Dried fruit snack."),
consumerRow("Spiced Apple Preserves", "Breakfast and sweets", "1 jar", 30, "Preserved apple jar."),
consumerRow("Tel-Amin Apple Butter", "Bread spread", "1 jar", 30, "Apple spread."),
consumerRow("Cave Honey (strained)", "Sweetener and medicine", "250 g jar", 35, "Household honey."),
consumerRow("Coffee Blossom Honey (grove-hive harvest)", "Sweetener and specialty honey", "250 g jar", 40, "Specialty honey."),
consumerRow("Apolline Apple Blossom Honey", "Sweetener and offering", "250 g jar", 40, "Orchard honey."),
consumerRow("Raw Cane Sugar", "Sweetener", "500 g packet", 20, "Basic sweetener."),
consumerRow("Refined White Sugar", "Sweetener and baking", "500 g packet", 25, "Refined sugar."),
consumerRow("Brown Sugar", "Baking and sauces", "500 g packet", 20, "Basic baking sugar."),
consumerRow("Molasses", "Baking and sweetener", "250 ml jar", 20, "Dark sweetener."),
consumerRow("Rock Sugar Crystals", "Tea and sweets", "250 g packet", 25, "Tea sugar."),
consumerRow("Sugar Loaves", "Household sweetener", "1 small loaf", 30, "Block sugar."),
consumerRow("Candied Citrus Peel", "Baking and sweets", "250 g packet", 30, "Sweet baking good."),
consumerRow("Sweet Tea Cakes", "Snack and hospitality", "1 box", 30, "Prepared sweet."),
consumerRow("Poppy Honey Cakes (market tins)", "Sweet market food", "1 tin", 40, "Prepared poppy sweet."),
consumerRow("Honey Cakes (sealed tins)", "Snack and festival food", "1 box", 30, "Prepared honey sweet."),
consumerRow("Sea Elm Honey Cakes (packaged)", "Snack and gift food", "1 box", 35, "Prepared meadery sweet."),
consumerRow("Noctic Flower Lokum (sweet export)", "Sweet, gift, festival treat", "1 small box", 60, "Discretionary comfort item."),
consumerRow("Horehound Candies (wrapped)", "Sweet and medicinal candy", "1 box", 30, "Medicinal sweet."),
 
-- Beverages and drink goods
consumerRow("Coffee", "Daily drink", "250 g packet", 40, "Basic coffee."),
consumerRow("Tel-Amin Medium Roast (whole bean)", "Household coffee", "250 g packet", 50, "Roasted coffee."),
consumerRow("Tel-Amin Dark Roast (whole bean)", "Household coffee", "250 g packet", 55, "Dark roast coffee."),
consumerRow("Stone-Ground Coffee (fine powder)", "Fine coffee powder", "250 g packet", 50, "Ground coffee."),
consumerRow("Cold-Brew Coffee Concentrate (bottled)", "Bottled coffee drink base", "1 bottle", 40, "Prepared coffee base."),
consumerRow("Sweetened Coffee Syrup (for desserts/drinks)", "Dessert and drink syrup", "1 bottle", 40, "Coffee syrup."),
consumerRow("Cascara Tea (coffee-cherry husk infusion)", "Tea infusion", "100 g packet", 30, "Coffee-cherry tea."),
consumerRow("Horehound Tea (dried leaves)", "Tea and household medicine", "1 pack", 20, "Medicinal tea."),
consumerRow("Horehound Syrup (cough blend)", "Cough blend and sweet drink base", "1 bottle", 40, "Medicinal syrup."),
consumerRow("Camel Hump Water Tea", "Tea and refreshment", "1 bottle", 25, "Jangsong refreshment."),
consumerRow("Apolline Apple Cider (sweet)", "Household drink", "1 bottle", 30, "Sweet cider."),
consumerRow("Mead", "Adult drink", "1 bottle", 40, "Common mead."),
consumerRow("Sea Elm Flavored Mead", "Adult drink and festival drink", "1 bottle", 45, "Sea-Elm mead."),
consumerRow("Manwine", "Adult drink and cooking", "1 bottle", 50, "Jogiani specialty drink."),
consumerRow("Ale of the Night", "Adult drink", "1 tankard or bottle", 25, "Common ale."),
consumerRow("Horehound Beer", "Adult drink", "1 bottle", 30, "Horehound beer."),
consumerRow("Blood InfusedRed Wine", "Adult drink, ritual hospitality", "1 bottle", 60, "Northern vineyard wine."),
consumerRow("Wine Vinegar (barrel aged)", "Cooking vinegar", "500 ml bottle", 20, "Wine vinegar."),
consumerRow("Manwine Vinegar (culinary)", "Cooking vinegar", "500 ml bottle", 20, "Manwine vinegar."),
consumerRow("Apple Vinegar of the Fossil Fields", "Cooking and pickling", "500 ml bottle", 20, "Apple vinegar."),
consumerRow("Wisp Rice Vinegar (fermented)", "Cooking vinegar", "500 ml bottle", 25, "Rice vinegar."),
 
-- Spices, botanicals, medicine, and ritual goods
consumerRow("Noctic-Rabrev Culinary Spice Blend", "Cooking and festival food", "small tin", 45, "Noctic culinary good."),
consumerRow("Dried Noctic-Rabrev Petals", "Tea, ritual, flavoring", "small packet", 50, "Ritual botanical."),
consumerRow("Noctic Tincture (therapeutic dosage)", "Therapeutic dosage", "1 vial", 50, "Therapeutic product."),
consumerRow("Noctic-Rabrev Infused Incense", "Household shrine and temple use", "1 pack", 30, "Ritual incense."),
consumerRow("Noctic-Rabrev Anointing Balm", "Ritual and medicinal balm", "1 jar", 40, "Ritual balm."),
consumerRow("Noctic-Rabrev Ritual Ink", "Written prayers, charms, records", "1 bottle", 50, "Ritual writing good."),
consumerRow("Ground Mugwort", "Tea, medicine, ritual", "small packet", 20, "Medicinal herb."),
consumerRow("Mugwort Oil", "Salve, lamp, ritual use", "small flask", 40, "Mugwort oil."),
consumerRow("Mugwort Tincture", "Apothecary use", "1 vial", 40, "Medicinal tincture."),
consumerRow("Poppy Seeds (culinary)", "Baking and garnish", "250 g packet", 20, "Culinary poppy."),
consumerRow("Poppy Seed Oil (pressed)", "Cooking oil", "250 ml bottle", 30, "Pressed oil."),
consumerRow("Poppy Petal Tea (non-potent herbal)", "Non-potent herbal tea", "1 pack", 20, "Household tea."),
consumerRow("Poppy Incense Cones (temple blend)", "Temple and household shrine", "1 pack", 30, "Ritual incense."),
consumerRow("Poppy Wreath Garlands (festival)", "Festival decoration", "1 bundle", 30, "Festival good."),
consumerRow("Horehound Tincture (apothecary)", "Apothecary use", "1 vial", 40, "Medicinal tincture."),
consumerRow("Horehound Incense (ritual sticks)", "Ritual sticks", "1 bundle", 20, "Ritual incense."),
consumerRow("Horehound Salve (chest rub)", "Chest rub and household medicine", "1 jar", 40, "Household medicine."),
consumerRow("Horehound Herb Bundles (fresh)", "Fresh herb, tea, ritual", "1 bundle", 15, "Fresh herb bundle."),
consumerRow("Velvet Antler Soap", "Bathing and medicinal grooming", "1 bar", 40, "Specialty soap."),
consumerRow("Velvet Antler Salve", "Balm and apothecary use", "1 jar", 50, "Specialty salve."),
consumerRow("Luxury Antler Infused Tea", "Specialty tea", "1 canister", 60, "Luxury tea."),
consumerRow("Trapper’s Tallow Soap (Pine & Resin Blend)", "Bathing and washing", "1 bar", 25, "Frontier soap."),
consumerRow("Agrithor Orys Flour", "Flatbread, porridge, thickening", "1 kg sack", 30, "Food-grade Orys flour from Aureum."),
consumerRow("Agrithor Orys Porridge Meal", "Breakfast porridge and household meals", "500 g packet", 22, "Everyday food product from Agrithor Orys grain."),
consumerRow("Pressed Agrithor Orys Cooking Oil", "Cooking oil", "500 ml bottle", 35, "Common cooking oil; valuable substitute for more distant imported oils."),
consumerRow("Golden Orys Salad Oil", "Finishing oil and cold dishes", "250 ml bottle", 40, "Higher-grade table oil."),
consumerRow("Agrithor Orys Essential Oil", "Fragrance, household shrine, oil blending", "small vial", 55, "Concentrated Orys oil for non-medical household and ritual use."),
consumerRow("Orys Anointing Oil Base", "Ritual oil base", "small flask", 60, "Used by oil-blenders as a local substitute base for costly traditional Stripping Path oils."),
consumerRow("Orys Diffuser Oil", "Household fragrance and shrine diffusion", "small vial", 45, "Nightly diffusion and festival fragrance oil."),
consumerRow("Orys Festival Oil Blend", "Festival lamps, ritual scent, domestic worship", "small flask", 65, "Prepared festival oil blend."),
consumerRow("Orys Waxed Candle Base", "Candle-making and household shrine use", "small block", 35, "Useful for candles and oil-lamp preparation."),
consumerRow("Pine-Scented Orys Candles", "Household light and shrine scent", "1 bundle", 35, "Everyday alternative to pine-scented oil sacraments."),
consumerRow("Cinnamon-Scented Orys Candles", "Household light and shrine scent", "1 bundle", 38, "Everyday alternative to cinnamon-scented oil sacraments."),
 
-- Household materials, clothing, repair, and domestic craft goods
consumerRow("Beeswax Candles (standard)", "Light and shrine use", "1 bundle", 30, "Household candles."),
consumerRow("Sea Elm Beeswax Candles (meadery grade)", "Light and ritual use", "1 bundle", 35, "Meadery-grade candles."),
consumerRow("Mammoth Fat Candles", "Heavy household candles", "1 candle", 25, "Heavy candle."),
consumerRow("Penguin Fat Candles (cold-weather)", "Cold-weather candles", "1 bundle", 50, "Northern candle bundle."),
consumerRow("Velvet Worm Silk Thread (spools)", "Sewing and repair", "1 spool", 30, "Specialty thread."),
consumerRow("Raw Silk Thread (spools)", "Sewing and embroidery", "1 spool", 40, "Silk thread."),
consumerRow("Woven Silk Sashes", "Dress, festival wear", "1 sash", 80, "Silk clothing good."),
consumerRow("Embroidered Veils (festival)", "Festival clothing", "1 veil", 120, "Festival garment."),
consumerRow("Silk Patch Kits (repair)", "Clothing repair", "1 kit", 30, "Repair kit."),
consumerRow("Cotton", "Cloth, household textile", "small bolt", 100, "Textile good."),
consumerRow("Wool", "Clothing and blankets", "small bundle", 80, "Textile good."),
consumerRow("Woolhorse Spun Yarn (dk/worsted, 50 kg)", "Knitting, repair, winter clothes", "small skein", 40, "Winter textile good."),
consumerRow("Woolhorse Felt Bolts (10 m x 1.4 m)", "Boots, cloaks, padding", "small folded piece", 80, "Felt good."),
consumerRow("Feather Quilting Fill (cleaned)", "Bedding repair", "small sack", 60, "Bedding good."),
consumerRow("Mother-of-Pearl Buttons (sorted)", "Clothing repair and ornament", "small packet", 30, "Clothing ornament."),
consumerRow("Pearl Thread Strands (drilled)", "Jewelry and festival dress", "1 strand", 80, "Adornment good."),
consumerRow("Abalone Shell Inlay Blanks", "Craft and ornament", "small packet", 50, "Craft good."),
consumerRow("Applewood Smoking Chips", "Cooking smoke and preservation", "1 sack", 20, "Kitchen fuel/flavoring."),
consumerRow("Zoe Elm Wood Oil (polish & sealant)", "Polish and sealant", "1 bottle", 40, "Domestic maintenance good."),
consumerRow("Zoe Elm Incense Resin (temple blend)", "Temple and household incense", "1 pack", 30, "Incense resin."),
 
-- Adult discretionary goods
consumerRow("Nocticine Silk-Wrap Cigarettes (20-count)", "Adult discretionary use", "20-count pack", 70, "Adult nocticine good."),
consumerRow("Caravan Reserve Noctic Cigars (hand-rolled)", "Adult discretionary use", "1 stick", 30, "Adult nocticine good."),
consumerRow("Pocket-Press Noctic Chew Pouches (minted)", "Adult discretionary use", "1 tin", 50, "Adult nocticine good."),
consumerRow("Hand-Cured Nefel Leaf Cigarettes (20-count)", "Adult discretionary use", "20-count pack", 65, "Adult tobacco good."),
consumerRow("Village Reserve Tobacco Cigars (oak-aged)", "Adult discretionary use", "1 stick", 40, "Adult tobacco good."),
consumerRow("Sun-Dried Pipe Tobacco (long-cut)", "Adult discretionary use", "1 pouch", 50, "Adult tobacco good."),
consumerRow("Herbal-Blend Hookah Tobacco", "Adult discretionary use", "1 jar", 60, "Adult tobacco good."),
 
-- Additional common spices and everyday cooking ingredients
consumerRow("Cinammon", "Common cooking spice", "50 g packet", 20, "Everyday spice."),
consumerRow("Cinammon Sticks (bundled)", "Tea, stews, baking, and mulled drinks", "small bundle", 25, "Common household spice."),
consumerRow("Ground Cinammon (milled)", "Baking, porridge, sweets, and drinks", "50 g tin", 25, "Common household spice."),
consumerRow("Cinammon Bark Chips (brew grade)", "Tea, brewing, stews, and warm drinks", "100 g packet", 22, "Common brewing and cooking spice."),
consumerRow("Cinammon Sugar Blend", "Baking and breakfast seasoning", "250 g packet", 25, "Common sweet spice blend."),
consumerRow("Cinammon Tea Mix (spice cut)", "Tea and warm drinks", "1 pack", 25, "Common household drink spice."),
consumerRow("Cinammon Pastry Fill (sealed)", "Baking filling", "1 jar", 35, "Prepared baking ingredient."),
consumerRow("Cistern-Grown Melon Crates", "Fresh melon, household meals, market snacks", "small melon crate", 32, "Water-accounted cistern melons from Mirovia."),
consumerRow("Desert Cucumber Baskets", "Fresh cucumbers, salads, pickling", "small basket", 24, "Dryland cucumbers grown for caravan and household markets."),
consumerRow("Preserved Desert Fruit", "Travel food, sweets, pantry storage", "small packet", 34, "Preserved desert fruit suited for dry-route storage."),
consumerRow("Sun-Dried Melon Strips", "Trail food, sweets, caravan snacks", "small packet", 28, "Dried melon strips from cistern-grown Mirovian fruit."),
consumerRow("Pressed Desert Seed Oil", "Cooking oil and caravan food preparation", "250 ml bottle", 38, "Household seed oil pressed from desert-grown produce."),
consumerRow("Packed Caravan Rations", "Travel meals, workday food, emergency stores", "ration box", 55, "Compact provisioning box prepared for dry routes and household reserve use."),
consumerRow("Dry-Route Produce Hampers", "Household produce, travel provisions", "small hamper", 46, "Mixed dry-route produce from the Pontic Esperance Homestead Association."),
consumerRow("Caravan Cucumber Pickles", "Pickles, travel food, meal accompaniment", "small jar", 26, "Shelf-stable cucumber pickles suited for caravan and household tables."),
consumerRow("Desert Fruit Preserves", "Jam, sweets, pantry storage", "small jar", 30, "Sweet preserved fruit from Mirovia's cistern farms."),
 
 
}
 
---------------------------------------------------------
-- Public invocation:
--  {{#invoke:AutoUpdateAgPrices|consumerPrices}}
--  {{#invoke:AutoUpdateAgPrices|consumerPrices|category=no}}
--  {{#invoke:AutoUpdateAgPrices|consumerPrices|limit=50}}
---------------------------------------------------------
function p.consumerPrices(frame)
local args = getArgs(frame)
local showCategory = not isNo(args.category)
local limit = tonumber(args.limit or "")
 
local localTime = os.date("*t")
local dailySeed = localTime.year * 1000 + localTime.yday
math.randomseed(dailySeed)
 
local dateString, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()
local out =
"{| class=\"wikitable sortable\"\n" ..
"|+ Consumer agricultural price list for " .. dateString .. "\n" ..
"! Date !! Δ !! Product !! Supplier / Port company !! Consumer use !! Retail unit !! Consumer price !! Notes\n"
 
local totalBaseNil, totalTodayNil, count = 0, 0, 0
 
for _, item in ipairs(consumerCatalog) do
if not limit or count < limit then
local product = getProductByName(item.productName)
if product then
local name = product[1]
local company = product[2]
local basePrice = product[3]
local city = inferHQCity(company) or ""
local adjustedQty = select(1, simulatePriceChange(
basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company, dailySeed
))
 
local consumerNil = item.baseNil
if adjustedQty and adjustedQty > 0 then
consumerNil = item.baseNil * (basePrice / adjustedQty)
end
 
local priceLevel = determinePriceLevel(item.baseNil, consumerNil)
local sym
local rowStyle
if consumerNil < item.baseNil then
sym = "↓"
rowStyle = ' style="background-color:lightblue;"'
elseif consumerNil > item.baseNil then
sym = "↑"
rowStyle = ' style="background-color:#ffcccb;"'
else
sym = "•"
rowStyle = ' style="background-color:lightgreen;"'
end
 
totalBaseNil = totalBaseNil + item.baseNil
totalTodayNil = totalTodayNil + consumerNil
count = count + 1
 
out = out .. string.format(
"|-%s\n| %s || %s || %s || %s || %s || %s || %s || %s\n",
rowStyle,
dateString,
sym,
name,
company,
item.consumerUse,
item.retailUnit,
formatConsumerPriceFromNil(consumerNil),
item.note
)
end
end
end
 
local avgBase = totalBaseNil / math.max(count, 1)
local avgToday = totalTodayNil / math.max(count, 1)
local avgLabel = "Standard"
local avgSym = "•"
if avgToday < avgBase then
avgLabel = "Lower consumer prices"
avgSym = "↓"
elseif avgToday > avgBase then
avgLabel = "Higher consumer prices"
avgSym = "↑"
end
 
out = out .. string.format(
"|-\n! colspan=\"8\" | Consumer average: %s %s; baseline %s, current %s across %d listed goods\n|}\n",
avgSym,
avgLabel,
formatConsumerPriceFromNil(avgBase),
formatConsumerPriceFromNil(avgToday),
count
)
 
return out
end
end


---------------------------------------------------------
---------------------------------------------------------
-- 6. MAIN Table Generation
-- 6. MAIN Table Generation (Condensed + Optional Full Breakdown)
---------------------------------------------------------
---------------------------------------------------------
function p.generateTable()
function p.generateTable(frame)
    -------------------------------------------------------
local args = getArgs(frame)
    -- Step A: create a daily seed for randomness
local mode = tostring(args.mode or "both"):lower()  -- both | summary | breakdown
    -- Uses year + yday to ensure each day is unique
local collapse = not isNo(args.collapse)            -- default true (collapsed)
    -------------------------------------------------------
 
    local localTime = os.date("*t")
local showSummary = (mode == "both" or mode == "summary")
    local dailySeed = localTime.year * 1000 + localTime.yday
local showBreakdown = (mode == "both" or mode == "breakdown")
    math.randomseed(dailySeed)
 
-- Step A: daily seed for randomness (unique per day)
local localTime = os.date("*t")
local dailySeed = localTime.year * 1000 + localTime.yday
math.randomseed(dailySeed)
 
-- Step B: date info
local dateString, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()
-- Step C: build outputs
local out = ""
 
local summary = ""
if showSummary then
summary =
"{| class=\"wikitable sortable\"\n" ..
"! Date (Day/Month/Year [[PSSC]]) !! Δ !! Product !! Producing Company !! Tier I Price !! Units !! Notes\n"
end
 
local breakdown = ""
if showBreakdown then
local collapseClass = collapse and " mw-collapsible mw-collapsed" or ""
breakdown =
"{| class=\"wikitable sortable" .. collapseClass .. "\"\n" ..
"|+ Full tier breakdown" .. (collapse and " (click to expand)" or "") .. "\n" ..
"! Date (Day/Month/Year [[PSSC]]) !! Product !! Producing Company !! Base Price !! Price Level !! Tier III Price !! Tier II Price !! Tier I Price !! Units !! Explanation\n"
end
 
-- track averages
local totalBase, totalNew, count = 0, 0, 0
 
-- Step D: rows
for _, product in ipairs(products) do
local name = product[1]
local company = product[2]
local basePrice = product[3]
local unit = product[4]
 
local city = inferHQCity(company) or ""
local newPrice, changeFactor, explanation = simulatePriceChange(basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company, dailySeed)
local priceLevel = determinePriceLevel(basePrice, newPrice)
local sym = levelSymbol(priceLevel)
 
local rowStyle
if priceLevel == "Low" then
rowStyle = ' style="background-color:lightblue;"'
elseif priceLevel == "Standard" then
rowStyle = ' style="background-color:lightgreen;"'
else
rowStyle = ' style="background-color:#ffcccb;"'
end
 
local tierIIIPrice = math.floor((newPrice / 3) * 100) / 100
local tierIIPrice  = math.floor((newPrice * 2 / 3) * 100) / 100
local tierIPrice  = newPrice
 
totalBase = totalBase + basePrice
totalNew  = totalNew + newPrice
count = count + 1


    -- Step B: gather date info
if showSummary then
    local dateString, dayOfMonth, month = getCurrentDate()
summary = summary .. string.format(
"|-%s\n| %s || %s || %s || %s || %.2f || %s || %s\n",
rowStyle, dateString, sym, name, company, tierIPrice, unit, explanation
)
end


    -- Step C: build table header
if showBreakdown then
    local wikitable =
breakdown = breakdown .. string.format(
        "{| class=\"wikitable\"\n" ..
"|-%s\n| %s || %s || %s || %.2f || %s || %.2f || %.2f || %.2f || %s || %s\n",
        "! Date (Day/Month/Year [[PSSC]]) !! Product !! Producing Company !! Base Price !! Price Level !! Tier III Price !! Tier II Price !! Tier I Price !! Units !! Explanation\n"
rowStyle, dateString, name, company, basePrice, priceLevel,
tierIIIPrice, tierIIPrice, tierIPrice, unit, explanation
)
end
end


    -- We’ll track totals so we can compare average base vs. average new.
-- Step E: averages
    local totalBase, totalNew = 0, 0
local avgBase = totalBase / count
    local count = 0
local avgNew = totalNew / count


    -- Step D: process each product with new daily random changes
local averagePriceLevel
    for _, product in ipairs(products) do
if avgNew > avgBase then
        local name    = product[1]
averagePriceLevel = "Low"
        local company  = product[2]
elseif avgNew < avgBase then
        local basePrice= product[3]
averagePriceLevel = "High"
        local unit    = product[4]
else
averagePriceLevel = "Standard"
end
local avgSym = levelSymbol(averagePriceLevel)


        -- 1) Adjust price with daily random change
if showSummary then
        local newPrice, changeFactor, explanation = simulatePriceChange(basePrice, dayOfMonth, month)
summary = summary .. string.format(
"|-\n! colspan=\"7\" | Average adjusted (%.2f) vs base (%.2f): %s %s\n|}\n",
avgNew, avgBase, avgSym, averagePriceLevel
)
out = out .. summary .. "\n"
end
 
if showBreakdown then
breakdown = breakdown .. string.format(
"|-\n! colspan=\"10\" | Average adjusted (%.2f) vs base (%.2f): %s %s\n|}\n",
avgNew, avgBase, avgSym, averagePriceLevel
)
out = out .. breakdown
end
 
return out
end
 
---------------------------------------------------------
-- Convenience: full expanded breakdown (for updating/audits)
---------------------------------------------------------
function p.full(frame)
frame = frame or {}
frame.args = frame.args or {}
frame.args.mode = "breakdown"
frame.args.collapse = "no"
return p.generateTable(frame)
end


        -- 2) Determine price level (swapped logic)
function p.getAverageData()
        local priceLevel = determinePriceLevel(basePrice, newPrice)
-- same daily seed logic already used by generateTable
local localTime = os.date("*t")
local dailySeed = localTime.year * 1000 + localTime.yday
math.randomseed(dailySeed)


        -- choose row color
local dateString, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()
        local rowStyle
        if priceLevel == "Low" then
            rowStyle = ' style="background-color:lightblue;"'
        elseif priceLevel == "Standard" then
            rowStyle = ' style="background-color:lightgreen;"'
        else
            rowStyle = ' style="background-color:#ffcccb;"'  -- light red
        end


        -- 3) Tier prices
local totalBase, totalNew, count = 0, 0, 0
        local tierIIIPrice = math.floor((newPrice / 3) * 100) / 100
        local tierIIPrice  = math.floor((newPrice * 2 / 3) * 100) / 100
        local tierIPrice  = newPrice


        -- 4) Accumulate totals for later average
for _, product in ipairs(products) do
        totalBase = totalBase + basePrice
local name = product[1]
        totalNew  = totalNew + newPrice
local company = product[2]
        count = count + 1
local basePrice = product[3]
local city = inferHQCity(company) or ""


        -- 5) Insert row with coloring
local newPrice = select(1, simulatePriceChange(
        wikitable = wikitable .. string.format(
basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company, dailySeed
            "|-%s\n| %s || %s || %s || %.2f || %s || %.2f || %.2f || %.2f || %s || %s\n",
))
            rowStyle,
            dateString,
            name,
            company,
            basePrice,
            priceLevel,
            tierIIIPrice,
            tierIIPrice,
            tierIPrice,
            unit,
            explanation
        )
    end


    -- Step E: compute average and determine overall level (swapped)
totalBase = totalBase + basePrice
    local avgBase = totalBase / count
totalNew = totalNew + newPrice
    local avgNew  = totalNew / count
count = count + 1
    local averagePriceLevel
end
    if avgNew > avgBase then
        averagePriceLevel = "Low"
    elseif avgNew < avgBase then
        averagePriceLevel = "High"
    else
        averagePriceLevel = "Standard"
    end


    -- Step F: add a final row at the bottom
local avgBase = totalBase / count
    wikitable = wikitable .. string.format(
local avgNew = totalNew / count
        "|-\n! colspan=\"10\" | Average adjusted price (%.2f) compared to average base price (%.2f) is **%s**.\n",
local avgLevel
        avgNew, avgBase, averagePriceLevel
if avgNew > avgBase then
    )
avgLevel = "Low"
elseif avgNew < avgBase then
avgLevel = "High"
else
avgLevel = "Standard"
end


    -- Close table
return {
    wikitable = wikitable .. "|}"
label = "Agriculture",
    return wikitable
avgBase = avgBase,
avgNew = avgNew,
avgLevel = avgLevel,
avgSym = levelSymbol(avgLevel),
pctChange = ((avgNew - avgBase) / avgBase) * 100
}
end
end


function p.getCompanyEmploymentInputs()
local localTime = os.date("*t")
local dailySeed = localTime.year * 1000 + localTime.yday
math.randomseed(dailySeed)
local _, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()
local companyMap = {}
for _, product in ipairs(products) do
local name = product[1]
local company = product[2]
local basePrice = product[3]
local city = inferHQCity(company) or "Vaeringheim"
local newPrice = select(1, simulatePriceChange(
basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company, dailySeed
))
if not companyMap[company] then
companyMap[company] = {
name = company,
sector = "Agriculture",
city = city,
totalBase = 0,
totalNew = 0,
count = 0
}
end
local row = companyMap[company]
row.totalBase = row.totalBase + basePrice
row.totalNew = row.totalNew + newPrice
row.count = row.count + 1
end
local out = {}
for _, row in pairs(companyMap) do
row.avgBase = row.totalBase / row.count
row.avgNew = row.totalNew / row.count
row.pctChange = ((row.avgNew - row.avgBase) / row.avgBase) * 100
table.insert(out, row)
end
table.sort(out, function(a, b) return a.name < b.name end)
return out
end
return p
return p

Latest revision as of 18:50, 10 October 2026

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


---------------------------------------------------------
-- Module:AutoUpdateAgPrices
-- Generates daily-updated agricultural-sector prices.
--
-- Features:
--  • Seeds randomness each day using localTime.year + localTime.yday
--  • Tier prices derived from the final adjusted price
--  • Minor event-based price boost for special days
--  • NEW (Dec 2025): Condensed display (Tier I headline) + collapsible full breakdown
--  • NEW (Dec 2025): Δ symbol column (↑ Low / ↓ High / • Standard)
--  • NEW (Dec 2025): Modes so editors can force full expanded output when updating
--
-- Usage:
--   {{#invoke:AutoUpdateAgPrices|generateTable}}
--     - default: summary + collapsed breakdown
--   {{#invoke:AutoUpdateAgPrices|generateTable|mode=summary}}
--     - summary only
--   {{#invoke:AutoUpdateAgPrices|generateTable|mode=breakdown}}
--     - breakdown only (collapsed by default)
--   {{#invoke:AutoUpdateAgPrices|generateTable|mode=breakdown|collapse=no}}
--     - breakdown only (expanded)
--   {{#invoke:AutoUpdateAgPrices|full}}
--     - breakdown only (expanded) convenience function
---------------------------------------------------------

local p = {}

---------------------------------------------------------
-- 1. getCurrentDate
--    Determines today's PSSC date and returns:
--      * dateString in "day/month/year [[PSSC]]"
--      * dayOfMonth (1..61)
--      * month (1=Atosiel, 2=Thalassiel, 3=Opsitheiel)
---------------------------------------------------------
local function getCurrentDate()
	local startDate = os.time({ year = 1999, month = 8, day = 6 })
	local secondsInDay = 86400
	local daysPerYear = 183
	local currentDate = os.time()
	local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay)

	local yearFraction = totalDaysElapsed / daysPerYear
	local psscYear = math.floor(yearFraction)
	local dayOfYear = math.floor((yearFraction - psscYear) * daysPerYear) + 1

	local month, dayOfMonth
	if dayOfYear <= 61 then
		month = 1
		dayOfMonth = dayOfYear
	elseif dayOfYear <= 122 then
		month = 2
		dayOfMonth = dayOfYear - 61
	else
		month = 3
		dayOfMonth = dayOfYear - 122
	end

	return string.format("%d/%d/%d [[PSSC]]", dayOfMonth, month, psscYear), dayOfMonth, month, psscYear, dayOfYear
end

---------------------------------------------------------
-- 2. Product Data
---------------------------------------------------------
local products = {
	{ "Rice", "Gladeseed Farmers' Union", 9.00, "tons" },
	{ "Edible Algae", "Gladeseed Farmers' Union", 21.00, "tons" },
	{ "Shrimp", "Gladeseed Farmers' Union", 15.00, "tons" },
	{ "Anterran Spicy Onion", "Gladeseed Farmers' Union", 18.00, "tons" },
	{ "Queen's Garlic", "Gladeseed Farmers' Union", 27.00, "tons" },
	{ "Morovian Water Buffalo", "Atterian Cattle Drivers", 0.60, "head" },
	{ "Morovian Water Buffalo Beef", "Atterian Cattle Drivers", 5.00, "tons" },
	{ "Morovian Water Buffalo Milk (raw)", "Atterian Cattle Drivers", 1.20, "barrels" },
	{ "Morovian Water Buffalo Milk (cultured)", "Atterian Cattle Drivers", 1.60, "barrels" },
	{ "Morovian Water Buffalo Cheese (aged wheels)", "Atterian Cattle Drivers", 3.40, "wheels" },
	{ "Morovian Water Buffalo Butter (salted)", "Atterian Cattle Drivers", 2.10, "crates" },
	{ "Morovian Water Buffalo Hides (cured)", "Atterian Cattle Drivers", 2.80, "sheets" },
	{ "Morovian Water Buffalo Horn Blanks", "Atterian Cattle Drivers", 1.10, "bundles" },
	{ "Morovian Water Buffalo Tallow (rendered)", "Atterian Cattle Drivers", 1.75, "barrels" },
	{ "Morovian Water Buffalo Bone Meal (fertilizer)", "Atterian Cattle Drivers", 0.95, "sacks" },
	{ "Unprocessed Noctic-Rabrev Leaf Concentrate", "Noctic Fleet", .60, "barrels" },
	{ "Processed Noctic-Rabrev Leaf Concentrate", "Noctic Fleet", .30, "barrels" },
	{ "Dried Noctic-Rabrev Petals", "Noctic Fleet", 2.25, "kilograms" },
	{ "Noctic-Rabrev Flower Oil Extract", "Noctic Fleet", .450, "liters" },
	{ "Noctic-Rabrev Culinary Spice Blend", "Noctic Fleet", 1.75, "kilograms" },
	{ "Sanctified Noctic Leaf (ritual-grade)", "Noctic Fleet", 9.00, "bundles" },
	{ "Noctic Tincture (therapeutic dosage)", "Noctic Fleet", 2.50, "vials" },
	{ "Noctic-Rabrev Infused Incense", "Noctic Fleet", 3.00, "packs" },
	{ "Noctic Flower Lokum (sweet export)", "Noctic Fleet", 2.25, "boxes" },
	{ "Temple-Pressed Noctic Resin", "Noctic Fleet", 5.00, "bricks" },
	{ "Distilled Noctic Elixir (medical grade)", "Noctic Fleet", 6.75, "bottles" },
	{ "Noctic-Rabrev Anointing Balm", "Noctic Fleet", 4.00, "jars" },
	{ "Noctic-Rabrev Ritual Ink", "Noctic Fleet", 3.50, "bottles" },
	{ "Noctic Soak Oil", "Noctic Fleet", 4.75, "flasks" },
	{ "Nocticine Silk-Wrap Cigarettes (20-count)", "Noctic Fleet", 7.25, "packs" },
	{ "Caravan Reserve Noctic Cigars (hand-rolled)", "Noctic Fleet", 3.40, "sticks" },
	{ "Pocket-Press Noctic Chew Pouches (minted)", "Noctic Fleet", 4.80, "tins" },
	{ "Chewable Night-Leaf Gum (sugar-free)", "Noctic Fleet", 3.20, "blisters" },
	{ "Quick-Fuse Nocticine Buccal Film", "Noctic Fleet", 8.10, "sheets" },
	{ "Hand-Cured Nefel Leaf Cigarettes (20-count)", "Nefel Village", 6.80, "packs" },
	{ "Village Reserve Tobacco Cigars (oak-aged)", "Nefel Village", 4.10, "sticks" },
	{ "Pressed Nefel Chew Rolls (spiced)", "Nefel Village", 4.50, "tins" },
	{ "Sun-Dried Pipe Tobacco (long-cut)", "Nefel Village", 5.25, "pouches" },
	{ "Tobacco Infused Oil (for incense burners)", "Nefel Village", 3.90, "flasks" },
	{ "Nefel Clay-Smoked Cigarettes (10-count)", "Nefel Village", 7.45, "packs" },
	{ "Herbal-Blend Hookah Tobacco", "Nefel Village", 6.20, "jars" },
	{ "Tobacco Ash Charcoal Tablets (ritual use)", "Nefel Village", 2.60, "discs" },
	{ "Manwine", "Jogiani Merchants of Manwine", 2.07, "barrels" },
	{ "Milkwine", "Jogiani Merchants of Manwine", 6.00, "barrels" },
	{ "Aged Manwine (oak-rested)", "Jogiani Merchants of Manwine", 3.60, "barrels" },
	{ "Spiced Manwine (cinnamon & citrus)", "Jogiani Merchants of Manwine", 2.85, "barrels" },
	{ "Honeyed Manwine (sweet blend)", "Jogiani Merchants of Manwine", 3.10, "barrels" },
	{ "Dry Manwine (export grade)", "Jogiani Merchants of Manwine", 2.45, "barrels" },
	{ "Sparkling Manwine (festival casks)", "Jogiani Merchants of Manwine", 4.20, "barrels" },
	{ "Milkwine Cream Liqueur (bottled)", "Jogiani Merchants of Manwine", 1.10, "bottles" },
	{ "Milkwine Whey Brandy (distilled)", "Jogiani Merchants of Manwine", 2.40, "bottles" },
	{ "Manwine Vinegar (culinary)", "Jogiani Merchants of Manwine", 0.85, "barrels" },
	{ "Zoe Elm Resin (Unrefined)", "Keepers of the Grove of Zoe Elm", 0.03, "barrels" },
	{ "Zoe Elm Resin (Refined)", "Keepers of the Grove of Zoe Elm", 0.04, "barrels" },
	{ "Zoe Elm Sap (raw draw)", "Keepers of the Grove of Zoe Elm", 0.02, "barrels" },
	{ "Zoe Elm Pitch (waterproofing grade)", "Keepers of the Grove of Zoe Elm", 0.06, "barrels" },
	{ "Zoe Elm Amberglaze (varnish base)", "Keepers of the Grove of Zoe Elm", 0.09, "barrels" },
	{ "Zoe Elm Incense Resin (temple blend)", "Keepers of the Grove of Zoe Elm", 0.12, "packs" },
	{ "Zoe Elm Bark Tannin (leather curing)", "Keepers of the Grove of Zoe Elm", 0.08, "sacks" },
	{ "Zoe Elm Wood Oil (polish & sealant)", "Keepers of the Grove of Zoe Elm", 0.07, "bottles" },
	{ "Zoe Elm Resin Beads (craft blanks)", "Keepers of the Grove of Zoe Elm", 0.05, "crates" },
	{ "Zoe Elm Resin Bricks (transport blocks)", "Keepers of the Grove of Zoe Elm", 0.05, "bricks" },
	{ "Sea Elm Flavored Mead", "Sea-Elm Southern Meadery", 1.11, "barrels" },
	{ "Sea Elm Dry Mead (export casks)", "Sea-Elm Southern Meadery", 1.25, "barrels" },
	{ "Sea Elm Spiced Mead (winter blend)", "Sea-Elm Southern Meadery", 1.35, "barrels" },
	{ "Sea Elm Honey-Reserve Mead (aged)", "Sea-Elm Southern Meadery", 1.75, "barrels" },
	{ "Sea Elm Salt-Spray Mead (briny finish)", "Sea-Elm Southern Meadery", 1.40, "barrels" },
	{ "Sea Elm Blossom Mead (spring batch)", "Sea-Elm Southern Meadery", 1.30, "barrels" },
	{ "Sea Elm Orchard Mead (fruit-infused)", "Sea-Elm Southern Meadery", 1.55, "barrels" },
	{ "Sea Elm Mead Vinegar (culinary)", "Sea-Elm Southern Meadery", 0.90, "barrels" },
	{ "Sea Elm Honey Cakes (packaged)", "Sea-Elm Southern Meadery", 0.55, "boxes" },
	{ "Sea Elm Beeswax Candles (meadery grade)", "Sea-Elm Southern Meadery", 0.45, "bundles" },
	{ "Wheat", "Plains of Jogi", 0.30, "tons" },
	{ "Oats", "Plains of Jogi", 0.23, "tons" },
	{ "Cereal", "Plains of Jogi", 0.52, "pallets" },
	{ "Hay", "Plains of Jogi", 0.45, "bales" },
	{ "Ale of the Night", "Ale of the Night Central Brewery", 2.43, "barrels" },
	{ "Ale of the Night (Noctic-Rabrev Stout)", "Ale of the Night Central Brewery", 2.65, "barrels" },
	{ "Ale of the Night (Noctic-Rabrev Porter)", "Ale of the Night Central Brewery", 2.58, "barrels" },
	{ "Ale of the Night (Noctic-Rabrev Black Lager)", "Ale of the Night Central Brewery", 2.52, "barrels" },
	{ "Ale of the Night (Noctic-Rabrev Spiced Ale)", "Ale of the Night Central Brewery", 2.70, "barrels" },
	{ "Ale of the Night (Noctic-Rabrev Honey Ale)", "Ale of the Night Central Brewery", 2.90, "barrels" },
	{ "Ale of the Night (Noctic-Rabrev Session Ale)", "Ale of the Night Central Brewery", 2.20, "barrels" },
	{ "Ale of the Night (Noctic-Rabrev Strong Ale)", "Ale of the Night Central Brewery", 3.10, "barrels" },
	{ "Ale of the Night (Noctic-Rabrev Barrel Reserve)", "Ale of the Night Central Brewery", 3.45, "barrels" },
	{ "Ale of the Night (Noctic-Rabrev Draught Kegs)", "Ale of the Night Central Brewery", 0.95, "kegs" },
	{ "Camels", "Camel Herders of the Jangsong Province", 1.04, "head" },
	{ "Camel Meat", "Camel Herders of the Jangsong Province", 34.65, "tons" },
	{ "Camel Milk", "Camel Herders of the Jangsong Province", 5.20, "barrels" },
	{ "Camel Hump Water", "Camel Herders of the Jangsong Province", 3.47, "barrels" },
	{ "Camel Hump Water Tea", "Camel Herders of the Jangsong Province", 0.86, "barrels" },
	{ "Pearls", "Anterran Imports and Services", 0.79, "sacks" },
	{ "Abalone", "Anterran Imports and Services", 2.64, "crates" },
	{ "Mother-of-Pearl Buttons (sorted)", "Anterran Imports and Services", 0.55, "crates" },
	{ "Pearl Thread Strands (drilled)", "Anterran Imports and Services", 0.68, "bundles" },
	{ "Pearl Dust (inlay grade)", "Anterran Imports and Services", 0.35, "jars" },
	{ "Abalone Shell Inlay Blanks", "Anterran Imports and Services", 1.20, "crates" },
	{ "Dried Abalone Strips (export)", "Anterran Imports and Services", 1.80, "crates" },
	{ "Abalone Broth Stock (sealed)", "Anterran Imports and Services", 0.95, "barrels" },
	{ "Abalone Shell Powder (polish)", "Anterran Imports and Services", 0.40, "sacks" },
	{ "Mixed Coastal Shell Lot (decor)", "Anterran Imports and Services", 0.60, "crates" },
	{ "Opium", "Merchant Guild of the Poppy Goddess", 0.18, "sacks" },
	{ "Poppy Seeds (culinary)", "Merchant Guild of the Poppy Goddess", 0.12, "sacks" },
	{ "Poppy Seed Oil (pressed)", "Merchant Guild of the Poppy Goddess", 0.20, "barrels" },
	{ "Poppy Flower Dye (red)", "Merchant Guild of the Poppy Goddess", 0.14, "jars" },
	{ "Poppy Petal Tea (non-potent herbal)", "Merchant Guild of the Poppy Goddess", 0.10, "packs" },
	{ "Poppy Honey Cakes (market tins)", "Merchant Guild of the Poppy Goddess", 0.16, "boxes" },
	{ "Poppy Incense Cones (temple blend)", "Merchant Guild of the Poppy Goddess", 0.22, "packs" },
	{ "Poppy Wreath Garlands (festival)", "Merchant Guild of the Poppy Goddess", 0.09, "bundles" },
	{ "Poppy Seed Flour (ground)", "Merchant Guild of the Poppy Goddess", 0.13, "sacks" },
	{ "Mead", "Grand Cave Bee Meadery", 0.49, "barrels" },
	{ "Cave Honey (raw comb)", "Grand Cave Bee Meadery", 1.20, "crates" },
	{ "Cave Honey (strained)", "Grand Cave Bee Meadery", 0.75, "jars" },
	{ "Beeswax Blocks (refined)", "Grand Cave Bee Meadery", 0.55, "blocks" },
	{ "Beeswax Candles (standard)", "Grand Cave Bee Meadery", 0.35, "bundles" },
	{ "Royal Jelly (apothecary grade)", "Grand Cave Bee Meadery", 1.60, "vials" },
	{ "Propolis Resin (sealant)", "Grand Cave Bee Meadery", 0.90, "packs" },
	{ "Honey Vinegar (brewer’s cut)", "Grand Cave Bee Meadery", 0.40, "barrels" },
	{ "Mead Yeast Cultures (starter)", "Grand Cave Bee Meadery", 0.22, "packs" },
	{ "Honey Cakes (sealed tins)", "Grand Cave Bee Meadery", 0.30, "boxes" },
	{ "Cinammon", "Cinammon Plains of Roue", 0.45, "tons" },
	{ "Cinammon Sticks (bundled)", "Cinammon Plains of Rouge", 0.60, "bundles" },
	{ "Ground Cinammon (milled)", "Cinammon Plains of Roue", 0.75, "sacks" },
	{ "Cinammon Bark Chips (brew grade)", "Cinammon Plains of Rouge", 0.55, "sacks" },
	{ "Cinammon Oil Extract (concentrate)", "Cinammon Plains of Rouge", 0.40, "bottles" },
	{ "Cinammon Sugar Blend", "Cinammon Plains of Rouge", 0.50, "sacks" },
	{ "Cinammon Tea Mix (spice cut)", "Cinammon Plains of Rouge", 0.48, "packs" },
	{ "Cinammon Resin (incense binder)", "Cinammon Plains of Rouge", 0.35, "bricks" },
	{ "Cinammon Candied Peel (export)", "Cinammon Plains of Rouge", 0.32, "crates" },
	{ "Cinammon Pastry Fill (sealed)", "Cinammon Plains of Rouge", 0.28, "jars" },
	{ "Velvet Worm Meat", "The Velvet Company", 1.04, "tons" },
	{ "Velvet Worm Eggs", "The Velvet Company", 0.35, "crates" },
	{ "Velvet Worm Silk Thread (spools)", "The Velvet Company", 0.95, "spools" },
	{ "Velvet Worm Silk Cloth (bolts)", "The Velvet Company", 2.40, "bolts" },
	{ "Velvet Worm Oil (rendered)", "The Velvet Company", 0.60, "barrels" },
	{ "Velvet Worm Chitin Sheets (craft)", "The Velvet Company", 0.75, "sheets" },
	{ "Velvet Worm Feed Pellets", "The Velvet Company", 0.28, "sacks" },
	{ "Pickled Velvet Worm Eggs (export)", "The Velvet Company", 0.55, "jars" },
	{ "Smoked Velvet Worm Strips", "The Velvet Company", 0.80, "slabs" },
	{ "Velvet Worm Broth Concentrate", "The Velvet Company", 0.42, "jars" },
	{ "Silk", "Seamstresses of Rouge", 5.00, "rolls" },
	{ "Dyed Silk (Rouge crimson)", "Seamstresses of Rouge", 5.75, "rolls" },
	{ "Patterned Silk Brocade", "Seamstresses of Rouge", 6.50, "rolls" },
	{ "Raw Silk Thread (spools)", "Seamstresses of Rouge", 1.40, "spools" },
	{ "Woven Silk Sashes", "Seamstresses of Rouge", 0.85, "bundles" },
	{ "Embroidered Veils (festival)", "Seamstresses of Rouge", 1.10, "units" },
	{ "Silk Lining Cloth (tailor grade)", "Seamstresses of Rouge", 4.40, "rolls" },
	{ "Silk Cord (braided)", "Seamstresses of Rouge", 0.60, "bundles" },
	{ "Silk Patch Kits (repair)", "Seamstresses of Rouge", 0.35, "kits" },
	{ "Finished Silk Robes (export)", "Seamstresses of Rouge", 2.20, "units" },
	{ "Horehound Mead", "Salurian Temple of Sacred Horehound", 0.05, "barrels" },
	{ "Horehound Beer", "Salurian Temple of Sacred Horehound", 0.07, "barrels" },
	{ "Horehound Tea (dried leaves)", "Salurian Temple of Sacred Horehound", 0.12, "packs" },
	{ "Horehound Syrup (cough blend)", "Salurian Temple of Sacred Horehound", 0.18, "bottles" },
	{ "Horehound Candies (wrapped)", "Salurian Temple of Sacred Horehound", 0.16, "boxes" },
	{ "Horehound Tincture (apothecary)", "Salurian Temple of Sacred Horehound", 0.22, "vials" },
	{ "Horehound Incense (ritual sticks)", "Salurian Temple of Sacred Horehound", 0.14, "sticks" },
	{ "Horehound Salve (chest rub)", "Salurian Temple of Sacred Horehound", 0.20, "jars" },
	{ "Horehound Honey Blend", "Salurian Temple of Sacred Horehound", 0.19, "jars" },
	{ "Horehound Herb Bundles (fresh)", "Salurian Temple of Sacred Horehound", 0.10, "bundles" },
	{ "Sea Cow Beef", "Bulhanu Ranchers' Association", 8.50, "tons" },
	{ "Sea Cow Milk (raw)", "Bulhanu Ranchers' Association", 2.40, "barrels" },
	{ "Sea Cow Cheese (aged wheels)", "Bulhanu Ranchers' Association", 3.60, "wheels" },
	{ "Sea Cow Butter (salted)", "Bulhanu Ranchers' Association", 2.10, "crates" },
	{ "Sea Cow Tallow (rendered)", "Bulhanu Ranchers' Association", 1.75, "barrels" },
	{ "Sea Cow Hides (cured)", "Bulhanu Ranchers' Association", 3.10, "sheets" },
	{ "Sea Cow Bone Meal (fertilizer)", "Bulhanu Ranchers' Association", 0.95, "sacks" },
	{ "Sea Cow Jerky (salted strips)", "Bulhanu Ranchers' Association", 4.40, "slabs" },
	{ "Sea Cow Sausage (smoked)", "Bulhanu Ranchers' Association", 6.20, "tons" },
	{ "Sea Cow Oil (lamp/cooking grade)", "Bulhanu Ranchers' Association", 1.30, "barrels" },
	{ "Atterian Armored Pufferfish", "Suncliff Fisheries", 3.00, "tons" },
	{ "Morovian Saucer Eyed Giant Eel", "Suncliff Fisheries", 7.50, "tons" },
	{ "Amina Crab", "Suncliff Fisheries", 6.00, "tons" },
	{ "Mugwort Oil", "Ministers of Mistress Mugwort", 0.35, "barrels" },
	{ "Ground Mugwort", "Ministers of Mistress Mugwort", 0.75, "sacks" },
	{ "Mugwort Tincture", "Ministers of Mistress Mugwort", 0.10, "barrels" },
	{ "Blood InfusedRed Wine", "Blood Vineyards of the Far North", 0.39, "barrels" },
	{ "Blood-Infused Red Wine (reserve)", "Blood Vineyards of the Far North", 0.55, "barrels" },
	{ "Blood-Infused Red Wine (oak-aged)", "Blood Vineyards of the Far North", 0.62, "barrels" },
	{ "Blood-Infused Spiced Red (winter batch)", "Blood Vineyards of the Far North", 0.58, "barrels" },
	{ "Dry Red Wine (cold-ferment)", "Blood Vineyards of the Far North", 0.44, "barrels" },
	{ "Fortified Red Wine (export casks)", "Blood Vineyards of the Far North", 0.70, "barrels" },
	{ "Red Grape Must (ferment base)", "Blood Vineyards of the Far North", 0.30, "barrels" },
	{ "Wine Vinegar (barrel aged)", "Blood Vineyards of the Far North", 0.26, "barrels" },
	{ "Pressed Grape Pomace (feed/fertilizer)", "Blood Vineyards of the Far North", 0.18, "sacks" },
	{ "Northern Vineyard Bottle Lot (mixed)", "Blood Vineyards of the Far North", 0.12, "crates" },
	{ "Wisp Rice", "Norsolyrian Wisp Rice Farmers Association", 1.5, "tons" },
	{ "Wisp Rice Flour (milled)", "Norsolyrian Wisp Rice Farmers Association", .950, "sacks" },
	{ "Wisp Rice Noodles (dried)", "Norsolyrian Wisp Rice Farmers Association", .620, "crates" },
	{ "Wisp Rice Vinegar (fermented)", "Norsolyrian Wisp Rice Farmers Association", .480, "barrels" },
	{ "Wisp Rice Cakes (pressed)", "Norsolyrian Wisp Rice Farmers Association", .560, "boxes" },
	{ "Wisp Rice Bran (feed grade)", "Norsolyrian Wisp Rice Farmers Association", .340, "sacks" },
	{ "Wisp Rice Straw Bales (thatching)", "Norsolyrian Wisp Rice Farmers Association", .210, "bales" },
	{ "Wisp Rice Malt (brewer’s batch)", "Norsolyrian Wisp Rice Farmers Association", .780, "sacks" },
	{ "Wisp Rice Seed Stock (certified)", "Norsolyrian Wisp Rice Farmers Association", .860, "sacks" },
	{ "Wisp Rice Porridge Mix (packaged)", "Norsolyrian Wisp Rice Farmers Association", .420, "crates" },
	{ "Giid-Lisea-Eda", "Giid-Lisea Ranching Import Company", 0.41, "head" },
	{ "Giid-Lisea-Eda Beef", "Giid-Lisea Ranching Import Company", 7.10, "tons" },
	{ "Giid-Lisea-Eda Milk", "Giid-Lisea Ranching Import Company", 3.85, "liters" },
	{ "Cream Butter", "Giid-Lisea Ranching Import Company", 2.12, "pounds" },
	{ "Aged Cheese", "Giid-Lisea Ranching Import Company", 1.44, "wheels" },
	{ "Giid-Lisea Hide Leather", "Giid-Lisea Ranching Import Company", 4.23, "sheets" },
	{ "Tusk Ivory Carvings", "Giid-Lisea Ranching Import Company", 0.73, "pieces" },
	{ "Bone-Broth Concentrate", "Giid-Lisea Ranching Import Company", 5.67, "jars" },
	{ "Mammoth Fat Candles", "Giid-Lisea Ranching Import Company", 1.98, "candles" },
	{ "Frozen Mammoth Steaks", "Giid-Lisea Ranching Import Company", 6.22, "pounds" },
	{ "Pickled Mammoth Tongue", "Giid-Lisea Ranching Import Company", 0.89, "jars" },
	{ "Giid-Lisea Jerky (salted)", "Giid-Lisea Ranching Import Company", 4.56, "slabs" },
	{ "Mammoth Bone Flour (fertilizer)", "Giid-Lisea Ranching Import Company", 2.71, "sacks" },
	{ "Giid-Lisea Cream Liqueur", "Giid-Lisea Ranching Import Company", 3.14, "bottles" },
	{ "Highland Ale (milk-based)", "Giid-Lisea Ranching Import Company", 5.09, "tankards" },
	{ "Vaeringheim Turkey Meat", "Bird Keepers of Saluria", 1.07, "tons" },
	{ "Salurian Swamp Quail Eggs", "Bird Keepers of Saluria", 12.00, "crates" },
	{ "Live Swamp Quail (breeding pairs)", "Bird Keepers of Saluria", 0.85, "pairs" },
	{ "Turkey Feathers (sorted)", "Bird Keepers of Saluria", 0.45, "bundles" },
	{ "Quail Feathers (fine)", "Bird Keepers of Saluria", 0.30, "bundles" },
	{ "Rendered Poultry Fat (cooking)", "Bird Keepers of Saluria", 0.60, "barrels" },
	{ "Smoked Turkey Strips (trail packs)", "Bird Keepers of Saluria", 0.95, "crates" },
	{ "Turkey Bone Stock (sealed)", "Bird Keepers of Saluria", 0.40, "barrels" },
	{ "Quail Egg Pickles (spiced jars)", "Bird Keepers of Saluria", 0.55, "jars" },
	{ "Feather Quilting Fill (cleaned)", "Bird Keepers of Saluria", 0.75, "sacks" },
	{ "Giant Fanged Penguin Blubber", "Hunters of the Giant Fanged Penguin", 25.00, "tons" },
	{ "Giant Fanged Penguin Blubber Oil Extract", "Hunters of the Giant Fanged Penguin", 5.00, "barrels" },
	{ "Giant Fanged Penguin Meat (salted)", "Hunters of the Giant Fanged Penguin", 12.50, "tons" },
	{ "Giant Fanged Penguin Meat (smoked)", "Hunters of the Giant Fanged Penguin", 14.00, "tons" },
	{ "Giant Fanged Penguin Hide (cured)", "Hunters of the Giant Fanged Penguin", 9.50, "sheets" },
	{ "Giant Fanged Penguin Bone Blanks (carving)", "Hunters of the Giant Fanged Penguin", 6.20, "crates" },
	{ "Penguin Fat Candles (cold-weather)", "Hunters of the Giant Fanged Penguin", 4.80, "bundles" },
	{ "Penguin Oil Lantern-Grade (refined)", "Hunters of the Giant Fanged Penguin", 6.10, "barrels" },
	{ "Penguin Bone Meal (fertilizer)", "Hunters of the Giant Fanged Penguin", 3.40, "sacks" },
	{ "Penguin Hunting Permits (season lot)", "Hunters of the Giant Fanged Penguin", 1.20, "permits" },
	{"Aminian Green Coffee Beans (unroasted)", "Aminian Coffee Company", 9, "pounds"},
	{"Tel-Amin Dark Roast (whole bean)", "Aminian Coffee Company", 11, "pounds"},
	{"Tel-Amin Medium Roast (whole bean)", "Aminian Coffee Company", 10.5, "pounds"},
	{"Aminian Espresso Blend (whole bean)", "Aminian Coffee Company", 12, "pounds"},
	{"Stone-Ground Coffee (fine powder)", "Aminian Coffee Company", 11.5, "pounds"},
	{"Coarse-Ground Caravan Coffee (brew-ready)", "Aminian Coffee Company", 10.0, "pounds"},
	{"Cold-Brew Coffee Concentrate (bottled)", "Aminian Coffee Company", 6.5, "bottles"},
	{"Sweetened Coffee Syrup (for desserts/drinks)", "Aminian Coffee Company", 5.5, "bottles"},
	{"Cascara Tea (coffee-cherry husk infusion)", "Aminian Coffee Company", 7.0, "pounds"},
	{"Coffee Blossom Honey (grove-hive harvest)", "Aminian Coffee Company", 4.0, "jars"},
	{ "Reindeer Meat", "Knights Castle Reindeer Herders", 3.15, "tons" },
	{ "Leather", "Knights Castle Reindeer Herders", 7.5, "pounds" },
	{ "Bone Products", "Knights Castle Reindeer Herders", 1.06, "crates" },
	{ "Whale Meat", "Lindley Whaling Company", 13.5, "tons" },
	{ "Whale Oil", "Lindley Whaling Company", .77, "crates" },
	{ "Whale Bone", "Lindley Whaling Company", 5.1, "tons" },
	{ "Seal Meat", "Lindley Whaling Company", 3.1, "tons" },
	{ "Seal Oil", "Lindley Whaling Company", .32, "crates" },
	{ "Seal Fur", "Lindley Whaling Company", 2.23, "crates" },
	{ "Sea Lion Meat", "Lindley Whaling Company", 6.45, "tons" },
	{ "Sea Lion Oil", "Lindley Whaling Company", .46, "crates" },
	{ "Sea Lion Fur", "Lindley Whaling Company", 4.8, "crates" },
	{ "Beans", "Granadita Collective", 2.4, "tons" },
	{ "Potatos", "Granadita Collective", 6.1, "tons" },
	{ "Squash", "Granadita Collective", 5.4, "tons" },
	{ "Wheat", "Granadita Collective", 1.19, "tons" },
	{ "maize", "Granadita Collective", 6.93, "tons" },
	{ "Vegetable Lamb of Tartary", "Herd Caton", 2.77, "head" },
	{ "Lamb’s Wool (Vegetable Blend)", "Herd Caton", .18, "kg" },
	{ "Lamb-Root Cheese", "Herd Caton", .42, "wheels" },
	{ "Tartary Saplings", "Herd Caton", .32, "plants" },
	{ "Pickled Lamb Stalks", "Herd Caton", .24, "jars" },
	{ "Partially Digested Fish Pulp", "Wasp Hunters of the Austral Isles", 23.76, "pounds" },
	{ "Fermented Fish Pulp Bricks", "Wasp Hunters of the Austral Isles", 4.12, "bricks" },
	{ "Fish Gut Oil (cooking & lamp use)", "Wasp Hunters of the Austral Isles", 7.85, "liters" },
	{ "Salted Intestinal Mash", "Wasp Hunters of the Austral Isles", 15.63, "pounds" },
	{ "Brined Gill Ribbons", "Wasp Hunters of the Austral Isles", 3.21, "bundles" },
	{ "Smoked Aiji-Hial-Nas Strips", "Wasp Hunters of the Austral Isles", 8.44, "pounds" },
	{ "Pickled Stomach Chunks", "Wasp Hunters of the Austral Isles", 2.09, "jars" },
	{ "Fish Maw Jelly", "Wasp Hunters of the Austral Isles", 6.39, "jars" },
	{ "Dried Scale Powder (seasoning)", "Wasp Hunters of the Austral Isles", 2.44, "sachets" },
	{ "Sea-Salt Ferment Porridge", "Wasp Hunters of the Austral Isles", 5.70, "bowls" },
	{ "Wasp Hunter’s Black Rum", "Wasp Hunters of the Austral Isles", 9.80, "bottles" },
	{ "Fish-Pulp Mead (sweet & briny blend)", "Wasp Hunters of the Austral Isles", 4.55, "bottles" },
	{ "Spiced Intestine Ale", "Wasp Hunters of the Austral Isles", 6.13, "tankards" },
	{ "Dried Roe Biscuits", "Wasp Hunters of the Austral Isles", 3.22, "cakes" },
	{ "Hunter’s Brine Wine (fortified)", "Wasp Hunters of the Austral Isles", 7.90, "bottles" },
	{ "Raw Cane Sugar", "Diamonia Sugar Cooperatives", 1.92, "tons" },
	{ "Refined White Sugar", "Diamonia Sugar Cooperatives", 1.44, "tons" },
	{ "Brown Sugar", "Diamonia Sugar Cooperatives", 0.88, "tons" },
	{ "Molasses", "Diamonia Sugar Cooperatives", 0.76, "barrels" },
	{ "Rock Sugar Crystals", "Diamonia Sugar Cooperatives", 0.67, "crates" },
	{ "Sugar Loaves", "Diamonia Sugar Cooperatives", 1.15, "blocks" },
	{ "Date Sugar Blend", "Diamonia Sugar Cooperatives", 0.38, "sacks" },
	{ "Candied Citrus Peel", "Diamonia Sugar Cooperatives", 0.24, "crates" },
	{ "Sugar Syrup", "Diamonia Sugar Cooperatives", 0.91, "barrels" },
	{ "Sweet Tea Cakes", "Diamonia Sugar Cooperatives", 0.53, "boxes" },
	{ "Cold-Steppe Barley", "Ouriana Lowlands Farmers' Association", 8.25, "tons" },
	{ "Proso Millet", "Ouriana Lowlands Farmers' Association", 7.75, "tons" },
	{ "Buckwheat", "Ouriana Lowlands Farmers' Association", 9.50, "tons" },
	{ "Foxtail Millet", "Ouriana Lowlands Farmers' Association", 8.00, "tons" },
	{ "Cold-Hardy Lentils", "Ouriana Lowlands Farmers' Association", 12.00, "tons" },
	{ "Turnips (Mountain-Grown)", "Ouriana Lowlands Farmers' Association", 6.25, "tons" },
	{ "Rutabagas (Highland)", "Ouriana Lowlands Farmers' Association", 6.50, "tons" },
	{ "Alpine Cabbage", "Ouriana Lowlands Farmers' Association", 6.75, "tons" },
	{ "Wild Rye", "Ouriana Lowlands Farmers' Association", 9.00, "tons" },
	{ "Cultivated Rye", "Ouriana Lowlands Farmers' Association", 9.75, "tons" },
	{ "Kohlrabi", "Ouriana Lowlands Farmers' Association", 7.25, "tons" },
	{ "Steppe Rhubarb", "Ouriana Lowlands Farmers' Association", 5.75, "tons" },
	{ "Mountain Sorrel", "Ouriana Lowlands Farmers' Association", 4.00, "tons" },
	{ "Cold-Hardy Hops", "Ouriana Lowlands Farmers' Association", 18.00, "tons" },
	{ "Highland Herbal Blend (raw)", "Ouriana Lowlands Farmers' Association", 10.50, "tons" },
	{ "Fermenting Barley", "Ouriana Lowlands Farmers' Association", 12.75, "tons" },
	{ "Highland Lentil and Millet Mix (packaged)", "Ouriana Lowlands Farmers' Association", 13.25, "tons" },
	{ "Highland Grayling", "Ouriad River Fisheries Cooperative", 7.80, "tons" },
	{ "Mountain Whitefish", "Ouriad River Fisheries Cooperative", 6.90, "tons" },
	{ "Brown Trout", "Ouriad River Fisheries Cooperative", 8.25, "tons" },
	{ "Lake Sturgeon Roe", "Ouriad River Fisheries Cooperative", 11.50, "kilograms" },
	{ "Whitefish (Spawning-Run)", "Ouriad River Fisheries Cooperative", 6.50, "tons" },
	{ "Lamprey", "Ouriad River Fisheries Cooperative", 9.75, "crates" },
	{ "Salted Lamprey Filets", "Ouriad River Fisheries Cooperative", 8.10, "tons" },
	{ "Smoked Burbot", "Ouriad River Fisheries Cooperative", 7.25, "tons" },
	{ "Steppe Horse (Working Breed)", "Caspazani Livestock Company", 3.2, "head" },
	{ "Highland Courier Mount", "Caspazani Livestock Company", 4.7, "head" },
	{ "Cavalry Stock (Auxiliary-Grade)", "Caspazani Livestock Company", 5.4, "head" },
	{ "Foal Training Licenses", "Caspazani Livestock Company", 0.4, "permits" },
	{ "Standard Saddle Kits (Hide & Wood)", "Caspazani Livestock Company", 1.6, "sets" },
	{ "Herding Bat Colony (Trained)", "Caspazani Livestock Company", 5.8, "colonies" },
	{ "Bat Guidance Whistle Sets", "Caspazani Livestock Company", 0.5, "kits" },
	{ "Pack Horse Leasing Contracts", "Caspazani Livestock Company", 1.9, "agreements" },
	{ "Horse Milk (Fermentable)", "Caspazani Livestock Company", 1.1, "liters" },
	{ "Livestock Registry Processing (Valley Standard)", "Caspazani Livestock Company", 0.3, "entries" },
	{ "White Beets", "White Ruby Communes", 7.124, "crates" },
	{ "Potatoes", "White Ruby Communes", 12.542, "sacks" },
	{ "Onions", "White Ruby Communes", 10.304, "sacks" },
	{ "Cabbage", "White Ruby Communes", 8.761, "heads" },
	{ "Garlic Bulbs", "White Ruby Communes", 1.984, "bundles" },
	{ "Dill", "White Ruby Communes", 0.673, "kilograms" },
	{ "Parsley", "White Ruby Communes", 0.544, "kilograms" },
	{ "Wild Juniper Berries", "White Ruby Communes", 0.298, "kilograms" },
	{ "Thyme Bush Cuttings", "White Ruby Communes", 0.186, "kilograms" },
	{ "Preserved Wild Boar (Spiced)", "White Ruby Communes", 0.462, "kilograms" },
	{ "Caledonian Spiced Ham", "White Ruby Communes", 0.117, "kilograms" },
	{ "Caledonian Cured Ham (Young)", "White Ruby Communes", 0.221, "kilograms" },
	{ "Purple Sturgeon Caviar", "White Ruby Communes", 0.037, "kilograms" },
	{ "Crab Roe Caviar", "White Ruby Communes", 0.052, "kilograms" },
	{ "Dried Pel'myeny Dumplings", "White Ruby Communes", 3.210, "packs" },
	{ "Borsch Base Mix (Dehydrated)", "White Ruby Communes", 2.901, "canisters" },
	{ "Velvet Antler Capsules", "Fange Velvet", 0.245, "bottles" },
	{ "Powdered Velvet Antler", "Fange Velvet", 1.102, "kilograms" },
	{ "Velvet Antler Slices (Dried)", "Fange Velvet", 0.538, "kilograms" },
	{ "Antler-Based Tonic Elixir", "Fange Velvet", 0.782, "liters" },
	{ "Velvet Antler Salve", "Fange Velvet", 0.312, "jars" },
	{ "Luxury Antler Infused Tea", "Fange Velvet", 0.874, "canisters" },
	{ "Antler Resin Bars", "Fange Velvet", 1.090, "bricks" },
	{ "Velvet Antler Wine (Fortified)", "Fange Velvet", 2.320, "bottles" },
	{ "Velvet Antler Soap", "Fange Velvet", 2.50, "bars" },
	{ "Antler Horn Carvings (Polished Ends)", "Fange Velvet", 0.152, "units" },
	{ "Wheat (Unmilled)", "Port of Corumia", 0.82, "tons" },
	{ "Oats (Unhulled)", "Port of Corumia", 0.52, "tons" },
	{ "Hay (Dry Bundled)", "Port of Corumia", 0.79, "bales" },
	{ "Cereal Base Grain Blend", "Port of Corumia", 0.87, "pallets" },
	{ "Nou-Oname Leaves (Dried)", "Port of Corumia", 12.00, "satchels" },
	{ "Adraso-Onam (Dried Herb Mix)", "Port of Corumia", 21.35, "bundles" },
	{ "Eeli-Illt-Eda Meat (Fresh)", "Port of Corumia", 5.5, "tons" },
	{ "Calamari (Lake Norton)", "Port of Corumia", 2.96, "tons" },
	{ "Jied-Rarev (Unrefined Pollen)", "Port of Corumia", 5.48, "kilograms" },
	{ "Fuy-Rabrev (Raw Resin)", "Port of Corumia", 5.96, "kilograms" },
	{ "Lowland Giraffe Meat (primal cuts)", "Lamian Ward", 6.80, "tons" },
	{ "Salted Giraffe Jerky", "Lamian Ward", 3.25, "slabs" },
	{ "Pemmican Cakes (tallow & dried meat)", "Lamian Ward", 2.10, "cakes" },
	{ "Rendered Tallow", "Lamian Ward", 2.95, "kilos" },
	{ "Marrow Oil", "Lamian Ward", 0.78, "barrels" },
	{ "Gelatin & Collagen Stock", "Lamian Ward", 1.35, "kilos" },
	{ "Bone-Broth Concentrate", "Lamian Ward", 4.20, "jars" },
	{ "Lowland Giraffe Hides (veg-tanned)", "Lamian Ward", 4.10, "sheets" },
	{ "Sinew/Tendon Cordage", "Lamian Ward", 0.95, "coils" },
	{ "Bone Flour (fertilizer)", "Lamian Ward", 2.40, "sacks" },
	{ "Bouldercast Alpine Fertilizer Pellets", "Sleva Farming Supply Cooperatives", 1.6, "tons" },
	{ "Bouldercast Terrace Blend (slow-release)", "Sleva Farming Supply Cooperatives", 1.25, "tons" },
	{ "Plug-Pit Seedling Mix (germination grade)", "Sleva Farming Supply Cooperatives", .875, "tons" },
	{ "Carapace Chitin-Calcium Flour (soil amendment)", "Sleva Farming Supply Cooperatives", .54, "tons" },
	{ "Molted Carapace Roofing Slabs (frost-proof)", "Sleva Farming Supply Cooperatives", 7.2, "slabs" },
	{ "Cuticle Grit (erosion & drainage aggregate)", "Sleva Farming Supply Cooperatives", .76, "tons" },
	{ "Root-Mat Foliar Extract (liquid feed)", "Sleva Farming Supply Cooperatives", 3.25, "barrels" },
	{ "Tri-Rostrum Microbial Inoculant", "Sleva Farming Supply Cooperatives", 45, "kilograms" },
	{ "Amber-Salt Deterrent Lures", "Sleva Farming Supply Cooperatives", 32, "packs" },
	{ "Terrace Stabilization Mat (biocomposite)", "Sleva Farming Supply Cooperatives", 18, "rolls" },
	{ "Woolhorse Underfleece (raw, Grade A)", "Hrimmanes Woolhorse Company", 2.4, "bales" },
	{ "Woolhorse Underfleece (raw, Grade B)", "Hrimmanes Woolhorse Company", 1.6, "bales" },
	{ "De-Guarded Woolhorse Tops", "Hrimmanes Woolhorse Company", 3.1, "bales" },
	{ "Woolhorse Spun Yarn (dk/worsted, 50 kg)", "Hrimmanes Woolhorse Company", 2.2, "crates" },
	{ "Woolhorse Felt Bolts (10 m x 1.4 m)", "Hrimmanes Woolhorse Company", 1.8, "bolts" },
	{ "Pack-Train Woolhorse (geldings)", "Hrimmanes Woolhorse Company", 0.85, "head" },
	{ "Breeding Woolhorse (mares)", "Hrimmanes Woolhorse Company", 1.10, "head" },
	{ "Cold-Weather Tack Set (saddle, collars, panniers)", "Hrimmanes Woolhorse Company", 7.50, "sets" },
	{ "Prime Reindeer Pelts", "King's Home Fur Trappers' Cooperative", 6.75, "bundles" },
	{ "Snow-Hare Fur (Winter White)", "King's Home Fur Trappers' Cooperative", 4.10, "bundles" },
	{ "Arctic Fox Pelts (Grade A)", "King's Home Fur Trappers' Cooperative", 7.90, "bundles" },
	{ "Tanned Wolf Hides", "King's Home Fur Trappers' Cooperative", 5.60, "sheets" },
	{ "Bear Fat Rendering (Cooking & Lamp Grade)", "King's Home Fur Trappers' Cooperative", 1.85, "barrels" },
	{ "Smoked Venison (Cold-Steppe Cure)", "King's Home Fur Trappers' Cooperative", 3.40, "tons" },
	{ "Antler Carving Blanks", "King's Home Fur Trappers' Cooperative", 0.88, "crates" },
	{ "Sinew Cordage (Hand-Twisted)", "King's Home Fur Trappers' Cooperative", 0.52, "coils" },
	{ "Trapper’s Tallow Soap (Pine & Resin Blend)", "King's Home Fur Trappers' Cooperative", 2.25, "bars" },
	{ "Frontier Survival Kits (Flint, Cord, Resin, Hide Pouch)", "King's Home Fur Trappers' Cooperative", 0.95, "sets" },
	{ "Caledonj Deep-Bay Lobster", "Caledonj Bay Fishermen’s’ Cooperatives", 1.875, "tons" },
	{ "Lobster Roe (Fresh)", "Caledonj Bay Fishermen’s’ Cooperatives", 6.80, "kilograms" },
	{ "Salt-Cured Lobster Meat", "Caledonj Bay Fishermen’s’ Cooperatives", 1.725, "tons" },
	{ "Pickled Lobster Claws (Spiced)", "Caledonj Bay Fishermen’s’ Cooperatives", 2.35, "jars" },
	{ "Lobster Bisque Base", "Caledonj Bay Fishermen’s’ Cooperatives", 3.90, "barrels" },
	{ "Smoked Lobster Fillets", "Caledonj Bay Fishermen’s’ Cooperatives", 1.850, "tons" },
	{ "Lobster Shell Powder (Culinary Use)", "Caledonj Bay Fishermen’s’ Cooperatives", 4.75, "kilograms" },
	{ "Chitin Extract (Cosmetic Grade)", "Caledonj Bay Fishermen’s’ Cooperatives", 7.80, "kilograms" },
	{ "Amber-Lobster Jerky", "Caledonj Bay Fishermen’s’ Cooperatives", 6.40, "slabs" },
	{ "Lobster Broth Concentrate", "Caledonj Bay Fishermen’s’ Cooperatives", 5.60, "bottles" },
	{ "Deep-Bay Lobster Oil", "Caledonj Bay Fishermen’s’ Cooperatives", 4.30, "liters" },
	{ "Crushed Lobster Shell Fertilizer", "Caledonj Bay Fishermen’s’ Cooperatives", 2.95, "sacks" },
	{ "Amber-Spiced Lobster Sausage", "Caledonj Bay Fishermen’s’ Cooperatives", 9.25, "tons" },
	{ "Marinated Lobster Medallions", "Caledonj Bay Fishermen’s’ Cooperatives", 3.25, "trays" },
	{ "Caledonj Lobster Liver Paste", "Caledonj Bay Fishermen’s’ Cooperatives", 2.10, "jars" },
	{ "Indigo", "Port of Euranidom", 0.04, "jars" },
	{ "Izaire Tempranillo", "Port of Euranidom", 3.96, "barrels" },
	{ "Mitrani Reisling", "Port of Euranidom", 2.64, "barrels" },
	{ "St. Felix Zinfandel", "Port of Euranidom", 1.66, "barrels" },
	{ "Lettuce", "Port of Euranidom", 4.96, "tons" },
	{ "Lettuce Water", "Port of Euranidom", 2.32, "barrels" },
	{ "Potting Soil", "Port of Euranidom", 13.20, "sacks" },
	{ "Garden Soil", "Port of Euranidom", 39.60, "sacks" },
	{ "Wheat", "Port of Euranidom", 3.30, "tons" },
	{ "Oats", "Port of Euranidom", 5.28, "tons" },
	{ "Arabian Horses", "Port of Euranidom", 0.17, "head" },
	{ "Wool", "Port of Euranidom", 2.64, "bales" },
	{ "Canned Tuna", "Port of Euranidom", 1.15, "crates" },
	{ "Fresh Tuna", "Port of Euranidom", 0.43, "tons" },
	{ "Tuna Eggs", "Port of Euranidom", 0.36, "crates" },
	{ "Cotton", "Port of Euranidom", 19.44, "bales" },
	{ "Silk", "Port of Euranidom", 0.09, "rolls" },
	{ "Cows", "Southern Port of Keltiania", 1.06, "head" },
	{ "Goats", "Southern Port of Keltiania", 1.85, "head" },
	{ "Sheep", "Southern Port of Keltiania", 1.58, "head" },
	{ "Pigs", "Southern Port of Keltiania", 1.48, "head" },
	{ "Chickens", "Southern Port of Keltiania", 5.28, "head" },
	{ "Turkeys", "Southern Port of Keltiania", 4.22, "head" },
	{ "Horses", "Southern Port of Keltiania", 0.79, "head" },
	{ "Fish", "Southern Port of Keltiania", 0.79, "tons" },
	{ "Wheat", "Southern Port of Keltiania", 13.20, "tons" },
	{ "Oats", "Southern Port of Keltiania", 5.28, "tons" },
	{ "Cereal", "Southern Port of Keltiania", 7.92, "pallets" },
	{ "Hay", "Southern Port of Keltiania", 15.84, "bales" },
	{ "Tropical Fruit", "Southern Port of Keltiania", 3.17, "tons" },
	{ "Assorted Vegetables", "Southern Port of Keltiania", 1.58, "tons" },
	{ "Assorted Nuts", "Southern Port of Keltiania", 2.64, "sacks" },
	{ "Assorted Oils", "Southern Port of Keltiania", 3.70, "barrels" },
	{ "Coffee", "Southern Port of Keltiania", 4.22, "pounds" },
	{ "Hemp Fiber", "Southern Port of Keltiania", 15.84, "tons" },
	{ "Hemp Oil", "Southern Port of Keltiania", 4.42, "barrels" },
	{ "Hemp Paper", "Southern Port of Keltiania", 3.68, "reams" },
	{ "Salain Wheat (Unmilled)", "Salain's Landing Granary Complex", 3.60, "tons" },
	{ "Salain Barley", "Salain's Landing Granary Complex", 3.25, "tons" },
	{ "Salain Oats (Cleaned)", "Salain's Landing Granary Complex", 2.85, "tons" },
	{ "Lake Morovia Rye", "Salain's Landing Granary Complex", 3.10, "tons" },
	{ "Granary Flour (stone-milled)", "Salain's Landing Granary Complex", 1.15, "sacks" },
	{ "Barley Flour (milled)", "Salain's Landing Granary Complex", 1.05, "sacks" },
	{ "Mixed Cereal Base Grain", "Salain's Landing Granary Complex", 4.20, "pallets" },
	{ "Emergency Grain Reserve Lots", "Salain's Landing Granary Complex", 5.75, "pallets" },
	{ "Sunflower Seeds (cleaned)", "Salain's Landing Granary Complex", 1.40, "sacks" },
	{ "Pressed Sunflower Oil", "Salain's Landing Granary Complex", 2.35, "barrels" },
	{ "Sunflower Meal (feed grade)", "Salain's Landing Granary Complex", 0.95, "sacks" },
	{ "Bran and Chaff Feed Mix", "Salain's Landing Granary Complex", 0.70, "sacks" },
	{ "Seed Grain Stock (certified)", "Salain's Landing Granary Complex", 1.85, "sacks" },
	{ "Granary Biscuit Rations", "Salain's Landing Granary Complex", 0.90, "boxes" },
	{ "Famine-Relief Flour Lots", "Salain's Landing Granary Complex", 3.80, "pallets" },
	{"Melusinian Orchard Apples (fresh)", "Grove Synaxis of Tel-Amin", 3.05, "tons"},
	{"Tel-Amin Pressing Apples", "Grove Synaxis of Tel-Amin", 1.40, "tons"},
	{"Coral-Grove Dried Apple Rings", "Grove Synaxis of Tel-Amin", 0.62, "crates"},
	{"Apolline Apple Cider (sweet)", "Grove Synaxis of Tel-Amin", 1.35, "barrels"},
	{"Apolline Apple Cider (dry export)", "Grove Synaxis of Tel-Amin", 1.55, "barrels"},
	{"Apple Vinegar of the Fossil Fields", "Grove Synaxis of Tel-Amin", 0.72, "barrels"},
	{"Apolline Apple Blossom Honey", "Grove Synaxis of Tel-Amin", 1.05, "jars"},
	{"Spiced Apple Preserves", "Grove Synaxis of Tel-Amin", 0.58, "jars"},
	{"Tel-Amin Apple Butter", "Grove Synaxis of Tel-Amin", 0.52, "jars"},
	{"Fossil-Field Orchard Saplings", "Grove Synaxis of Tel-Amin", 0.86, "plants"},
	{"Applewood Smoking Chips", "Grove Synaxis of Tel-Amin", 0.44, "sacks"},
	{"Apolline Grove Garlands", "Grove Synaxis of Tel-Amin", 0.28, "bundles"},

---------------------------------------------------------
-- Alperkin Commercial Cult
-- Wardens of the Fields of Callope
---------------------------------------------------------

	{ "Agrithor Orys Grain", "Wardens of the Fields of Callope", 4.80, "tons" },
	{ "Agrithor Orys Flour", "Wardens of the Fields of Callope", 1.35, "sacks" },
	{ "Agrithor Orys Porridge Meal", "Wardens of the Fields of Callope", 1.05, "sacks" },
	{ "Agrithor Orys Brewing Grain", "Wardens of the Fields of Callope", 3.60, "tons" },
	{ "Pressed Agrithor Orys Cooking Oil", "Wardens of the Fields of Callope", 2.75, "barrels" },
	{ "Clarified Agrithor Orys Frying Oil", "Wardens of the Fields of Callope", 2.35, "barrels" },
	{ "Golden Orys Salad Oil", "Wardens of the Fields of Callope", 0.42, "bottles" },
	{ "Agrithor Orys Lamp Oil", "Wardens of the Fields of Callope", 1.85, "barrels" },
	{ "Agrithor Orys Essential Oil", "Wardens of the Fields of Callope", 0.34, "vials" },
	{ "Orys Anointing Oil Base", "Wardens of the Fields of Callope", 0.30, "flasks" },
	{ "Orys Diffuser Oil", "Wardens of the Fields of Callope", 0.36, "vials" },
	{ "Orys Festival Oil Blend", "Wardens of the Fields of Callope", 0.44, "flasks" },
	{ "Orys Pine-Substitute Ritual Oil", "Wardens of the Fields of Callope", 0.28, "vials" },
	{ "Orys Cinnamon-Substitute Ritual Oil", "Wardens of the Fields of Callope", 0.31, "vials" },
	{ "Orys Rose-Substitute Ritual Oil", "Wardens of the Fields of Callope", 0.29, "vials" },
	{ "Orys Lettuce-Substitute Ritual Oil", "Wardens of the Fields of Callope", 0.27, "vials" },
	{ "Orys Oilcake Feed", "Wardens of the Fields of Callope", 0.88, "sacks" },
	{ "Agrithor Orys Seed Stock", "Wardens of the Fields of Callope", 1.95, "sacks" },
	{ "Orys Waxed Candle Base", "Wardens of the Fields of Callope", 0.52, "blocks" },
	{ "Pine-Scented Orys Candles", "Wardens of the Fields of Callope", 0.46, "bundles" },
	{ "Cinnamon-Scented Orys Candles", "Wardens of the Fields of Callope", 0.48, "bundles" },

---------------------------------------------------------
-- Southern Strait Foothill Partner Company
-- Lenaian Water Company
---------------------------------------------------------

	{ "Thal Qencha Watercress", "Lenaian Water Company", 5.80, "tons" },
	{ "Spring-Fed Watercress Bunches", "Lenaian Water Company", 0.34, "crates" },
	{ "Cold-Storage Mountain Greens", "Lenaian Water Company", 4.90, "tons" },
	{ "Snowholme Spring Lettuce", "Lenaian Water Company", 4.25, "tons" },
	{ "Thal Qencha Trout", "Lenaian Water Company", 7.60, "tons" },
	{ "Spring-Pond Trout", "Lenaian Water Company", 0.52, "crates" },
	{ "Smoked Thal Qencha Fish", "Lenaian Water Company", 0.64, "crates" },
	{ "Packed Ice-Box Produce", "Lenaian Water Company", 0.58, "crates" },
	{ "Inspected Mountain Food Shipments", "Lenaian Water Company", 6.40, "lots" },
	{ "Road-Market Fish Consignments", "Lenaian Water Company", 5.10, "lots" },
	{ "Clean Spring Water Casks", "Lenaian Water Company", 0.44, "casks" },
	{ "Foothill Herb and Cress Mix", "Lenaian Water Company", 0.38, "crates" },

---------------------------------------------------------
-- Southern Strait Desert Provisioning Company
-- Pontic Esperance Homestead Association
---------------------------------------------------------

	{ "Mirovian Cistern Melons", "Pontic Esperance Homestead Association", 4.95, "tons" },
	{ "Cistern-Grown Melon Crates", "Pontic Esperance Homestead Association", 0.46, "crates" },
	{ "Dryland Cucumbers", "Pontic Esperance Homestead Association", 3.85, "tons" },
	{ "Desert Cucumber Baskets", "Pontic Esperance Homestead Association", 0.36, "baskets" },
	{ "Preserved Desert Fruit", "Pontic Esperance Homestead Association", 0.58, "crates" },
	{ "Sun-Dried Melon Strips", "Pontic Esperance Homestead Association", 0.42, "packets" },
	{ "Mirovian Seed Oil", "Pontic Esperance Homestead Association", 2.55, "barrels" },
	{ "Pressed Desert Seed Oil", "Pontic Esperance Homestead Association", 0.44, "bottles" },
	{ "Packed Caravan Rations", "Pontic Esperance Homestead Association", 0.72, "boxes" },
	{ "Dry-Route Produce Hampers", "Pontic Esperance Homestead Association", 0.66, "hampers" },
	{ "Water-Accounted Produce Consignments", "Pontic Esperance Homestead Association", 5.75, "lots" },
	{ "Mirovia Ferry-Market Food Supply", "Pontic Esperance Homestead Association", 4.80, "lots" },
	{ "Cistern Ledger Melon Lots", "Pontic Esperance Homestead Association", 3.90, "lots" },
	{ "Caravan Cucumber Pickles", "Pontic Esperance Homestead Association", 0.39, "jars" },
	{ "Desert Fruit Preserves", "Pontic Esperance Homestead Association", 0.48, "jars" },

    ---------------------------------------------------------
    -- Southern Strait Central Highland Agricultural Market
    -- Nysaran Velai Farmers' League
    ---------------------------------------------------------
    { "Nysaran Terrace Beans", "Nysaran Velai Farmers' League", 2.65, "tons" },
    { "Snowholme Cold-Weather Tubers", "Nysaran Velai Farmers' League", 5.60, "tons" },
    { "Preserved Highland Root Stores", "Nysaran Velai Farmers' League", 0.58, "crates" },
    { "Dried Bean and Tuber Mix", "Nysaran Velai Farmers' League", 0.66, "crates" },

    { "Terrace Bean Seed Stock (certified)", "Nysaran Velai Farmers' League", 1.70, "sacks" },
    { "Cold-Weather Seed Tubers", "Nysaran Velai Farmers' League", 1.55, "sacks" },

    { "Nysaran Highland Sheep", "Nysaran Velai Farmers' League", 1.35, "head" },
    { "Nysaran Mutton", "Nysaran Velai Farmers' League", 4.25, "tons" },
    { "Salt-Cured Highland Mutton", "Nysaran Velai Farmers' League", 0.62, "crates" },

    { "Nysaran Highland Wool (raw)", "Nysaran Velai Farmers' League", 2.45, "bales" },
    { "Washed Nysaran Wool (Grade A)", "Nysaran Velai Farmers' League", 1.90, "bales" },
    { "Nysaran Wool Yarn (spun)", "Nysaran Velai Farmers' League", 2.05, "crates" },
    { "Highland Felt Bolts", "Nysaran Velai Farmers' League", 1.70, "bolts" },
    { "Wool Grease (rendered lanolin)", "Nysaran Velai Farmers' League", 1.35, "barrels" },

    { "Snowholme Fodder Bales", "Nysaran Velai Farmers' League", 12.40, "bales" },
    { "Pack-Animal Feed Mix", "Nysaran Velai Farmers' League", 0.82, "sacks" },
    { "Highland Animal Bedding", "Nysaran Velai Farmers' League", 11.60, "bales" },
    { "Mule-Train Provision Boxes", "Nysaran Velai Farmers' League", 0.68, "boxes" },

    { "Communal Granary Reserve Lots", "Nysaran Velai Farmers' League", 5.20, "lots" },
    { "Lacaran Hodos Upland Provision Lots", "Nysaran Velai Farmers' League", 5.60, "lots" },

	---------------------------------------------------------
	-- Saruq Thyrsa Specialty Livestock Company
	-- Reed Farms of the Upper Thyrsa
	---------------------------------------------------------

	{ "Live Maenic Snails (market-grade)", "Reed Farms of the Upper Thyrsa", 0.80, "head" },
	{ "Maenic Snail Meat (dressed)", "Reed Farms of the Upper Thyrsa", 4.60, "tons" },
	{ "Reed-Smoked Maenic Snail Meat", "Reed Farms of the Upper Thyrsa", 0.72, "crates" },
	{ "Thyrsan Brined Maenic Snail Meat", "Reed Farms of the Upper Thyrsa", 0.56, "jars" },
	{ "Salt-Cured Maenic Snail Eggs", "Reed Farms of the Upper Thyrsa", 0.32, "jars" },
	{ "Maenic Snail Broth Concentrate", "Reed Farms of the Upper Thyrsa", 0.48, "jars" },
	{ "Maenic Snail Mucin (apothecary grade)", "Reed Farms of the Upper Thyrsa", 0.28, "bottles" },
	{ "Cleaned Maenic Snail Shells", "Reed Farms of the Upper Thyrsa", 0.70, "crates" },
	{ "Maenic Shell Inlay Blanks", "Reed Farms of the Upper Thyrsa", 0.46, "crates" },
	{ "Maenic Shell Lime (fertilizer)", "Reed Farms of the Upper Thyrsa", 1.20, "sacks" },


    -- Kefayrûn Qarazir House
    -- Rumi-Kefaya, Eastern Mykonos
    -- Native Qarazir breeding, aviculture and agricultural exports

    { "Live Qarazir (standard farm stock)", "Kefayrûn Qarazir House", 0.78, "head" },
    { "Qarazir Breeding Pair", "Kefayrûn Qarazir House", 2.10, "pairs" },
    { "Qarazir Chicks (juvenile stock)", "Kefayrûn Qarazir House", 0.32, "head" },
    { "Qarazir Fertile Hatching Eggs", "Kefayrûn Qarazir House", 1.15, "crates" },
    { "Qarazir Table Eggs", "Kefayrûn Qarazir House", 0.68, "crates" },
    { "Qarazir Meat (dressed)", "Kefayrûn Qarazir House", 9.50, "tons" },
    { "Qarazir Meat (smoked)", "Kefayrûn Qarazir House", 1.85, "crates" },
    { "Qarazir Meat (salt-cured)", "Kefayrûn Qarazir House", 1.35, "crates" },
    { "Qarazir Rendered Fat", "Kefayrûn Qarazir House", 1.40, "barrels" },
    { "Qarazir Iridescent Feathers (sorted)", "Kefayrûn Qarazir House", 2.75, "bundles" },
    { "Qarazir White Crest Feathers", "Kefayrûn Qarazir House", 3.60, "bundles" },
    { "Qarazir Feather Plumes (ornamental grade)", "Kefayrûn Qarazir House", 4.25, "bundles" },
    { "Qarazir Leather (tanned)", "Kefayrûn Qarazir House", 3.25, "sheets" },
    { "Qarazir Leather Goods (craft blanks)", "Kefayrûn Qarazir House", 2.15, "crates" },
    { "Qarazir Eggshell Craft Blanks", "Kefayrûn Qarazir House", 0.85, "crates" },
    { "Qarazir Bone Meal (fertilizer)", "Kefayrûn Qarazir House", 0.95, "sacks" },
    { "Qarazir Feather Meal (fertilizer)", "Kefayrûn Qarazir House", 0.75, "sacks" },
    { "Qarazir Manure (composted)", "Kefayrûn Qarazir House", 0.45, "sacks" },


}

---------------------------------------------------------
---------------------------------------------------------
-- 2.5 City-Signal Integrations (WX / War / Hatch / Temple / Health)
---------------------------------------------------------
local forecastOk, forecast = pcall(require, "Module:BassaridiaForecast")
local warOk, war = pcall(require, "Module:WarLeagueDivisionOpsBVR")
local hatchOk, hatch = pcall(require, "Module:HatchMinistryDailyOps")
local outbreakOk, outbreaks = pcall(require, "Module:BassaridiaOutbreaks")

local function escapePattern(s)
	s = tostring(s or "")
	return s:gsub("([%%%^%$%(%)%.%[%]%*%+%-%?])", "%%%1")
end

-- Company HQ mapping (from General Port company table). For HQs that are not forecast cities,
-- city signals will simply not apply (safe fallback).
local companyHQOverrides = {
	["Gladeseed Farmers' Union"] = "Vaeringheim",
	["Atterian Cattle Drivers Company"] = "Somniumpolis",
	["Atterian Cattle Drivers"] = "Somniumpolis",
	["Keepers of the Grove of Zoe Elm"] = "Laceran Mountains",
	["Plains of Jogi"] = "Jogi",
	["Ale of the Night Central Brewery"] = "Jogi",
	["Camel Herders of the Jangsong Province"] = "Manduay region",
	["Grand Cave Bee Meadery"] = "Mylecia",
	["Cinnamon Plains of Rouge"] = "Rouge",
	["Cinammon Plains of Rouge"] = "Rouge",
	["Cinammon Plains of Roue"] = "Rouge",
	["Velvet Homestead"] = "Rouge",
	["The Velvet Company"] = "Rouge",
	["Commune of the Garganid Apostles"] = "Vaeringheim",
	["Salurian Temple of Sacred Horehound"] = "Saluria",
	["Bulhanu Ranchers' Association"] = "Somniumpolis",
	["Suncliff Fisheries"] = "Skýrophos",
	["Ministers of Mistress Mugwort"] = "Thorsalon",
	["Blood Vineyards of the Far North"] = "Thorsalon",
	["Norsolyrian Wisp Rice Farmers Association"] = "Norsolyra",
	["Giid-Lisea Ranching Import Company"] = "Pyralis",
	["Bird Keepers of Saluria"] = "Saluria",
	["Hellhound Breeders of Dragevik"] = "Dragevik",
	["Aminian Coffee Company"] = "Tel-Amin",
	["Knights Castle Reindeer Herders"] = "Riddersborg",
	["Lindley Whaling Company"] = "Ardclach",
	["Granadita Collective"] = "Eastern southern Strait coastal villages",
	["Herd Caton"] = "Catonis Atrium",
	["Wasp Hunters of the Austral Isles"] = "Austral Isles",
	["Sea-Elm Southern Meadery"] = "Blore Heath",
	["Nefel Village"] = "Jogi",
	["Diamonia Sugar Cooperatives"] = "Diamandis",
	["Ouriana Lowlands Farmers' Association"] = "Bashkim",
	["Ouriad River Fisheries Cooperative"] = "Ourid",
	["Caspazani Livestock Company"] = "Bashkim",
	["White Ruby Communes"] = "Notranskja",
	["Fange Velvet"] = "Fanghorn",
	["Lamian Ward"] = "Erythros",
	["Sleva Farming Supply Cooperatives"] = "Slevik",
	["Hrimmanes Woolhorse Company"] = "Eikbu",
	["King's Home Fur Trappers' Cooperative"] = "Elijah's Rest",
	["Caledonj Bay Fishermen’s’ Cooperatives"] = "Slevik",
	["Grove Synaxis of Tel-Amin"] = "Tel-Amin",
	["Wardens of the Fields of Callope"] = "Aureum",
["Pontic Esperance Homestead Association"] = "Mirovia",
["Nysaran Velai Farmers' League"] = "Nysara Velai",
	["Reed Farms of the Upper Thyrsa"] = "Saruq Thyrsa",

["Kefayrûn Qarazir House"] = "Rumi-Kefaya",




	-- Services/other companies that appear in the ag price list
	["Noctic Fleet"] = "", -- Fleet-based; no fixed city
	["Jogiani Merchants of Manwine"] = "Jogi",
	["Anterran Imports and Services"] = "Alphaville",
	["Merchant Guild of the Poppy Goddess"] = "Vaeringheim",
	["Hunters of the Giant Fanged Penguin"] = "Gulf of Jangsong",
	["Port of Corumia"] = "Corum",
	["Lenaian Water Company"] = "Thal Qencha",
}

-- Cities we can detect from names (extend freely).
local knownCities = {
	"Vaeringheim","Luminaria","Serena","Pyralis","Symphonara","Somniumpolis","Nexa",
	"Lunalis Sancta","Sylvapolis","Acheron","Erythros","Catonis Atrium","Jogi","Tel-Amin",
	"Lewisburg","Ardclach","Riddersborg","Slevik","Kaledonija","Skýrophos","Odiferia",
	"Ourid","Bashkim","Tonar","Diamandis","Keybir-Aviv","Thermosalem","Saluria",
	"Norsolyra","Rouge","Dragevik","Notranskja","Fanghorn","Eikbu","Sårensby","Aureum",
	"Mylecia","Nysara Velai","Ferrum Citadel","Delphica","Bjornopolis","New Kingsland","Storesund","Rumi-Kefaya",
}

local function inferHQCity(companyName)
	companyName = tostring(companyName or "")
	if companyHQOverrides[companyName] ~= nil then
		local v = companyHQOverrides[companyName]
		if v == "" then return nil end
		return v
	end
	for _, c in ipairs(knownCities) do
		if companyName == c then return c end
	end
	for _, c in ipairs(knownCities) do
		if companyName:find(c, 1, true) then return c end
	end
	-- Heuristics for common demonyms / aliases
	if companyName:find("Aminian", 1, true) then return "Tel-Amin" end
	return nil
end

local function productClass(productName)
    local n = (productName or ""):lower()

    -- Household and transport staples
    if n:find("rice")
        or n:find("wheat")
        or n:find("oats")
        or n:find("cereal")
        or n:find("hay")
        or n:find("bean")
        or n:find("tuber")
        or n:find("root store")
        or n:find("flour")
        or n:find("granary")
        or n:find("ration")
        or n:find("provision")
        or n:find("milk")
        or n:find("cheese")
        or n:find("butter")
        or n:find("meat")
        or n:find("mutton")
    then
        return "staple"
    end

    -- Agricultural and livestock inputs
    if n:find("fertilizer")
        or n:find("seed")
        or n:find("pellet")
        or n:find("inocul")
        or n:find("soil")
        or n:find("fodder")
        or n:find("feed")
        or n:find("bedding")
    then
        return "input"
    end

    -- Ritual and temple goods
    if n:find("ritual")
        or n:find("incense")
        or n:find("anoint")
        or n:find("sanctified")
        or n:find("temple")
    then
        return "ritual"
    end

    return "standard"
end

local function opsLevelToNumber(levelOrLabel)
	local n = tonumber(levelOrLabel)
	if n then return n end
	local t = tostring(levelOrLabel or ""):lower()
	if t:find("green") then return 0 end
	if t:find("yellow") then return 1 end
	if t:find("orange") then return 2 end
	if t:find("red") then return 3 end
	return 0
end

local function clamp(x, lo, hi)
	if x < lo then return lo end
	if x > hi then return hi end
	return x
end

local function getForecastSignal(city, year, dayOfYear)
	if not (forecastOk and forecast and type(forecast.getOpsData) == "function") then
		return { mult = 0, note = nil, opsLevel = 0 }
	end
	local op = forecast.getOpsData(city, year, dayOfYear)
	if not op or not op.alert or not op.impacts then
		return { mult = 0, note = nil, opsLevel = 0 }
	end

	local m = 0
	local ground = tostring(op.impacts.ground or "OK")
	local sea    = tostring(op.impacts.sea or "OK")
	local air    = tostring(op.impacts.air or "OK")

	-- supply friction by mode
	if ground == "Slow" then m = m + 0.02
	elseif ground == "Hazard" then m = m + 0.05
	elseif ground == "Closed" then m = m + 0.08 end

	if sea == "Restricted" then m = m + 0.03
	elseif sea == "Closed" then m = m + 0.06 end

	if air == "Limited" then m = m + 0.01
	elseif air == "No-Go" then m = m + 0.04 end

	-- condition bump
	local cond = tostring(op.condition or "")
	local lc = cond:lower()
	if lc:find("blizzard") then m = m + 0.05
	elseif lc:find("storm") then m = m + 0.03
	elseif lc:find("fog") then m = m + 0.02
	elseif lc:find("rain") then m = m + 0.01 end

	local opsLevel = opsLevelToNumber(op.alert.level)
	local note = string.format("WX/Ops %s (%s; G:%s S:%s A:%s)", tostring(op.alert.label or ""), cond, ground, sea, air)
	return { mult = m, note = note, opsLevel = opsLevel }
end

local function getWarLeagueSignalFromOps(opsLevel)
	-- baseline posture from Ops Alert
	local m = 0
	if opsLevel == 1 then m = 0.01
	elseif opsLevel == 2 then m = 0.03
	elseif opsLevel >= 3 then m = 0.06 end
	return { mult = m, note = (opsLevel > 0) and ("War posture +" .. string.format("%.0f%%", m*100)) or nil }
end

local function countCityInHatchReport(city, year, dayOfYear)
	if not (hatchOk and hatch and type(hatch.dailyReport) == "function") then
		return 0
	end
	local report = hatch.dailyReport({ args = { year = tostring(year), day = tostring(dayOfYear), legend = "no" } })
	report = tostring(report or "")
	local needle = "%[%[List_of_cities_in_Bassaridia_Vaeringheim#" .. escapePattern(city) .. "%|" .. escapePattern(city) .. "%]%]"
	local c = 0
	for _ in report:gmatch(needle) do c = c + 1 end
	return c
end

local function getHatchSignal(city, year, dayOfYear)
	local n = countCityInHatchReport(city, year, dayOfYear)
	if n <= 0 then return { mult = 0, note = nil } end
	local m = math.min(0.05, n * 0.005)
	local note = string.format("Hatch activity %d (≈+%.1f%%)", n, m*100)
	return { mult = m, note = note }
end

local function countCityInWarLeagueTable(city, seed)
	if not (warOk and war and type(war.makeTable) == "function") then
		return 0
	end
	local tbl = war.makeTable({ args = { rows = "36", seed = tostring(seed), showlegend = "no", flagsize = "0" } })
	tbl = tostring(tbl or "")
	local needle = "%[%[List_of_cities_in_Bassaridia_Vaeringheim#" .. escapePattern(city) .. "%|" .. escapePattern(city) .. "%]%]"
	local c = 0
	for _ in tbl:gmatch(needle) do c = c + 1 end
	return c
end

local function getWarLeagueSignal(city, seed)
	local n = countCityInWarLeagueTable(city, seed)
	if n <= 0 then return { mult = 0, note = nil } end
	-- mild friction per reported row involvement (cap)
	local m = math.min(0.06, n * 0.002)
	local note = string.format("War League activity %d (≈+%.1f%%)", n, m*100)
	return { mult = m, note = note }
end

local function parseOutbreakSeverity(outText)
	outText = tostring(outText or "")
	local sev = outText:match('style="background:[^"]+"%s*|%s*([A-Z]+)%s*||')
	if sev == "CRITICAL" or sev == "HIGH" or sev == "MEDIUM" or sev == "LOW" or sev == "NONE" then
		return sev
	end
	return "NONE"
end

local function getHealthSignal(city)
	if not (outbreakOk and outbreaks and type(outbreaks.outbreaksForCity) == "function") then
		return { mult = 0, severity = "NONE", note = nil }
	end
	local txt = outbreaks.outbreaksForCity({ args = { city = city } })
	local sev = parseOutbreakSeverity(txt)
	local m = 0
	if sev == "LOW" then m = 0.01
	elseif sev == "MEDIUM" then m = 0.03
	elseif sev == "HIGH" then m = 0.06
	elseif sev == "CRITICAL" then m = 0.10 end
	local note = (sev ~= "NONE") and ("Health " .. sev .. " (≈+" .. string.format("%.0f%%", m*100) .. ")") or nil
	return { mult = m, severity = sev, note = note }
end

local function getTempleBankSignal(pClass, healthSeverity, opsLevel)
	-- Temple Bank behavior: stabilize staples during health/ops stress; allow non-staples to rise.
	local crisis = (healthSeverity == "MEDIUM" or healthSeverity == "HIGH" or healthSeverity == "CRITICAL" or (tonumber(opsLevel) or 0) >= 2)
	if not crisis then return { mult = 0, note = nil } end
	local m = 0
	if pClass == "staple" then
		if healthSeverity == "CRITICAL" then m = -0.06
		elseif healthSeverity == "HIGH" then m = -0.04
		else m = -0.02 end
		if (tonumber(opsLevel) or 0) >= 3 then m = m - 0.01 end
		return { mult = m, note = string.format("Temple Bank stabilization (%.0f%%)", m*100) }
	else
		if healthSeverity == "CRITICAL" then m = 0.04
		elseif healthSeverity == "HIGH" then m = 0.03
		else m = 0.015 end
		if (tonumber(opsLevel) or 0) >= 3 then m = m + 0.01 end
		return { mult = m, note = string.format("Temple Bank overhead (+%.0f%%)", m*100) }
	end
end
-- 3. Special Date Events
---------------------------------------------------------
local events = {
	["1,6"]  = "Bayram al-Nur (Festival of Light) [Vaeringheim]",
	["1,18"] = "Chag Or Hadash (Festival of New Light) [Luminaria]",
	["1,30"] = "Symposion Eirinis (Symposium of Harmony) [Serena]",
	["1,43"] = "Alev Günü (Day of Flame) [Pyralis]",
	["1,48"] = "Day of Abandonment [Vaeringheim]",
	["1,55"] = "Tikkun Tzel (Repair of Shadows) [Symphonara]",
	["2,6"]  = "Panegyris Chrysou (Golden Gathering) [Aurelia]",
	["2,17"] = "Constitution Day [Luminaria]",
	["2,19"] = "Mehtap Dalgası (Moonlit Tide) [Vaeringheim]",
	["2,31"] = "Oneiro Foteino (Dream of Illumination) [Somniumpolis]",
	["2,39"] = "Anniversary of victory in the New South Jangsong Campaign [Nexa]",
	["2,44"] = "Erev Galgal (Eve of Cycles) [Nexa]",
	["2,45"] = "Bassaridia Festival [Somniumpolis]",
	["2,48"] = "Anniversary of victory in the Southern Lake Morovia Campaign [Somniumpolis]",
	["2,54"] = "Leilat al-Kamar (Night of the Moon) [Lunalis Sancta]",
	["2,61"] = "Taşrakah (Reverence of the Stone) [Luminaria]",
	["3,6"]  = "Chag Tvuah (Festival of Harvest) [Sylvapolis]",
	["3,18"] = "Anagenesis Eirmos (Procession of Rebirth) [Acheron]",
	["3,28"] = "Panagia Therizis (Holy Day of the Reaper) [Sylvapolis]",
	["3,37"] = "Anniversary of victory in the Morovian Frontier Campaign [Acheron]",
	["3,43"] = "Karnavali Thysias (Carnival of Celebration) [Erythros]",
	["3,53"] = "Sefar Yashar (Straight Path Celebration) [Catonis Atrium]",
}

---------------------------------------------------------
-- 4. simulatePriceChange
--    Randomly modifies the base price daily,
--    applying a slight additional boost if
--    a special event occurs on that dateKey.
---------------------------------------------------------
local function simulatePriceChange(basePrice, dayOfMonth, month, psscYear, dayOfYear, city, productName, companyName, dailySeed)
	local dateKey = string.format("%d,%d", month, dayOfMonth)
	local changeFactor = math.random(-20, 20) / 100
	local explanationParts = {}

	if events[dateKey] then
		changeFactor = changeFactor + 0.05 -- small boost for special events
		table.insert(explanationParts, events[dateKey] .. ": Prices influenced by event dynamics")
	else
		table.insert(explanationParts, "General market fluctuations")
	end

	-- City-driven signals (weather, War League, Hatch, public health, Temple Bank)
	local notes = {}
	city = tostring(city or "")
	local pClass = productClass(productName)
	local cityAdd = 0

	if city ~= "" then
		local wx = getForecastSignal(city, psscYear, dayOfYear)
		cityAdd = cityAdd + (wx.mult or 0)
		if wx.note then table.insert(notes, wx.note) end

		local wl0 = getWarLeagueSignalFromOps(wx.opsLevel or 0)
		cityAdd = cityAdd + (wl0.mult or 0)
		if wl0.note then table.insert(notes, wl0.note) end

		-- War League operations table (deterministic, date-seeded)
		local wl = getWarLeagueSignal(city, dailySeed)
		cityAdd = cityAdd + (wl.mult or 0)
		if wl.note then table.insert(notes, wl.note) end

		local hm = getHatchSignal(city, psscYear, dayOfYear)
		cityAdd = cityAdd + (hm.mult or 0)
		if hm.note then table.insert(notes, hm.note) end

		local ph = getHealthSignal(city)
		cityAdd = cityAdd + (ph.mult or 0)
		if ph.note then table.insert(notes, ph.note) end

		local tb = getTempleBankSignal(pClass, ph.severity or "NONE", wx.opsLevel or 0)
		cityAdd = cityAdd + (tb.mult or 0)
		if tb.note then table.insert(notes, tb.note) end
	end

	cityAdd = clamp(cityAdd, -0.20, 0.20)
	changeFactor = clamp(changeFactor + cityAdd, -0.35, 0.35)

	if #notes > 0 then
		table.insert(explanationParts, "Local signals: " .. table.concat(notes, "; "))
	end

	local explanation = table.concat(explanationParts, ". ") .. "."
	local newPrice = math.floor((basePrice * (1 + changeFactor)) * 100) / 100
	return newPrice, changeFactor, explanation
end

---------------------------------------------------------
-- 5. determinePriceLevel
--    Swapped so that:
--      adjustedPrice > basePrice ⇒ "Low"
--      adjustedPrice < basePrice ⇒ "High"
--      otherwise ⇒ "Standard"
---------------------------------------------------------
local function determinePriceLevel(basePrice, adjustedPrice)
	if adjustedPrice > basePrice then
		return "Low"
	elseif adjustedPrice < basePrice then
		return "High"
	else
		return "Standard"
	end
end

---------------------------------------------------------
-- Args helpers (for modes)
---------------------------------------------------------
local function getArgs(frame)
	if type(frame) ~= "table" then
		return {}
	end

	local args = {}
	local fargs = frame.args or {}

	local pargs = {}
	if frame.getParent then
		local parent = frame:getParent()
		if parent and parent.args then
			pargs = parent.args
		end
	end

	for k, v in pairs(pargs) do
		if v ~= nil and v ~= "" then
			args[k] = v
		end
	end
	for k, v in pairs(fargs) do
		if v ~= nil and v ~= "" then
			args[k] = v
		end
	end

	return args
end

local function isNo(v)
	v = tostring(v or ""):lower()
	return (v == "no" or v == "n" or v == "false" or v == "0")
end

local function levelSymbol(priceLevel)
	if priceLevel == "Low" then
		return "↑"
	elseif priceLevel == "High" then
		return "↓"
	else
		return "•"
	end
end

---------------------------------------------------------
-- 5.5 Consumer price helpers
--    Converts the Port agricultural ledger into ordinary
--    household market prices. The ledger values are units
--    redeemable per poli, so consumer prices move inversely:
--    higher adjusted quantity per poli = lower retail price.
---------------------------------------------------------
local productLookup = nil

local function getProductByName(name)
	if productLookup == nil then
		productLookup = {}
		for _, product in ipairs(products) do
			productLookup[product[1]] = product
		end
	end
	return productLookup[name]
end

local function formatConsumerPriceFromNil(totalNil)
	totalNil = math.floor((tonumber(totalNil) or 0) + 0.5)
	if totalNil < 1 then totalNil = 1 end

	local poli = math.floor(totalNil / 200)
	local rem = totalNil % 200
	local sik = math.floor(rem / 10)
	local nilCoins = rem % 10

	local parts = {}
	if poli > 0 then table.insert(parts, tostring(poli) .. "₱̈") end
	if sik > 0 then table.insert(parts, tostring(sik) .. "Ƨ̈") end
	if nilCoins > 0 then table.insert(parts, tostring(nilCoins) .. "•") end
	if #parts == 0 then return "1•" end
	return table.concat(parts, " ")
end

local function consumerRow(productName, consumerUse, retailUnit, baseNil, note)
	return {
		productName = productName,
		consumerUse = consumerUse,
		retailUnit = retailUnit,
		baseNil = baseNil,
		note = note or ""
	}
end

local consumerCatalog = {
	-- Core staples and grain goods
	consumerRow("Rice", "Daily grain staple", "1 kg sack", 25, "Core voucher staple and one of the most common household goods."),
	consumerRow("Wisp Rice", "Specialty rice, porridge, festival meals", "1 kg sack", 40, "Northern specialty rice."),
	consumerRow("Wisp Rice Flour (milled)", "Baking, noodles, porridge", "1 kg sack", 35, "Processed form of Wisp Rice."),
	consumerRow("Wisp Rice Noodles (dried)", "Quick meals and soups", "500 g packet", 30, "Shelf-stable noodle packet."),
	consumerRow("Wisp Rice Cakes (pressed)", "Snack and travel food", "small box", 25, "Prepared rice snack."),
	consumerRow("Wisp Rice Porridge Mix (packaged)", "Breakfast food", "500 g packet", 20, "Common morning food."),
	consumerRow("Wheat", "Bread, flour, flatbread", "1 kg sack", 20, "Jogi grain staple."),
	consumerRow("Oats", "Porridge and breakfast", "1 kg sack", 18, "Cheap everyday grain."),
	consumerRow("Cereal", "Breakfast meal and ration cakes", "1 kg packet", 22, "Basic household grain blend."),
	consumerRow("Granary Flour (stone-milled)", "Household baking", "1 kg sack", 25, "Retail flour from Salain's Landing."),
	consumerRow("Barley Flour (milled)", "Baking, thickening, porridge", "1 kg sack", 20, "Common baking and soup good."),
	consumerRow("Granary Biscuit Rations", "Travel food, worker lunch", "1 box", 30, "Durable ration box."),
	consumerRow("Cold-Steppe Barley", "Soup, porridge, brewing", "1 kg sack", 20, "Ouriana staple grain."),
	consumerRow("Proso Millet", "Porridge, flatbread", "1 kg sack", 18, "Cheap small grain."),
	consumerRow("Buckwheat", "Pancakes, porridge, noodles", "1 kg sack", 25, "Cold-region household grain."),
	consumerRow("Cold-Hardy Lentils", "Stews and protein supplement", "1 kg sack", 25, "High-value pulse crop."),
	consumerRow("Beans", "Stews and household meals", "1 kg sack", 25, "Common household protein."),
	consumerRow("maize", "Meal, porridge, cakes", "1 kg sack", 20, "Granadita household staple."),

	-- Vegetables, herbs, and cooking plants
	consumerRow("Edible Algae", "Soups, patties, preserved food", "500 g bundle", 12, "Morovian canal and wetland staple."),
	consumerRow("Anterran Spicy Onion", "Cooking base", "500 g bundle", 15, "Flavor base for everyday cooking."),
	consumerRow("Queen's Garlic", "Cooking, medicine, sauces", "250 g braid", 15, "Household kitchen and medicinal good."),
	consumerRow("Potatoes", "Staple vegetable", "2 kg sack", 25, "Basic Caledonian vegetable staple."),
	consumerRow("White Beets", "Soups and pickles", "1 kg basket", 20, "Useful in soups and preserved foods."),
	consumerRow("Onions", "Cooking base", "1 kg sack", 15, "Basic cooking vegetable."),
	consumerRow("Cabbage", "Soup, pickles, stews", "1 head", 12, "Cheap fresh vegetable."),
	consumerRow("Garlic Bulbs", "Cooking and household medicine", "1 bundle", 15, "Common household purchase."),
	consumerRow("Dill", "Pickles, soups, fish dishes", "small bundle", 8, "Daily herb."),
	consumerRow("Parsley", "Garnish and cooking herb", "small bundle", 8, "Daily herb."),
	consumerRow("Wild Juniper Berries", "Seasoning and preserves", "small packet", 15, "Specialty seasoning."),
	consumerRow("Thyme Bush Cuttings", "Cooking herb", "small bundle", 8, "Daily herb."),
	consumerRow("Lettuce", "Fresh salad and wraps", "1 head", 12, "Fresh vegetable."),
	consumerRow("Assorted Vegetables", "General household cooking", "1 kg basket", 25, "Mixed market vegetables."),
	consumerRow("Mountain Sorrel", "Soups and sour greens", "small bundle", 10, "Fresh sour green."),
	consumerRow("Steppe Rhubarb", "Stewed sweets and preserves", "500 g bundle", 20, "Seasonal tart vegetable."),

	-- Meat, seafood, and preserved proteins
	consumerRow("Shrimp", "Rice dishes and stews", "500 g basket", 35, "Frequent fresh protein."),
	consumerRow("Atterian Armored Pufferfish", "Specialty fish", "500 g dressed portion", 65, "Usually prepared by approved sellers."),
	consumerRow("Morovian Saucer Eyed Giant Eel", "Patties, smoked eel, festival meals", "500 g portion", 50, "Named eel product from the ledger."),
	consumerRow("Amina Crab", "Stews and market meals", "500 g portion", 60, "Fresh crab portion."),
	consumerRow("Fresh Tuna", "Fresh fish", "500 g portion", 50, "Fresh imported fish."),
	consumerRow("Canned Tuna", "Shelf-stable household protein", "1 tin", 20, "Everyday preserved fish."),
	consumerRow("Fish", "Everyday fish meals", "500 g portion", 30, "General fish category."),
	consumerRow("Highland Grayling", "Fresh fish", "500 g portion", 40, "Ourid river fish."),
	consumerRow("Mountain Whitefish", "Fresh fish", "500 g portion", 35, "Ourid river fish."),
	consumerRow("Brown Trout", "Fresh fish, smoked fish", "500 g portion", 45, "Higher-value river fish."),
	consumerRow("Salted Lamprey Filets", "Preserved fish", "250 g packet", 30, "Shelf-stable fish."),
	consumerRow("Smoked Burbot", "Preserved fish", "250 g packet", 30, "Smoked fish packet."),
	consumerRow("Morovian Water Buffalo Beef", "Household meat, special meals", "500 g cut", 85, "Common upgrade beyond baseline ration goods."),
	consumerRow("Camel Meat", "Stews and dried strips", "500 g portion", 60, "Jangsong-linked protein."),
	consumerRow("Sea Cow Beef", "Stews and preserved meat", "500 g cut", 75, "Somniumpolis-linked ranching product."),
	consumerRow("Sea Cow Jerky (salted strips)", "Travel food and snacks", "250 g packet", 40, "Preserved meat."),
	consumerRow("Sea Cow Sausage (smoked)", "Smoked household protein", "500 g link", 70, "Smoked sausage."),
	consumerRow("Giid-Lisea-Eda Beef", "Imported red meat", "500 g cut", 90, "Higher-status imported meat."),
	consumerRow("Frozen Mammoth Steaks", "Luxury meat", "250 g portion", 80, "Luxury frozen cut."),
	consumerRow("Giid-Lisea Jerky (salted)", "Travel food", "250 g slab", 50, "Imported preserved meat."),
	consumerRow("Vaeringheim Turkey Meat", "Poultry meals", "500 g portion", 60, "Common poultry meat."),
	consumerRow("Salurian Swamp Quail Eggs", "Breakfast, baking, pickles", "12 eggs", 30, "Small premium eggs."),
	consumerRow("Smoked Turkey Strips (trail packs)", "Trail food and snacks", "250 g packet", 40, "Preserved poultry."),
	consumerRow("Reindeer Meat", "Northern meat, stews", "500 g portion", 60, "Northern meat product."),
	consumerRow("Smoked Venison (Cold-Steppe Cure)", "Preserved meat", "250 g packet", 45, "Cold-steppe preserved meat."),
	consumerRow("Seal Meat", "Northern preserved protein", "500 g portion", 50, "Northern protein."),
	consumerRow("Whale Meat", "Preserved northern protein", "500 g portion", 70, "High-value northern protein."),
	consumerRow("Caledonj Deep-Bay Lobster", "Special seafood meal", "500 g portion", 100, "Luxury seafood."),
	consumerRow("Pickled Lobster Claws (Spiced)", "Preserved seafood", "1 jar", 60, "Specialty jarred seafood."),
	consumerRow("Lobster Broth Concentrate", "Soup base", "1 bottle", 50, "Prepared soup base."),
	consumerRow("Velvet Worm Meat", "Specialty protein", "250 g portion", 40, "Rouge specialty protein."),
	consumerRow("Smoked Velvet Worm Strips", "Snack, breakfast hash", "250 g slab", 50, "Prepared specialty protein."),
	consumerRow("Velvet Worm Broth Concentrate", "Soup base", "1 jar", 40, "Prepared broth concentrate."),
	consumerRow("Live Maenic Snails (market-grade)", "Fresh cooking, market meals, festival dishes", "1 live snail", 45, "Large native snail raised in the reed farms of Saruq Thyrsa."),
	consumerRow("Maenic Snail Meat (dressed)", "Stews, grilling, roasting, and market meals", "500 g dressed portion", 55, "Fresh dressed meat from farmed Maenic Snails."),
	consumerRow("Reed-Smoked Maenic Snail Meat", "Preserved protein, snacks, and travel food", "250 g packet", 45, "Maenic Snail meat traditionally smoked over dried Thyrsan reeds."),
	consumerRow("Thyrsan Brined Maenic Snail Meat", "Preserved food, mezze, stews, and market meals", "1 jar", 40, "Brined Maenic Snail meat prepared for household and ferry-market sale."),
	consumerRow("Salt-Cured Maenic Snail Eggs", "Delicacy, festival food, and garnish", "small jar", 75, "Salt-cured eggs from farmed Maenic Snails; a high-value Saruq delicacy."),
	consumerRow("Maenic Snail Broth Concentrate", "Soups, sauces, stews, and cooking stock", "1 jar", 35, "Concentrated broth produced from Maenic Snail processing."),

	-- Milk, cheese, butter, fats, and oils
	consumerRow("Morovian Water Buffalo Milk (raw)", "Drinking and cooking", "1 liter", 15, "Everyday dairy."),
	consumerRow("Morovian Water Buffalo Milk (cultured)", "Breakfast, sauces, cooking", "500 ml jar", 18, "Cultured dairy."),
	consumerRow("Morovian Water Buffalo Cheese (aged wheels)", "Bread, meals, snacks", "250 g wedge", 30, "Aged cheese wedge."),
	consumerRow("Morovian Water Buffalo Butter (salted)", "Cooking and bread", "250 g block", 25, "Salted butter."),
	consumerRow("Camel Milk", "Drinking and cultured dairy", "1 liter", 25, "Specialized dairy."),
	consumerRow("Sea Cow Milk (raw)", "Drinking and cooking", "1 liter", 20, "Raw dairy."),
	consumerRow("Sea Cow Cheese (aged wheels)", "Meals and snacks", "250 g wedge", 35, "Aged cheese."),
	consumerRow("Sea Cow Butter (salted)", "Cooking", "250 g block", 25, "Salted butter."),
	consumerRow("Sea Cow Oil (lamp/cooking grade)", "Lamp and cooking oil", "500 ml bottle", 30, "Dual household oil."),
	consumerRow("Cream Butter", "Cooking and bread", "250 g block", 30, "Imported cream butter."),
	consumerRow("Aged Cheese", "Table cheese", "250 g wedge", 40, "Imported aged cheese."),
	consumerRow("Rendered Poultry Fat (cooking)", "Cooking fat", "250 g jar", 20, "Rendered fat."),
	consumerRow("Pressed Sunflower Oil", "Cooking oil", "500 ml bottle", 30, "Household cooking oil."),
	consumerRow("Assorted Oils", "Cooking oil", "500 ml bottle", 30, "Mixed cooking oil."),
	consumerRow("Hemp Oil", "Cooking, lamp, salve base", "250 ml bottle", 35, "Specialty oil."),
	consumerRow("Whale Oil", "Lamp oil", "500 ml flask", 25, "Northern lamp oil."),
	consumerRow("Seal Oil", "Lamp oil and northern cooking use", "500 ml flask", 20, "Northern oil."),

	-- Fruit, sugar, honey, sweets, and preserves
	consumerRow("Tropical Fruit", "Fresh fruit", "1 kg basket", 40, "Southern fruit basket."),
	consumerRow("Melusinian Orchard Apples (fresh)", "Fresh fruit", "1 kg basket", 30, "Fresh Tel-Amin apples."),
	consumerRow("Coral-Grove Dried Apple Rings", "Snack and travel food", "250 g packet", 25, "Dried fruit snack."),
	consumerRow("Spiced Apple Preserves", "Breakfast and sweets", "1 jar", 30, "Preserved apple jar."),
	consumerRow("Tel-Amin Apple Butter", "Bread spread", "1 jar", 30, "Apple spread."),
	consumerRow("Cave Honey (strained)", "Sweetener and medicine", "250 g jar", 35, "Household honey."),
	consumerRow("Coffee Blossom Honey (grove-hive harvest)", "Sweetener and specialty honey", "250 g jar", 40, "Specialty honey."),
	consumerRow("Apolline Apple Blossom Honey", "Sweetener and offering", "250 g jar", 40, "Orchard honey."),
	consumerRow("Raw Cane Sugar", "Sweetener", "500 g packet", 20, "Basic sweetener."),
	consumerRow("Refined White Sugar", "Sweetener and baking", "500 g packet", 25, "Refined sugar."),
	consumerRow("Brown Sugar", "Baking and sauces", "500 g packet", 20, "Basic baking sugar."),
	consumerRow("Molasses", "Baking and sweetener", "250 ml jar", 20, "Dark sweetener."),
	consumerRow("Rock Sugar Crystals", "Tea and sweets", "250 g packet", 25, "Tea sugar."),
	consumerRow("Sugar Loaves", "Household sweetener", "1 small loaf", 30, "Block sugar."),
	consumerRow("Candied Citrus Peel", "Baking and sweets", "250 g packet", 30, "Sweet baking good."),
	consumerRow("Sweet Tea Cakes", "Snack and hospitality", "1 box", 30, "Prepared sweet."),
	consumerRow("Poppy Honey Cakes (market tins)", "Sweet market food", "1 tin", 40, "Prepared poppy sweet."),
	consumerRow("Honey Cakes (sealed tins)", "Snack and festival food", "1 box", 30, "Prepared honey sweet."),
	consumerRow("Sea Elm Honey Cakes (packaged)", "Snack and gift food", "1 box", 35, "Prepared meadery sweet."),
	consumerRow("Noctic Flower Lokum (sweet export)", "Sweet, gift, festival treat", "1 small box", 60, "Discretionary comfort item."),
	consumerRow("Horehound Candies (wrapped)", "Sweet and medicinal candy", "1 box", 30, "Medicinal sweet."),

	-- Beverages and drink goods
	consumerRow("Coffee", "Daily drink", "250 g packet", 40, "Basic coffee."),
	consumerRow("Tel-Amin Medium Roast (whole bean)", "Household coffee", "250 g packet", 50, "Roasted coffee."),
	consumerRow("Tel-Amin Dark Roast (whole bean)", "Household coffee", "250 g packet", 55, "Dark roast coffee."),
	consumerRow("Stone-Ground Coffee (fine powder)", "Fine coffee powder", "250 g packet", 50, "Ground coffee."),
	consumerRow("Cold-Brew Coffee Concentrate (bottled)", "Bottled coffee drink base", "1 bottle", 40, "Prepared coffee base."),
	consumerRow("Sweetened Coffee Syrup (for desserts/drinks)", "Dessert and drink syrup", "1 bottle", 40, "Coffee syrup."),
	consumerRow("Cascara Tea (coffee-cherry husk infusion)", "Tea infusion", "100 g packet", 30, "Coffee-cherry tea."),
	consumerRow("Horehound Tea (dried leaves)", "Tea and household medicine", "1 pack", 20, "Medicinal tea."),
	consumerRow("Horehound Syrup (cough blend)", "Cough blend and sweet drink base", "1 bottle", 40, "Medicinal syrup."),
	consumerRow("Camel Hump Water Tea", "Tea and refreshment", "1 bottle", 25, "Jangsong refreshment."),
	consumerRow("Apolline Apple Cider (sweet)", "Household drink", "1 bottle", 30, "Sweet cider."),
	consumerRow("Mead", "Adult drink", "1 bottle", 40, "Common mead."),
	consumerRow("Sea Elm Flavored Mead", "Adult drink and festival drink", "1 bottle", 45, "Sea-Elm mead."),
	consumerRow("Manwine", "Adult drink and cooking", "1 bottle", 50, "Jogiani specialty drink."),
	consumerRow("Ale of the Night", "Adult drink", "1 tankard or bottle", 25, "Common ale."),
	consumerRow("Horehound Beer", "Adult drink", "1 bottle", 30, "Horehound beer."),
	consumerRow("Blood InfusedRed Wine", "Adult drink, ritual hospitality", "1 bottle", 60, "Northern vineyard wine."),
	consumerRow("Wine Vinegar (barrel aged)", "Cooking vinegar", "500 ml bottle", 20, "Wine vinegar."),
	consumerRow("Manwine Vinegar (culinary)", "Cooking vinegar", "500 ml bottle", 20, "Manwine vinegar."),
	consumerRow("Apple Vinegar of the Fossil Fields", "Cooking and pickling", "500 ml bottle", 20, "Apple vinegar."),
	consumerRow("Wisp Rice Vinegar (fermented)", "Cooking vinegar", "500 ml bottle", 25, "Rice vinegar."),

	-- Spices, botanicals, medicine, and ritual goods
	consumerRow("Noctic-Rabrev Culinary Spice Blend", "Cooking and festival food", "small tin", 45, "Noctic culinary good."),
	consumerRow("Dried Noctic-Rabrev Petals", "Tea, ritual, flavoring", "small packet", 50, "Ritual botanical."),
	consumerRow("Noctic Tincture (therapeutic dosage)", "Therapeutic dosage", "1 vial", 50, "Therapeutic product."),
	consumerRow("Noctic-Rabrev Infused Incense", "Household shrine and temple use", "1 pack", 30, "Ritual incense."),
	consumerRow("Noctic-Rabrev Anointing Balm", "Ritual and medicinal balm", "1 jar", 40, "Ritual balm."),
	consumerRow("Noctic-Rabrev Ritual Ink", "Written prayers, charms, records", "1 bottle", 50, "Ritual writing good."),
	consumerRow("Ground Mugwort", "Tea, medicine, ritual", "small packet", 20, "Medicinal herb."),
	consumerRow("Mugwort Oil", "Salve, lamp, ritual use", "small flask", 40, "Mugwort oil."),
	consumerRow("Mugwort Tincture", "Apothecary use", "1 vial", 40, "Medicinal tincture."),
	consumerRow("Poppy Seeds (culinary)", "Baking and garnish", "250 g packet", 20, "Culinary poppy."),
	consumerRow("Poppy Seed Oil (pressed)", "Cooking oil", "250 ml bottle", 30, "Pressed oil."),
	consumerRow("Poppy Petal Tea (non-potent herbal)", "Non-potent herbal tea", "1 pack", 20, "Household tea."),
	consumerRow("Poppy Incense Cones (temple blend)", "Temple and household shrine", "1 pack", 30, "Ritual incense."),
	consumerRow("Poppy Wreath Garlands (festival)", "Festival decoration", "1 bundle", 30, "Festival good."),
	consumerRow("Horehound Tincture (apothecary)", "Apothecary use", "1 vial", 40, "Medicinal tincture."),
	consumerRow("Horehound Incense (ritual sticks)", "Ritual sticks", "1 bundle", 20, "Ritual incense."),
	consumerRow("Horehound Salve (chest rub)", "Chest rub and household medicine", "1 jar", 40, "Household medicine."),
	consumerRow("Horehound Herb Bundles (fresh)", "Fresh herb, tea, ritual", "1 bundle", 15, "Fresh herb bundle."),
	consumerRow("Velvet Antler Soap", "Bathing and medicinal grooming", "1 bar", 40, "Specialty soap."),
	consumerRow("Velvet Antler Salve", "Balm and apothecary use", "1 jar", 50, "Specialty salve."),
	consumerRow("Luxury Antler Infused Tea", "Specialty tea", "1 canister", 60, "Luxury tea."),
	consumerRow("Trapper’s Tallow Soap (Pine & Resin Blend)", "Bathing and washing", "1 bar", 25, "Frontier soap."),
	consumerRow("Agrithor Orys Flour", "Flatbread, porridge, thickening", "1 kg sack", 30, "Food-grade Orys flour from Aureum."),
	consumerRow("Agrithor Orys Porridge Meal", "Breakfast porridge and household meals", "500 g packet", 22, "Everyday food product from Agrithor Orys grain."),
	consumerRow("Pressed Agrithor Orys Cooking Oil", "Cooking oil", "500 ml bottle", 35, "Common cooking oil; valuable substitute for more distant imported oils."),
	consumerRow("Golden Orys Salad Oil", "Finishing oil and cold dishes", "250 ml bottle", 40, "Higher-grade table oil."),
	consumerRow("Agrithor Orys Essential Oil", "Fragrance, household shrine, oil blending", "small vial", 55, "Concentrated Orys oil for non-medical household and ritual use."),
	consumerRow("Orys Anointing Oil Base", "Ritual oil base", "small flask", 60, "Used by oil-blenders as a local substitute base for costly traditional Stripping Path oils."),
	consumerRow("Orys Diffuser Oil", "Household fragrance and shrine diffusion", "small vial", 45, "Nightly diffusion and festival fragrance oil."),
	consumerRow("Orys Festival Oil Blend", "Festival lamps, ritual scent, domestic worship", "small flask", 65, "Prepared festival oil blend."),
	consumerRow("Orys Waxed Candle Base", "Candle-making and household shrine use", "small block", 35, "Useful for candles and oil-lamp preparation."),
	consumerRow("Pine-Scented Orys Candles", "Household light and shrine scent", "1 bundle", 35, "Everyday alternative to pine-scented oil sacraments."),
	consumerRow("Cinnamon-Scented Orys Candles", "Household light and shrine scent", "1 bundle", 38, "Everyday alternative to cinnamon-scented oil sacraments."),

	-- Household materials, clothing, repair, and domestic craft goods
	consumerRow("Beeswax Candles (standard)", "Light and shrine use", "1 bundle", 30, "Household candles."),
	consumerRow("Sea Elm Beeswax Candles (meadery grade)", "Light and ritual use", "1 bundle", 35, "Meadery-grade candles."),
	consumerRow("Mammoth Fat Candles", "Heavy household candles", "1 candle", 25, "Heavy candle."),
	consumerRow("Penguin Fat Candles (cold-weather)", "Cold-weather candles", "1 bundle", 50, "Northern candle bundle."),
	consumerRow("Velvet Worm Silk Thread (spools)", "Sewing and repair", "1 spool", 30, "Specialty thread."),
	consumerRow("Raw Silk Thread (spools)", "Sewing and embroidery", "1 spool", 40, "Silk thread."),
	consumerRow("Woven Silk Sashes", "Dress, festival wear", "1 sash", 80, "Silk clothing good."),
	consumerRow("Embroidered Veils (festival)", "Festival clothing", "1 veil", 120, "Festival garment."),
	consumerRow("Silk Patch Kits (repair)", "Clothing repair", "1 kit", 30, "Repair kit."),
	consumerRow("Cotton", "Cloth, household textile", "small bolt", 100, "Textile good."),
	consumerRow("Wool", "Clothing and blankets", "small bundle", 80, "Textile good."),
	consumerRow("Woolhorse Spun Yarn (dk/worsted, 50 kg)", "Knitting, repair, winter clothes", "small skein", 40, "Winter textile good."),
	consumerRow("Woolhorse Felt Bolts (10 m x 1.4 m)", "Boots, cloaks, padding", "small folded piece", 80, "Felt good."),
	consumerRow("Feather Quilting Fill (cleaned)", "Bedding repair", "small sack", 60, "Bedding good."),
	consumerRow("Mother-of-Pearl Buttons (sorted)", "Clothing repair and ornament", "small packet", 30, "Clothing ornament."),
	consumerRow("Pearl Thread Strands (drilled)", "Jewelry and festival dress", "1 strand", 80, "Adornment good."),
	consumerRow("Abalone Shell Inlay Blanks", "Craft and ornament", "small packet", 50, "Craft good."),
	consumerRow("Applewood Smoking Chips", "Cooking smoke and preservation", "1 sack", 20, "Kitchen fuel/flavoring."),
	consumerRow("Zoe Elm Wood Oil (polish & sealant)", "Polish and sealant", "1 bottle", 40, "Domestic maintenance good."),
	consumerRow("Zoe Elm Incense Resin (temple blend)", "Temple and household incense", "1 pack", 30, "Incense resin."),

	-- Adult discretionary goods
	consumerRow("Nocticine Silk-Wrap Cigarettes (20-count)", "Adult discretionary use", "20-count pack", 70, "Adult nocticine good."),
	consumerRow("Caravan Reserve Noctic Cigars (hand-rolled)", "Adult discretionary use", "1 stick", 30, "Adult nocticine good."),
	consumerRow("Pocket-Press Noctic Chew Pouches (minted)", "Adult discretionary use", "1 tin", 50, "Adult nocticine good."),
	consumerRow("Hand-Cured Nefel Leaf Cigarettes (20-count)", "Adult discretionary use", "20-count pack", 65, "Adult tobacco good."),
	consumerRow("Village Reserve Tobacco Cigars (oak-aged)", "Adult discretionary use", "1 stick", 40, "Adult tobacco good."),
	consumerRow("Sun-Dried Pipe Tobacco (long-cut)", "Adult discretionary use", "1 pouch", 50, "Adult tobacco good."),
	consumerRow("Herbal-Blend Hookah Tobacco", "Adult discretionary use", "1 jar", 60, "Adult tobacco good."),

	-- Additional common spices and everyday cooking ingredients
	consumerRow("Cinammon", "Common cooking spice", "50 g packet", 20, "Everyday spice."),
	consumerRow("Cinammon Sticks (bundled)", "Tea, stews, baking, and mulled drinks", "small bundle", 25, "Common household spice."),
	consumerRow("Ground Cinammon (milled)", "Baking, porridge, sweets, and drinks", "50 g tin", 25, "Common household spice."),
	consumerRow("Cinammon Bark Chips (brew grade)", "Tea, brewing, stews, and warm drinks", "100 g packet", 22, "Common brewing and cooking spice."),
	consumerRow("Cinammon Sugar Blend", "Baking and breakfast seasoning", "250 g packet", 25, "Common sweet spice blend."),
	consumerRow("Cinammon Tea Mix (spice cut)", "Tea and warm drinks", "1 pack", 25, "Common household drink spice."),
	consumerRow("Cinammon Pastry Fill (sealed)", "Baking filling", "1 jar", 35, "Prepared baking ingredient."),
	consumerRow("Cistern-Grown Melon Crates", "Fresh melon, household meals, market snacks", "small melon crate", 32, "Water-accounted cistern melons from Mirovia."),
	consumerRow("Desert Cucumber Baskets", "Fresh cucumbers, salads, pickling", "small basket", 24, "Dryland cucumbers grown for caravan and household markets."),
	consumerRow("Preserved Desert Fruit", "Travel food, sweets, pantry storage", "small packet", 34, "Preserved desert fruit suited for dry-route storage."),
	consumerRow("Sun-Dried Melon Strips", "Trail food, sweets, caravan snacks", "small packet", 28, "Dried melon strips from cistern-grown Mirovian fruit."),
	consumerRow("Pressed Desert Seed Oil", "Cooking oil and caravan food preparation", "250 ml bottle", 38, "Household seed oil pressed from desert-grown produce."),
	consumerRow("Packed Caravan Rations", "Travel meals, workday food, emergency stores", "ration box", 55, "Compact provisioning box prepared for dry routes and household reserve use."),
	consumerRow("Dry-Route Produce Hampers", "Household produce, travel provisions", "small hamper", 46, "Mixed dry-route produce from the Pontic Esperance Homestead Association."),
	consumerRow("Caravan Cucumber Pickles", "Pickles, travel food, meal accompaniment", "small jar", 26, "Shelf-stable cucumber pickles suited for caravan and household tables."),
	consumerRow("Desert Fruit Preserves", "Jam, sweets, pantry storage", "small jar", 30, "Sweet preserved fruit from Mirovia's cistern farms."),


}

---------------------------------------------------------
-- Public invocation:
--   {{#invoke:AutoUpdateAgPrices|consumerPrices}}
--   {{#invoke:AutoUpdateAgPrices|consumerPrices|category=no}}
--   {{#invoke:AutoUpdateAgPrices|consumerPrices|limit=50}}
---------------------------------------------------------
function p.consumerPrices(frame)
	local args = getArgs(frame)
	local showCategory = not isNo(args.category)
	local limit = tonumber(args.limit or "")

	local localTime = os.date("*t")
	local dailySeed = localTime.year * 1000 + localTime.yday
	math.randomseed(dailySeed)

	local dateString, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()
	local out =
		"{| class=\"wikitable sortable\"\n" ..
		"|+ Consumer agricultural price list for " .. dateString .. "\n" ..
		"! Date !! Δ !! Product !! Supplier / Port company !! Consumer use !! Retail unit !! Consumer price !! Notes\n"

	local totalBaseNil, totalTodayNil, count = 0, 0, 0

	for _, item in ipairs(consumerCatalog) do
		if not limit or count < limit then
			local product = getProductByName(item.productName)
			if product then
				local name = product[1]
				local company = product[2]
				local basePrice = product[3]
				local city = inferHQCity(company) or ""
				local adjustedQty = select(1, simulatePriceChange(
					basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company, dailySeed
				))

				local consumerNil = item.baseNil
				if adjustedQty and adjustedQty > 0 then
					consumerNil = item.baseNil * (basePrice / adjustedQty)
				end

				local priceLevel = determinePriceLevel(item.baseNil, consumerNil)
				local sym
				local rowStyle
				if consumerNil < item.baseNil then
					sym = "↓"
					rowStyle = ' style="background-color:lightblue;"'
				elseif consumerNil > item.baseNil then
					sym = "↑"
					rowStyle = ' style="background-color:#ffcccb;"'
				else
					sym = "•"
					rowStyle = ' style="background-color:lightgreen;"'
				end

				totalBaseNil = totalBaseNil + item.baseNil
				totalTodayNil = totalTodayNil + consumerNil
				count = count + 1

				out = out .. string.format(
					"|-%s\n| %s || %s || %s || %s || %s || %s || %s || %s\n",
					rowStyle,
					dateString,
					sym,
					name,
					company,
					item.consumerUse,
					item.retailUnit,
					formatConsumerPriceFromNil(consumerNil),
					item.note
				)
			end
		end
	end

	local avgBase = totalBaseNil / math.max(count, 1)
	local avgToday = totalTodayNil / math.max(count, 1)
	local avgLabel = "Standard"
	local avgSym = "•"
	if avgToday < avgBase then
		avgLabel = "Lower consumer prices"
		avgSym = "↓"
	elseif avgToday > avgBase then
		avgLabel = "Higher consumer prices"
		avgSym = "↑"
	end

	out = out .. string.format(
		"|-\n! colspan=\"8\" | Consumer average: %s %s; baseline %s, current %s across %d listed goods\n|}\n",
		avgSym,
		avgLabel,
		formatConsumerPriceFromNil(avgBase),
		formatConsumerPriceFromNil(avgToday),
		count
	)

	return out
end



---------------------------------------------------------
-- 6. MAIN Table Generation (Condensed + Optional Full Breakdown)
---------------------------------------------------------
function p.generateTable(frame)
	local args = getArgs(frame)
	local mode = tostring(args.mode or "both"):lower()  -- both | summary | breakdown
	local collapse = not isNo(args.collapse)            -- default true (collapsed)

	local showSummary = (mode == "both" or mode == "summary")
	local showBreakdown = (mode == "both" or mode == "breakdown")

	-- Step A: daily seed for randomness (unique per day)
	local localTime = os.date("*t")
	local dailySeed = localTime.year * 1000 + localTime.yday
	math.randomseed(dailySeed)

	-- Step B: date info
	local dateString, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()
	-- Step C: build outputs
	local out = ""

	local summary = ""
	if showSummary then
		summary =
			"{| class=\"wikitable sortable\"\n" ..
			"! Date (Day/Month/Year [[PSSC]]) !! Δ !! Product !! Producing Company !! Tier I Price !! Units !! Notes\n"
	end

	local breakdown = ""
	if showBreakdown then
		local collapseClass = collapse and " mw-collapsible mw-collapsed" or ""
		breakdown =
			"{| class=\"wikitable sortable" .. collapseClass .. "\"\n" ..
			"|+ Full tier breakdown" .. (collapse and " (click to expand)" or "") .. "\n" ..
			"! Date (Day/Month/Year [[PSSC]]) !! Product !! Producing Company !! Base Price !! Price Level !! Tier III Price !! Tier II Price !! Tier I Price !! Units !! Explanation\n"
	end

	-- track averages
	local totalBase, totalNew, count = 0, 0, 0

	-- Step D: rows
	for _, product in ipairs(products) do
		local name = product[1]
		local company = product[2]
		local basePrice = product[3]
		local unit = product[4]

		local city = inferHQCity(company) or ""
		local newPrice, changeFactor, explanation = simulatePriceChange(basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company, dailySeed)
		local priceLevel = determinePriceLevel(basePrice, newPrice)
		local sym = levelSymbol(priceLevel)

		local rowStyle
		if priceLevel == "Low" then
			rowStyle = ' style="background-color:lightblue;"'
		elseif priceLevel == "Standard" then
			rowStyle = ' style="background-color:lightgreen;"'
		else
			rowStyle = ' style="background-color:#ffcccb;"'
		end

		local tierIIIPrice = math.floor((newPrice / 3) * 100) / 100
		local tierIIPrice  = math.floor((newPrice * 2 / 3) * 100) / 100
		local tierIPrice   = newPrice

		totalBase = totalBase + basePrice
		totalNew  = totalNew + newPrice
		count = count + 1

		if showSummary then
			summary = summary .. string.format(
				"|-%s\n| %s || %s || %s || %s || %.2f || %s || %s\n",
				rowStyle, dateString, sym, name, company, tierIPrice, unit, explanation
			)
		end

		if showBreakdown then
			breakdown = breakdown .. string.format(
				"|-%s\n| %s || %s || %s || %.2f || %s || %.2f || %.2f || %.2f || %s || %s\n",
				rowStyle, dateString, name, company, basePrice, priceLevel,
				tierIIIPrice, tierIIPrice, tierIPrice, unit, explanation
			)
		end
	end

	-- Step E: averages
	local avgBase = totalBase / count
	local avgNew = totalNew / count

	local averagePriceLevel
	if avgNew > avgBase then
		averagePriceLevel = "Low"
	elseif avgNew < avgBase then
		averagePriceLevel = "High"
	else
		averagePriceLevel = "Standard"
	end
	local avgSym = levelSymbol(averagePriceLevel)

	if showSummary then
		summary = summary .. string.format(
			"|-\n! colspan=\"7\" | Average adjusted (%.2f) vs base (%.2f): %s %s\n|}\n",
			avgNew, avgBase, avgSym, averagePriceLevel
		)
		out = out .. summary .. "\n"
	end

	if showBreakdown then
		breakdown = breakdown .. string.format(
			"|-\n! colspan=\"10\" | Average adjusted (%.2f) vs base (%.2f): %s %s\n|}\n",
			avgNew, avgBase, avgSym, averagePriceLevel
		)
		out = out .. breakdown
	end

	return out
end

---------------------------------------------------------
-- Convenience: full expanded breakdown (for updating/audits)
---------------------------------------------------------
function p.full(frame)
	frame = frame or {}
	frame.args = frame.args or {}
	frame.args.mode = "breakdown"
	frame.args.collapse = "no"
	return p.generateTable(frame)
end

function p.getAverageData()
	-- same daily seed logic already used by generateTable
	local localTime = os.date("*t")
	local dailySeed = localTime.year * 1000 + localTime.yday
	math.randomseed(dailySeed)

	local dateString, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()

	local totalBase, totalNew, count = 0, 0, 0

	for _, product in ipairs(products) do
		local name = product[1]
		local company = product[2]
		local basePrice = product[3]
		local city = inferHQCity(company) or ""

		local newPrice = select(1, simulatePriceChange(
			basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company, dailySeed
		))

		totalBase = totalBase + basePrice
		totalNew = totalNew + newPrice
		count = count + 1
	end

	local avgBase = totalBase / count
	local avgNew = totalNew / count
	local avgLevel
	if avgNew > avgBase then
		avgLevel = "Low"
	elseif avgNew < avgBase then
		avgLevel = "High"
	else
		avgLevel = "Standard"
	end

	return {
		label = "Agriculture",
		avgBase = avgBase,
		avgNew = avgNew,
		avgLevel = avgLevel,
		avgSym = levelSymbol(avgLevel),
		pctChange = ((avgNew - avgBase) / avgBase) * 100
	}
end

function p.getCompanyEmploymentInputs()
	local localTime = os.date("*t")
	local dailySeed = localTime.year * 1000 + localTime.yday
	math.randomseed(dailySeed)

	local _, dayOfMonth, month, psscYear, dayOfYear = getCurrentDate()

	local companyMap = {}

	for _, product in ipairs(products) do
		local name = product[1]
		local company = product[2]
		local basePrice = product[3]
		local city = inferHQCity(company) or "Vaeringheim"

		local newPrice = select(1, simulatePriceChange(
			basePrice, dayOfMonth, month, psscYear, dayOfYear, city, name, company, dailySeed
		))

		if not companyMap[company] then
			companyMap[company] = {
				name = company,
				sector = "Agriculture",
				city = city,
				totalBase = 0,
				totalNew = 0,
				count = 0
			}
		end

		local row = companyMap[company]
		row.totalBase = row.totalBase + basePrice
		row.totalNew = row.totalNew + newPrice
		row.count = row.count + 1
	end

	local out = {}
	for _, row in pairs(companyMap) do
		row.avgBase = row.totalBase / row.count
		row.avgNew = row.totalNew / row.count
		row.pctChange = ((row.avgNew - row.avgBase) / row.avgBase) * 100
		table.insert(out, row)
	end

	table.sort(out, function(a, b) return a.name < b.name end)
	return out
end
return p