Module:GeneralPortMarketLog: Difference between revisions
From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs) No edit summary |
NewZimiaGov (talk | contribs) No edit summary |
||
| Line 2: | Line 2: | ||
local p = {} | local p = {} | ||
-- 1) Date logic unchanged... | |||
function p.getCurrentDate() | function p.getCurrentDate() | ||
local startDate = os.time({year = 1999, month = 8, day = 6}) | local startDate = os.time({year = 1999, month = 8, day = 6}) | ||
| Line 17: | Line 18: | ||
end | end | ||
-- 2) Helpers unchanged... | |||
local function randomChoice(t) | local function randomChoice(t) | ||
return t[math.random(#t)] | return t[math.random(#t)] | ||
end | end | ||
-- | -- 3) Global price helpers unchanged... | ||
-- [getGlobalClosePrice(), getInvestorClosingValues() as before] | |||
-- 4) NATIONAL POPULATION CONSTANT | |||
local nationalPopulation = 82,545,451 -- total population of the nation | |||
function p.generateMarketLog() | function p.generateMarketLog() | ||
| Line 55: | Line 33: | ||
local dateStr = string.format("Day %d, Y.%d", day, year) | local dateStr = string.format("Day %d, Y.%d", day, year) | ||
-- closingData, closePrice, priceChange, regionalReport, stock flows, etc. unchanged... | |||
local stipendRedemption = math.random( | -- STIPEND VOUCHERS REDEEMED | ||
-- Use between 0.05% and 0.20% of the national population each day: | |||
local minRedemption = math.floor(nationalPopulation * 0.0005) | |||
local maxRedemption = math.floor(nationalPopulation * 0.0020) | |||
local stipendRedemption = math.random(minRedemption, maxRedemption) | |||
-- COMMODITY VOLUME unchanged or adjust similarly if desired | |||
local commodityVolume = math.random(3000, 4000) | local commodityVolume = math.random(3000, 4000) | ||
-- ...rest of your data gathering... | |||
-- BUILD WIKITABLE | |||
local log = "{| class=\"wikitable\" style=\"width:100%\"\n" | local log = "{| class=\"wikitable\" style=\"width:100%\"\n" | ||
log = log .. string.format("! colspan=2 | General Port of Lake Morovia – Market Activity Log (%s)\n", dateStr) | log = log .. string.format("! colspan=2 | General Port of Lake Morovia – Market Activity Log (%s)\n", dateStr) | ||
| Line 110: | Line 53: | ||
log = log .. "|-\n" | log = log .. "|-\n" | ||
log = log .. string.format("| '''Commodity Redemption Volume''' || %d tons\n", commodityVolume) | log = log .. string.format("| '''Commodity Redemption Volume''' || %d tons\n", commodityVolume) | ||
-- [and the rest of the table as before] | |||
return log | return log | ||
end | end | ||
-- dailyMarketSummary() and return p unchanged | |||
return p | |||
Revision as of 06:19, 26 April 2025
Documentation for this module may be created at Module:GeneralPortMarketLog/doc
-- Module:GeneralPortMarketLog
local p = {}
-- 1) Date logic unchanged...
function p.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
return psscYear, dayOfYear
end
-- 2) Helpers unchanged...
local function randomChoice(t)
return t[math.random(#t)]
end
-- 3) Global price helpers unchanged...
-- [getGlobalClosePrice(), getInvestorClosingValues() as before]
-- 4) NATIONAL POPULATION CONSTANT
local nationalPopulation = 82,545,451 -- total population of the nation
function p.generateMarketLog()
local year, day = p.getCurrentDate()
local dateStr = string.format("Day %d, Y.%d", day, year)
-- closingData, closePrice, priceChange, regionalReport, stock flows, etc. unchanged...
-- STIPEND VOUCHERS REDEEMED
-- Use between 0.05% and 0.20% of the national population each day:
local minRedemption = math.floor(nationalPopulation * 0.0005)
local maxRedemption = math.floor(nationalPopulation * 0.0020)
local stipendRedemption = math.random(minRedemption, maxRedemption)
-- COMMODITY VOLUME unchanged or adjust similarly if desired
local commodityVolume = math.random(3000, 4000)
-- ...rest of your data gathering...
-- BUILD WIKITABLE
local log = "{| class=\"wikitable\" style=\"width:100%\"\n"
log = log .. string.format("! colspan=2 | General Port of Lake Morovia – Market Activity Log (%s)\n", dateStr)
log = log .. "|-\n"
log = log .. string.format("| '''Stipend Vouchers Redeemed''' || %d Poli\n", stipendRedemption)
log = log .. "|-\n"
log = log .. string.format("| '''Commodity Redemption Volume''' || %d tons\n", commodityVolume)
-- [and the rest of the table as before]
return log
end
-- dailyMarketSummary() and return p unchanged