Module:AutoUpdateAgPrices
From MicrasWiki
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
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", 1.8, "tons" },
{ "Potatos", "Granadita Collective", 4.9, "tons" },
{ "Squash", "Granadita Collective", 4.7, "tons" },
{ "Wheat", "Granadita Collective", 1.13, "tons" },
{ "maize", "Granadita Collective", 5.82, "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" },
}
---------------------------------------------------------
-- 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)
local dateKey = string.format("%d,%d", month, dayOfMonth)
local changeFactor = math.random(-20, 20) / 100
local explanation
if events[dateKey] then
explanation = events[dateKey] .. ": Prices influenced by event dynamics."
changeFactor = changeFactor + 0.05 -- small boost for special events
else
explanation = "General market fluctuations."
end
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
---------------------------------------------------------
-- 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 = 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 newPrice, changeFactor, explanation = simulatePriceChange(basePrice, dayOfMonth, month)
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
return p