Module:AutoUpdateManfPrices: Difference between revisions
From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs) No edit summary |
NewZimiaGov (talk | contribs) No edit summary |
||
| Line 77: | Line 77: | ||
{"Candles", "Market Hanavusu", 0.73, "pieces"}, | {"Candles", "Market Hanavusu", 0.73, "pieces"}, | ||
{"Copper", "Copper Mines of Southern Jogi", 2.1, "tons"}, | {"Copper", "Copper Mines of Southern Jogi", 2.1, "tons"}, | ||
{"Kalithros Class Rifle", "Somniant Stock Fund", 0.83, "units"}, | {"Kalithros Class Rifle", "Somniant Stock Fund", 0.83, "units"}, | ||
{"Delphica Class Grenadier Rifle", "Somniant Stock Fund", 0.249, "units"}, | {"Delphica Class Grenadier Rifle", "Somniant Stock Fund", 0.249, "units"}, | ||
{"Chrysos Class Commando Rifle", "Somniant Stock Fund", 0.124, "units"}, | {"Chrysos Class Commando Rifle", "Somniant Stock Fund", 0.124, "units"}, | ||
{"Lothaya Class Sniper Rifle", "Somniant Stock Fund", 0.0332, "units"}, | {"Lothaya Class Sniper Rifle", "Somniant Stock Fund", 0.0332, "units"}, | ||
{"Erythros Class Pistol", "Somniant Stock Fund", 0.166, "units"}, | {"Erythros Class Pistol", "Somniant Stock Fund", 0.166, "units"}, | ||
{"Bubalus XT Class Revolver", "Somniant Stock Fund", 0.95, "units"}, | {"Bubalus XT Class Revolver", "Somniant Stock Fund", 0.95, "units"}, | ||
{"Cathartes Class RPG", "Somniant Stock Fund", 0.03, "units"}, | {"Cathartes Class RPG", "Somniant Stock Fund", 0.03, "units"}, | ||
{"Harpyia Class Submachine Gun", "Somniant Stock Fund", 0.125, "units"}, | {"Harpyia Class Submachine Gun", "Somniant Stock Fund", 0.125, "units"}, | ||
{"Strix Class Combat Shotgun", "Somniant Stock Fund", 0.22, "units"}, | {"Strix Class Combat Shotgun", "Somniant Stock Fund", 0.22, "units"}, | ||
{"Regavis Class DMR", "Somniant Stock Fund", 0.27, "units"}, | {"Regavis Class DMR", "Somniant Stock Fund", 0.27, "units"}, | ||
{"Aithra Class Howitzer", "Somniant Stock Fund", 0.00170, "units"}, | {"Aithra Class Howitzer", "Somniant Stock Fund", 0.00170, "units"}, | ||
{"Aetheris Class Towed Howitzer", "Somniant Stock Fund", 0.00490, "units"}, | {"Aetheris Class Towed Howitzer", "Somniant Stock Fund", 0.00490, "units"}, | ||
{"Iynas Class Field Gun", "Somniant Stock Fund", 0.00420, "units"}, | {"Iynas Class Field Gun", "Somniant Stock Fund", 0.00420, "units"}, | ||
{"300mm Secutor Class Coastal Guns", "Somniant Stock Fund", 0.0033, "guns"}, | {"300mm Secutor Class Coastal Guns", "Somniant Stock Fund", 0.0033, "guns"}, | ||
{"155mm Halicarn Class Self-Propelled Howitzer", "Somniant Stock Fund", 0.0025, "units"}, | {"155mm Halicarn Class Self-Propelled Howitzer", "Somniant Stock Fund", 0.0025, "units"}, | ||
{"120mm Odiferian Class Mortar Carrier", "Somniant Stock Fund", 0.00160, "units"}, | {"120mm Odiferian Class Mortar Carrier", "Somniant Stock Fund", 0.00160, "units"}, | ||
{"Makra Class Battle Tank", "Somniant Stock Fund", 0.0083, "units"}, | {"Makra Class Battle Tank", "Somniant Stock Fund", 0.0083, "units"}, | ||
{"Laya Class Heavy Tank", "Somniant Stock Fund", 0.0033, "units"}, | {"Laya Class Heavy Tank", "Somniant Stock Fund", 0.0033, "units"}, | ||
{"Arachne Class Light Tank", "Somniant Stock Fund", 0.0099, "units"}, | {"Arachne Class Light Tank", "Somniant Stock Fund", 0.0099, "units"}, | ||
{"Thalassa Class Main Battle Tank", "Somniant Stock Fund", 0.0050, "units"}, | {"Thalassa Class Main Battle Tank", "Somniant Stock Fund", 0.0050, "units"}, | ||
{"Syrinx Class Armored Infantry", "Somniant Stock Fund", 0.049, "squads"}, | {"Syrinx Class Armored Infantry", "Somniant Stock Fund", 0.049, "squads"}, | ||
{"Bijarian Command Vehicle", "Somniant Stock Fund", 0.00083, "units"}, | {"Bijarian Command Vehicle", "Somniant Stock Fund", 0.00083, "units"}, | ||
{"Onceanic Recon Vehicle", "Somniant Stock Fund", 0.00249, "units"}, | {"Onceanic Recon Vehicle", "Somniant Stock Fund", 0.00249, "units"}, | ||
{"Ephyra Class Anti-Aircraft Vehicle", "Somniant Stock Fund", 0.00120, "units"}, | {"Ephyra Class Anti-Aircraft Vehicle", "Somniant Stock Fund", 0.00120, "units"}, | ||
{"Ampelos Class Armored Recovery Vehicle", "Somniant Stock Fund", 0.0031, "systems"}, | {"Ampelos Class Armored Recovery Vehicle", "Somniant Stock Fund", 0.0031, "systems"}, | ||
{"Penthia Class Bridge-Laying Vehicle", "Somniant Stock Fund", 0.0008, "systems"}, | {"Penthia Class Bridge-Laying Vehicle", "Somniant Stock Fund", 0.0008, "systems"}, | ||
{"Corythia Class Dedicated Logistics and Transport Truck", "Somniant Stock Fund", 0.0019, "systems"}, | {"Corythia Class Dedicated Logistics and Transport Truck", "Somniant Stock Fund", 0.0019, "systems"}, | ||
{"Icaria Class Mine-Clearing / Combat Engineering Vehicle", "Somniant Stock Fund", 0.0008, "systems"}, | {"Icaria Class Mine-Clearing / Combat Engineering Vehicle", "Somniant Stock Fund", 0.0008, "systems"}, | ||
{"Kalypso Class Aircraft Carrier", "Somniant Stock Fund", 0.00005, "ships"}, | {"Kalypso Class Aircraft Carrier", "Somniant Stock Fund", 0.00005, "ships"}, | ||
{"Luminaria Class Carrier", "Somniant Stock Fund", 0.00004, "ships"}, | {"Luminaria Class Carrier", "Somniant Stock Fund", 0.00004, "ships"}, | ||
{"Ferrum Citadel Class Battleship", "Somniant Stock Fund", 0.00009, "ships"}, | {"Ferrum Citadel Class Battleship", "Somniant Stock Fund", 0.00009, "ships"}, | ||
{"Eidolon Class Cruiser", "Somniant Stock Fund", 0.00020, "ships"}, | {"Eidolon Class Cruiser", "Somniant Stock Fund", 0.00020, "ships"}, | ||
{"Vaeringheim Class Corvette", "Somniant Stock Fund", 0.00050, "ships"}, | {"Vaeringheim Class Corvette", "Somniant Stock Fund", 0.00050, "ships"}, | ||
{"Sylvapolis Class Frigate", "Somniant Stock Fund", 0.00032, "ships"}, | {"Sylvapolis Class Frigate", "Somniant Stock Fund", 0.00032, "ships"}, | ||
{"Aetherium Class Patrol Ship", "Somniant Stock Fund", 0.00058, "ships"}, | {"Aetherium Class Patrol Ship", "Somniant Stock Fund", 0.00058, "ships"}, | ||
{"Atterian Class Combat Ship", "Somniant Stock Fund", 0.00016, "ships"}, | {"Atterian Class Combat Ship", "Somniant Stock Fund", 0.00016, "ships"}, | ||
{"Xylanda Class Attack Submarine", "Somniant Stock Fund", 0.00025, "ships"}, | {"Xylanda Class Attack Submarine", "Somniant Stock Fund", 0.00025, "ships"}, | ||
{"Acheron Class Submersible Destroyer", "Somniant Stock Fund", 0.00016, "ships"}, | {"Acheron Class Submersible Destroyer", "Somniant Stock Fund", 0.00016, "ships"}, | ||
{"Bijarian Ballistic Missile Submarine", "Somniant Stock Fund", 0.00012, "ships"}, | {"Bijarian Ballistic Missile Submarine", "Somniant Stock Fund", 0.00012, "ships"}, | ||
{"Thalassus Class Amphibious Assault Ship", "Somniant Stock Fund", 0.000065, "ships"}, | {"Thalassus Class Amphibious Assault Ship", "Somniant Stock Fund", 0.000065, "ships"}, | ||
{"Saluria Class Gunboat", "Somniant Stock Fund", 0.00041, "ships"}, | {"Saluria Class Gunboat", "Somniant Stock Fund", 0.00041, "ships"}, | ||
{"Cetus Class Attack Craft", "Somniant Stock Fund", 0.00050, "ships"}, | {"Cetus Class Attack Craft", "Somniant Stock Fund", 0.00050, "ships"}, | ||
{"Odobenus Class Minelayer", "Somniant Stock Fund", 0.0003, "ships"}, | {"Odobenus Class Minelayer", "Somniant Stock Fund", 0.0003, "ships"}, | ||
{"Cetomagna Class Minehunter", "Somniant Stock Fund", 0.0003, "ships"}, | {"Cetomagna Class Minehunter", "Somniant Stock Fund", 0.0003, "ships"}, | ||
{"Aithra Class Proximity Aircraft", "Somniant Stock Fund", 0.00083, "aircraft"}, | {"Aithra Class Proximity Aircraft", "Somniant Stock Fund", 0.00083, "aircraft"}, | ||
{"Orphali Class Tanker Aircraft", "Somniant Stock Fund", 0.00044, "aircraft"}, | {"Orphali Class Tanker Aircraft", "Somniant Stock Fund", 0.00044, "aircraft"}, | ||
{"Ventiflor Eye Class AEW&C Aircraft", "Somniant Stock Fund", 0.00011, "aircraft"}, | {"Ventiflor Eye Class AEW&C Aircraft", "Somniant Stock Fund", 0.00011, "aircraft"}, | ||
{"Fluxus Class Maritime Patrol Aircraft", "Somniant Stock Fund", 0.00063, "aircraft"}, | {"Fluxus Class Maritime Patrol Aircraft", "Somniant Stock Fund", 0.00063, "aircraft"}, | ||
{"Hostica Class Maritime Patrol Aircraft", "Somniant Stock Fund", 0.00071, "aircraft"}, | {"Hostica Class Maritime Patrol Aircraft", "Somniant Stock Fund", 0.00071, "aircraft"}, | ||
{"Chrysos Class Sea Bomber", "Somniant Stock Fund", 0.00166, "aircraft"}, | {"Chrysos Class Sea Bomber", "Somniant Stock Fund", 0.00166, "aircraft"}, | ||
{"Misttalon Class Heavy Bomber", "Somniant Stock Fund", 0.00025, "aircraft"}, | {"Misttalon Class Heavy Bomber", "Somniant Stock Fund", 0.00025, "aircraft"}, | ||
{"Symphonara Class Compound Intercept", "Somniant Stock Fund", 0.00066, "aircraft"}, | {"Symphonara Class Compound Intercept", "Somniant Stock Fund", 0.00066, "aircraft"}, | ||
{"Nefelian Transport Plane", "Somniant Stock Fund", 0.00083, "aircraft"}, | {"Nefelian Transport Plane", "Somniant Stock Fund", 0.00083, "aircraft"}, | ||
{"Noctiluna Class Medium Transport Helicopter", "Somniant Stock Fund", 0.0010, "aircraft"}, | {"Noctiluna Class Medium Transport Helicopter", "Somniant Stock Fund", 0.0010, "aircraft"}, | ||
{"Umbraclaw Class Heavy Transport Helicopter", "Somniant Stock Fund", 0.00089, "aircraft"}, | {"Umbraclaw Class Heavy Transport Helicopter", "Somniant Stock Fund", 0.00089, "aircraft"}, | ||
{"Thalassa Class Attack Helicopter", "Somniant Stock Fund", 0.00130, "aircraft"}, | {"Thalassa Class Attack Helicopter", "Somniant Stock Fund", 0.00130, "aircraft"}, | ||
{"Catonis Class Unmanned Aircraft", "Somniant Stock Fund", 0.00083, "aircraft"}, | {"Catonis Class Unmanned Aircraft", "Somniant Stock Fund", 0.00083, "aircraft"}, | ||
{"Lotos Class Tactical UAV", "Somniant Stock Fund", 0.00087, "aircraft"}, | {"Lotos Class Tactical UAV", "Somniant Stock Fund", 0.00087, "aircraft"}, | ||
{"Aurantius Class Multi-Role UAV", "Somniant Stock Fund", 0.00091, "aircraft | {"Aurantius Class Multi-Role UAV", "Somniant Stock Fund", 0.00091, "aircraft"}, | ||
} | } | ||
| Line 214: | Line 206: | ||
--------------------------------------------------------- | --------------------------------------------------------- | ||
function p.generateTable() | function p.generateTable() | ||
-- (A) | -- (A) Seed randomness | ||
local localTime = os.date("*t") | local localTime = os.date("*t") | ||
math.randomseed(localTime.year * 1000 + localTime.yday) | |||
-- (B) | -- (B) Get date info | ||
local dateString, dayOfMonth, month = getCurrentDate() | local dateString, dayOfMonth, month = getCurrentDate() | ||
-- (C) Table header | -- (C) Table header | ||
local wikitable = | local wikitable = | ||
"{| class=\"wikitable\"\n" .. | "{| class=\"wikitable\"\n" .. | ||
"! Date | "! Date !! Product !! Company !! Base Price !! Level !! Tier III !! Tier II !! Tier I !! Units !! Explanation\n" | ||
local totalBase, totalNew, count = 0, 0, 0 | |||
local totalBase, totalNew = 0, 0 | |||
-- (D) | -- (D) Populate rows | ||
for _, product in ipairs(products) do | for _, product in ipairs(products) do | ||
local name | local name, company, basePrice, units = unpack(product) | ||
local newPrice, _, explanation = simulatePriceChange(basePrice, dayOfMonth, month) | |||
local newPrice, | |||
local priceLevel = determinePriceLevel(basePrice, newPrice) | local priceLevel = determinePriceLevel(basePrice, newPrice) | ||
-- | -- row coloring | ||
local rowStyle | local rowStyle | ||
if priceLevel == "Low" then | if priceLevel == "Low" then | ||
| Line 248: | Line 233: | ||
rowStyle = ' style="background-color:lightgreen;"' | rowStyle = ' style="background-color:lightgreen;"' | ||
else | else | ||
rowStyle = ' style="background-color:#ffcccb;"' | rowStyle = ' style="background-color:#ffcccb;"' | ||
end | end | ||
local tierIII = math.floor((newPrice / 3) * 10000) / 10000 | |||
local | local tierII = math.floor((newPrice * 2/3) * 10000) / 10000 | ||
local | local tierI = newPrice | ||
local | |||
totalBase = totalBase + basePrice | totalBase = totalBase + basePrice | ||
totalNew = totalNew + newPrice | totalNew = totalNew + newPrice | ||
count = count + 1 | count = count + 1 | ||
wikitable = wikitable .. string.format( | wikitable = wikitable .. string.format( | ||
"|-%s\n| %s || %s || %s || %.4f || %s || %.4f || %.4f || %.4f || %s || %s\n", | "|-%s\n| %s || %s || %s || %.4f || %s || %.4f || %.4f || %.4f || %s || %s\n", | ||
rowStyle, | rowStyle, dateString, name, company, basePrice, | ||
priceLevel, tierIII, tierII, tierI, units, explanation | |||
) | ) | ||
end | end | ||
-- (E) | -- (E) Averages | ||
local avgBase = totalBase / count | local avgBase = totalBase / count | ||
local avgNew = totalNew / count | local avgNew = totalNew / count | ||
local avgLevel | |||
local | |||
if avgNew < avgBase then | if avgNew < avgBase then | ||
avgLevel = "Low" | |||
elseif avgNew > avgBase then | elseif avgNew > avgBase then | ||
avgLevel = "High" | |||
else | else | ||
avgLevel = "Standard" | |||
end | end | ||
-- ( | -- (F) Footer | ||
wikitable = wikitable .. string.format( | wikitable = wikitable .. string.format( | ||
"|-\n! colspan=\"10\" | Average adjusted price (%.4f) | "|-\n! colspan=\"10\" | Average adjusted price (%.4f) vs base (%.4f) ⇒ %s\n", | ||
avgNew, avgBase, | avgNew, avgBase, avgLevel | ||
) | ) | ||
wikitable = wikitable .. "|}" | wikitable = wikitable .. "|}" | ||
return wikitable | return wikitable | ||
| Line 296: | Line 273: | ||
--------------------------------------------------------- | --------------------------------------------------------- | ||
-- 7. Optional: | -- 7. Optional: Single-Day Line Graph | ||
--------------------------------------------------------- | --------------------------------------------------------- | ||
function p.generateSingleDayLineGraph() | function p.generateSingleDayLineGraph() | ||
local localTime = os.date("*t") | local localTime = os.date("*t") | ||
math.randomseed(localTime.year * 1000 + localTime.yday) | |||
local dateString, dayOfMonth, month = getCurrentDate() | local dateString, dayOfMonth, month = getCurrentDate() | ||
local data = {} | |||
for _, product in ipairs(products) do | for _, product in ipairs(products) do | ||
local name | local name, _, basePrice = unpack(product) | ||
local newPrice = simulatePriceChange(basePrice, dayOfMonth, month) | local newPrice = simulatePriceChange(basePrice, dayOfMonth, month) | ||
table.insert(data, { product = name, difference = newPrice - basePrice }) | |||
table.insert( | |||
end | end | ||
local spec = { | local spec = { | ||
["$schema"] | ["$schema"] = "https://vega.github.io/schema/vega-lite/v5.json", | ||
description | description = "Single-day price difference chart", | ||
width | width = 700, height = 400, | ||
data = { values = data }, | |||
data | mark = "line", | ||
mark | encoding = { | ||
encoding | x = { field = "product", type = "ordinal", title = "Product" }, | ||
x = { field = "product", | y = { field = "difference", type = "quantitative", title = "Difference" }, | ||
y = { field = "difference", type = "quantitative", title = "Difference | |||
tooltip = { field = "difference", type = "quantitative" } | tooltip = { field = "difference", type = "quantitative" } | ||
}, | }, | ||
title | title = "Price Differences for " .. dateString | ||
} | } | ||
return string.format("<graph>%s</graph>", mw.text.jsonEncode(spec)) | |||
return string.format("<graph>%s</graph>", | |||
end | end | ||
return p | return p | ||
Revision as of 15:06, 22 April 2025
Documentation for this module may be created at Module:AutoUpdateManfPrices/doc
---------------------------------------------------------
-- Module:DailyPriceTable
-- Generates a daily-updated product table + single-day line graph
-- for differences between base and adjusted prices,
-- with each row colored by price level:
-- • Low => light blue
-- • Standard => light green
-- • High => light red
---------------------------------------------------------
local p = {}
---------------------------------------------------------
-- 1. getCurrentDate
-- Returns today's date in PSSC format (day/month/year),
-- and numeric dayOfMonth/month for further calculations.
---------------------------------------------------------
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
local dateString = string.format("%d/%d/%d [[PSSC]]", dayOfMonth, month, psscYear)
return dateString, dayOfMonth, month
end
---------------------------------------------------------
-- 2. Product Data
---------------------------------------------------------
local products = {
{"BT-01 Rifle", "Baratar Corporation", 3.15, "shipments"},
{"Q31 Spearhead", "Baratar Corporation", 0.27, "cases"},
{"Q31 Recon", "Baratar Corporation", 2.25, "units"},
{"Lowland 9mm", "Baratar Corporation", 3.90, "cases"},
{"q38.7 Sniper Rifle", "Baratar Corporation", 0.45, "crates"},
{"Electricity", "Roving Wind Farm Corporation", 550.00, "megawatts"},
{"Purple Granite", "Thalassian Temples Granite Export Cooperative", 0.036, "blocks"},
{"Iron", "East Keltian Iron Company", 1.692, "tons"},
{"Steel", "East Keltian Iron Company", 2.412, "tons"},
{"Concrete", "East Keltian Iron Company", 6.039, "tons"},
{"Coal", "Mylecian Coal Ports", 0.378, "tons"},
{"Diamonds", "Merchants of the Valley of Diamonds", 0.05, "carats"},
{"Timber", "East Keltian Timber Company", 5.63, "logs"},
{"Mens' Boots", "Onceanic Boot Company", 2.00, "pairs"},
{"Womens' Boots", "Onceanic Boot Company", 3.00, "pairs"},
{"Garganram Sign Plains Fertilizer", "Commune of the Garganid Apostles", 0.60, "tons"},
{"Gold Necklaces", "Shï Collective", 0.15, "pieces"},
{"Gold Rings", "Shï Collective", 0.40, "pieces"},
{"Gold Bracelets", "Shï Collective", 0.27, "pieces"},
{"Gold Earrings", "Shï Collective", 0.65, "pairs"},
{"Robes", "Order of the Sphinx", 1.30, "units"},
{"Dresses", "Order of the Sphinx", 0.65, "units"},
{"Tarnkappes", "Order of the Sphinx", 2.10, "cloaks"},
{"Coats", "Order of the Sphinx", 1.05, "units"},
{"Perfume", "Market Hanavusu", 0.32, "bottles"},
{"Cologne", "Market Hanavusu", 0.45, "bottles"},
{"Incense", "Market Hanavusu", 0.90, "sticks"},
{"Candles", "Market Hanavusu", 0.73, "pieces"},
{"Copper", "Copper Mines of Southern Jogi", 2.1, "tons"},
{"Kalithros Class Rifle", "Somniant Stock Fund", 0.83, "units"},
{"Delphica Class Grenadier Rifle", "Somniant Stock Fund", 0.249, "units"},
{"Chrysos Class Commando Rifle", "Somniant Stock Fund", 0.124, "units"},
{"Lothaya Class Sniper Rifle", "Somniant Stock Fund", 0.0332, "units"},
{"Erythros Class Pistol", "Somniant Stock Fund", 0.166, "units"},
{"Bubalus XT Class Revolver", "Somniant Stock Fund", 0.95, "units"},
{"Cathartes Class RPG", "Somniant Stock Fund", 0.03, "units"},
{"Harpyia Class Submachine Gun", "Somniant Stock Fund", 0.125, "units"},
{"Strix Class Combat Shotgun", "Somniant Stock Fund", 0.22, "units"},
{"Regavis Class DMR", "Somniant Stock Fund", 0.27, "units"},
{"Aithra Class Howitzer", "Somniant Stock Fund", 0.00170, "units"},
{"Aetheris Class Towed Howitzer", "Somniant Stock Fund", 0.00490, "units"},
{"Iynas Class Field Gun", "Somniant Stock Fund", 0.00420, "units"},
{"300mm Secutor Class Coastal Guns", "Somniant Stock Fund", 0.0033, "guns"},
{"155mm Halicarn Class Self-Propelled Howitzer", "Somniant Stock Fund", 0.0025, "units"},
{"120mm Odiferian Class Mortar Carrier", "Somniant Stock Fund", 0.00160, "units"},
{"Makra Class Battle Tank", "Somniant Stock Fund", 0.0083, "units"},
{"Laya Class Heavy Tank", "Somniant Stock Fund", 0.0033, "units"},
{"Arachne Class Light Tank", "Somniant Stock Fund", 0.0099, "units"},
{"Thalassa Class Main Battle Tank", "Somniant Stock Fund", 0.0050, "units"},
{"Syrinx Class Armored Infantry", "Somniant Stock Fund", 0.049, "squads"},
{"Bijarian Command Vehicle", "Somniant Stock Fund", 0.00083, "units"},
{"Onceanic Recon Vehicle", "Somniant Stock Fund", 0.00249, "units"},
{"Ephyra Class Anti-Aircraft Vehicle", "Somniant Stock Fund", 0.00120, "units"},
{"Ampelos Class Armored Recovery Vehicle", "Somniant Stock Fund", 0.0031, "systems"},
{"Penthia Class Bridge-Laying Vehicle", "Somniant Stock Fund", 0.0008, "systems"},
{"Corythia Class Dedicated Logistics and Transport Truck", "Somniant Stock Fund", 0.0019, "systems"},
{"Icaria Class Mine-Clearing / Combat Engineering Vehicle", "Somniant Stock Fund", 0.0008, "systems"},
{"Kalypso Class Aircraft Carrier", "Somniant Stock Fund", 0.00005, "ships"},
{"Luminaria Class Carrier", "Somniant Stock Fund", 0.00004, "ships"},
{"Ferrum Citadel Class Battleship", "Somniant Stock Fund", 0.00009, "ships"},
{"Eidolon Class Cruiser", "Somniant Stock Fund", 0.00020, "ships"},
{"Vaeringheim Class Corvette", "Somniant Stock Fund", 0.00050, "ships"},
{"Sylvapolis Class Frigate", "Somniant Stock Fund", 0.00032, "ships"},
{"Aetherium Class Patrol Ship", "Somniant Stock Fund", 0.00058, "ships"},
{"Atterian Class Combat Ship", "Somniant Stock Fund", 0.00016, "ships"},
{"Xylanda Class Attack Submarine", "Somniant Stock Fund", 0.00025, "ships"},
{"Acheron Class Submersible Destroyer", "Somniant Stock Fund", 0.00016, "ships"},
{"Bijarian Ballistic Missile Submarine", "Somniant Stock Fund", 0.00012, "ships"},
{"Thalassus Class Amphibious Assault Ship", "Somniant Stock Fund", 0.000065, "ships"},
{"Saluria Class Gunboat", "Somniant Stock Fund", 0.00041, "ships"},
{"Cetus Class Attack Craft", "Somniant Stock Fund", 0.00050, "ships"},
{"Odobenus Class Minelayer", "Somniant Stock Fund", 0.0003, "ships"},
{"Cetomagna Class Minehunter", "Somniant Stock Fund", 0.0003, "ships"},
{"Aithra Class Proximity Aircraft", "Somniant Stock Fund", 0.00083, "aircraft"},
{"Orphali Class Tanker Aircraft", "Somniant Stock Fund", 0.00044, "aircraft"},
{"Ventiflor Eye Class AEW&C Aircraft", "Somniant Stock Fund", 0.00011, "aircraft"},
{"Fluxus Class Maritime Patrol Aircraft", "Somniant Stock Fund", 0.00063, "aircraft"},
{"Hostica Class Maritime Patrol Aircraft", "Somniant Stock Fund", 0.00071, "aircraft"},
{"Chrysos Class Sea Bomber", "Somniant Stock Fund", 0.00166, "aircraft"},
{"Misttalon Class Heavy Bomber", "Somniant Stock Fund", 0.00025, "aircraft"},
{"Symphonara Class Compound Intercept", "Somniant Stock Fund", 0.00066, "aircraft"},
{"Nefelian Transport Plane", "Somniant Stock Fund", 0.00083, "aircraft"},
{"Noctiluna Class Medium Transport Helicopter", "Somniant Stock Fund", 0.0010, "aircraft"},
{"Umbraclaw Class Heavy Transport Helicopter", "Somniant Stock Fund", 0.00089, "aircraft"},
{"Thalassa Class Attack Helicopter", "Somniant Stock Fund", 0.00130, "aircraft"},
{"Catonis Class Unmanned Aircraft", "Somniant Stock Fund", 0.00083, "aircraft"},
{"Lotos Class Tactical UAV", "Somniant Stock Fund", 0.00087, "aircraft"},
{"Aurantius Class Multi-Role UAV", "Somniant Stock Fund", 0.00091, "aircraft"},
}
---------------------------------------------------------
-- 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
-- Applies daily random factor to basePrice. If today's
-- date matches a known event, add a small positive boost.
---------------------------------------------------------
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 -- slight boost for event days
else
explanation = "General market fluctuations."
end
local newPrice = math.floor((basePrice * (1 + changeFactor)) * 10000) / 10000
return newPrice, changeFactor, explanation
end
---------------------------------------------------------
-- 5. determinePriceLevel
-- Returns "Low", "Standard", or "High"
---------------------------------------------------------
local function determinePriceLevel(basePrice, adjustedPrice)
if adjustedPrice < basePrice then
return "Low"
elseif adjustedPrice > basePrice then
return "High"
else
return "Standard"
end
end
---------------------------------------------------------
-- 6. Main Function: generateTable
-- Builds the daily wiki-table with updated prices.
---------------------------------------------------------
function p.generateTable()
-- (A) Seed randomness
local localTime = os.date("*t")
math.randomseed(localTime.year * 1000 + localTime.yday)
-- (B) Get date info
local dateString, dayOfMonth, month = getCurrentDate()
-- (C) Table header
local wikitable =
"{| class=\"wikitable\"\n" ..
"! Date !! Product !! Company !! Base Price !! Level !! Tier III !! Tier II !! Tier I !! Units !! Explanation\n"
local totalBase, totalNew, count = 0, 0, 0
-- (D) Populate rows
for _, product in ipairs(products) do
local name, company, basePrice, units = unpack(product)
local newPrice, _, explanation = simulatePriceChange(basePrice, dayOfMonth, month)
local priceLevel = determinePriceLevel(basePrice, newPrice)
-- row coloring
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 tierIII = math.floor((newPrice / 3) * 10000) / 10000
local tierII = math.floor((newPrice * 2/3) * 10000) / 10000
local tierI = newPrice
totalBase = totalBase + basePrice
totalNew = totalNew + newPrice
count = count + 1
wikitable = wikitable .. string.format(
"|-%s\n| %s || %s || %s || %.4f || %s || %.4f || %.4f || %.4f || %s || %s\n",
rowStyle, dateString, name, company, basePrice,
priceLevel, tierIII, tierII, tierI, units, explanation
)
end
-- (E) Averages
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
-- (F) Footer
wikitable = wikitable .. string.format(
"|-\n! colspan=\"10\" | Average adjusted price (%.4f) vs base (%.4f) ⇒ %s\n",
avgNew, avgBase, avgLevel
)
wikitable = wikitable .. "|}"
return wikitable
end
---------------------------------------------------------
-- 7. Optional: Single-Day Line Graph
---------------------------------------------------------
function p.generateSingleDayLineGraph()
local localTime = os.date("*t")
math.randomseed(localTime.year * 1000 + localTime.yday)
local dateString, dayOfMonth, month = getCurrentDate()
local data = {}
for _, product in ipairs(products) do
local name, _, basePrice = unpack(product)
local newPrice = simulatePriceChange(basePrice, dayOfMonth, month)
table.insert(data, { product = name, difference = newPrice - basePrice })
end
local spec = {
["$schema"] = "https://vega.github.io/schema/vega-lite/v5.json",
description = "Single-day price difference chart",
width = 700, height = 400,
data = { values = data },
mark = "line",
encoding = {
x = { field = "product", type = "ordinal", title = "Product" },
y = { field = "difference", type = "quantitative", title = "Difference" },
tooltip = { field = "difference", type = "quantitative" }
},
title = "Price Differences for " .. dateString
}
return string.format("<graph>%s</graph>", mw.text.jsonEncode(spec))
end
return p