Module:BassaridiaForecast
From MicrasWiki
Jump to navigationJump to search
Documentation for this module may be created at Module:BassaridiaForecast/doc
--------------------------------------------------------- -- Module:WeatherForecast -- Provides a daily weather forecast for each city -- using spelled-out climate names, a PSSC date system, -- and random event selection by season. --------------------------------------------------------- local p = {} --------------------------------------------------------- -- 1. Calendar System --------------------------------------------------------- local function getCurrentDateInfo() local startDate = os.time({year = 1999, month = 8, day = 6}) local secondsInDay = 86400 local daysPerYear = 183 local currentTime = os.time() local totalDaysElapsed = math.floor((currentTime - startDate) / secondsInDay) local yearFraction = totalDaysElapsed / daysPerYear local psscYear = math.floor(yearFraction) local dayOfYear = math.floor((yearFraction - psscYear) * daysPerYear) + 1 return { psscYear = psscYear, dayOfYear = dayOfYear } end --------------------------------------------------------- -- 2. Determine the Season -- Spring: 1..61 -- Summer: 62..122 -- Fall/Winter: 123..183 --------------------------------------------------------- local function getSeason(dayOfYear) if dayOfYear <= 61 then return "Spring" elseif dayOfYear <= 122 then return "Summer" else return "Fall/Winter" end end --------------------------------------------------------- -- 3. Weather Events Table -- Keyed by spelled-out climate name -> season -> array of events --------------------------------------------------------- local climateEvents = { ["Humid Subtropical"] = { Spring = { "Light rain in the morning, sun breaks by afternoon", "Warm, breezy day with scattered sprinkles", "Cloudy skies, chance of mild thunderstorms", "Sunny spells with rising humidity", "Patchy fog early, clearing toward midday", "Gentle breeze, comfortable temperatures", "Overcast afternoon with drizzle" }, Summer = { "Hot and humid with afternoon thunderstorms", "Steamy day, high humidity, potential heat index", "Intermittent downpours, warm all day", "Sultry evening with lightning in the distance", "Sunny morning, hazy midday, scattered storms", "Damp overnight, lingering warm humidity", "Heat advisory in effect, minimal clouds" }, ["Fall/Winter"] = { "Warm daytime temperatures, mild nights", "Occasional rainfall with persistent warmth", "Cooler mornings, sunny afternoons", "Low humidity, slight chance of drizzle by dusk", "Partial cloud cover, gentle breezes", "Warm midday, late-evening shower chance", "Dawn fog, warm haze through late afternoon" } }, ["Oceanic"] = { Spring = { "Frequent light showers, fresh breeze", "Cool morning mist, moderate afternoon sun", "Variable cloudiness, gentle drizzle off and on", "Partly cloudy with hints of sunshine", "Occasional gusts, temperatures staying mild", "Patchy fog early, scattered rain midday", "Steady breeze keeping temperatures moderate" }, Summer = { "Mild temperatures, steady rain intervals", "Overcast skies with pleasant breezes", "Intermittent drizzle, comfortable humidity", "Sun breaks between passing showers", "Cloudy spells, occasional light rain", "Long periods of soft rainfall, mild all day", "Morning and evening drizzle, mild midday sun" }, ["Fall/Winter"] = { "Cool and damp, heavy clouds overhead", "Prolonged drizzle, breezy conditions", "Low visibility in morning fog, gradual clearing", "Passing showers with occasional gusts", "Chilly evenings, overcast all day", "Frequent light rain, temperatures staying cool", "Intermittent wind-driven rain, gray skies" } }, ["Subpolar Oceanic"] = { Spring = { "Cold mornings, patchy snow melt by afternoon", "Light rain mixed with wet flurries", "Breezy, near-freezing dawn warming slightly", "Overcast skies, damp winds through valleys", "Cool drizzle turning to sleet in late day", "Sun occasionally peeking through cloud deck", "Early frost, mild midday with possible showers" }, Summer = { "Short, cool days with off-and-on drizzle", "Overcast skies, constant low-hanging clouds", "Light rain, scattered breaks of weak sunshine", "Moist air with frequent mist in foothills", "Gentle breezes, chilly evenings despite summer", "Occasional bright spells, but generally gray", "Rain showers followed by cool, breezy nights" }, ["Fall/Winter"] = { "Snow flurries mixing with cold rain", "Prolonged cold, occasional freezing rain", "Heavy cloud cover, sleet in the afternoon", "Frequent snow showers, gusty winds", "Thick overcast, subfreezing nights", "Lake-effect rain-snow mix near large water bodies", "Wind chill making days feel colder" } }, ["Mediterranean (Hot Summer)"] = { Spring = { "Mild day, bright sun, low humidity", "Occasional shower, but mostly sunny", "Warm afternoon, cool evening breezes", "Clear sunrise, gentle inland wind", "Budding vegetation after light morning dew", "Sunny midday, scattered clouds by nightfall", "Light breeze, temperature steadily rising" }, Summer = { "Hot, dry heat with strong midday sun", "Clear skies, intense afternoon warmth", "Minimal rain, soaring temperatures", "Late evening breeze offering slight relief", "High UV index under cloudless skies", "Occasional dust carried by inland winds", "Parched landscapes, zero precipitation" }, ["Fall/Winter"] = { "Mild to cool days, some light rainfall", "Cloudy periods with gentle sea breezes", "Moderate temperatures, short bursts of rain", "Crisp mornings, pleasant afternoons", "Overcast nights, dew forming on fields", "Rain-laden front passing once a week", "Light wind with occasional heavier showers" } }, ["Hot Desert"] = { Spring = { "Warm days, cooler nights, cloudless skies", "Low humidity, moderate daytime heat", "Occasional dust devil, mostly clear conditions", "Dry air with gentle warming trend", "Sunny skies, evenings dropping in temperature", "Gusty winds stirring light sand", "Visibility high, no rainfall" }, Summer = { "Intense daytime heat, well above average", "Scorching midday, zero cloud cover", "Possible heat advisories, shimmering horizons", "Extremely dry air with frequent dust storms", "Sun sets late, relief only after dark", "Mirage-like conditions over open dunes", "No precipitation, parched desert floor" }, ["Fall/Winter"] = { "Warm sunlight, chilly nights", "Occasional wind picking up sand in gusts", "Sparse clouds, moderate daytime temps", "Stable conditions, large day-night range", "Sun-drenched afternoons, mild late evenings", "Periodic dust storms after frontal passages", "Minimal chance of any rain" } }, ["Cold Steppe"] = { Spring = { "Cool morning, warm midday sun, breezy", "Light rain showers across grasslands", "Variable cloud cover with mild gusts", "Patchy frost early, gradually warming", "Short bursts of sunshine, possible hail", "Clearing by afternoon, crisp dry air", "Temperature swings dawn to dusk" }, Summer = { "Warm daytime, occasional thunderstorms", "Hot afternoons, breezy, slight dryness", "Cloud buildup leading to scattered showers", "Clear early morning, gusty storms later", "Warm overall, cooler at night in open steppe", "Long sunlit evenings, thunder at dusk", "Rainfall minimal but not absent" }, ["Fall/Winter"] = { "Cool to cold days, frosty nights", "Occasional snow flurries on grassland", "Wind-driven chill under gray skies", "Sparse precipitation, dryness persists", "Temps below freezing after sunset", "Brisk winds, dusting of snow at times", "Sunny breaks mixed with sharp cold air" } }, ["Hot Steppe"] = { Spring = { "Hot day, low humidity, strong sunshine", "Gusty wind with dust swirling midday", "Warm mornings, hotter afternoons, no rain", "Sun exposure high, sparse vegetation", "Light breeze after sunset, starry night", "Some haze on horizon from dry soils", "Dry conditions, mild warming trend" }, Summer = { "Very hot, sporadic dust storms", "Scorching midday sun, high evaporation", "Light breezes but lingering heat", "Dust-laden air, minimal rainfall chance", "Warm nights with limited relief", "Periodic windy gusts raising dust plumes", "Enduring dryness, heat extremes persist" }, ["Fall/Winter"] = { "Hot days, warm evenings, stable dryness", "Rare rainfall, short bursts if clouds appear", "Temps remain high, some cooler nights", "Periodic hazy mornings from airborne dust", "Mild breezes, daytime remains hot", "Cloudless skies, slight drop in humidity", "Wind shifts occasionally bringing cooler gusts" } }, ["Subarctic"] = { Spring = { "Snow gradually melting, slushy paths", "Chilly breezes, frequent flurries possible", "Long nights slowly shortening, crisp mornings", "Light snowfall in higher elevations, cold rain lower", "Sunny breaks on clear days, sub-zero nights", "Occasional storms with mixed precipitation", "Icy patches remain until late season" }, Summer = { "Short, cool days, moderate sunshine", "Rainy spells, possible sleet in higher areas", "Snow line retreating, green valleys emerging", "Lengthy twilight, crisp air after sundown", "Sudden temperature dips even midday", "Drizzle common, heavy rainfall occasional", "Cool breezes from mountain passes" }, ["Fall/Winter"] = { "Early snowfall, ground freezing quickly", "Prolonged darkness, bitter cold sets in", "Gusty winds carrying ice crystals", "Heavy accumulations, drifting snowbanks", "Frequent sub-zero nights, minimal thaw", "Blizzard conditions with strong fronts", "Persistent ice coverage on lakes and rivers" } } } --------------------------------------------------------- -- 4. List of Cities, spelled out, no abbreviations --------------------------------------------------------- local cityData = { -- Major Cities in Bassaridia Vaeringheim {city = "Vaeringheim", climate = "Humid Subtropical"}, {city = "Luminaria", climate = "Oceanic"}, {city = "Serena", climate = "Subpolar Oceanic"}, {city = "Pyralis", climate = "Oceanic"}, {city = "Symphonara", climate = "Oceanic"}, {city = "Aurelia", climate = "Mediterranean (Hot Summer)"}, {city = "Somniumpolis", climate = "Humid Subtropical"}, {city = "Nexa", climate = "Oceanic"}, {city = "Lunalis Sancta", climate = "Oceanic"}, {city = "Sylvapolis", climate = "Humid Subtropical"}, -- Minor Cities in Bassaridia Vaeringheim {city = "Saluria", climate = "Oceanic"}, {city = "Aetherium", climate = "Subarctic"}, {city = "Ferrum Citadel", climate = "Hot Desert"}, {city = "Acheron", climate = "Cold Steppe"}, {city = "Erythros", climate = "Oceanic"}, {city = "Catonis Atrium", climate = "Oceanic"}, {city = "Delphica", climate = "Oceanic"}, {city = "Koinonía", climate = "Oceanic"}, {city = "Aureum", climate = "Mediterranean (Hot Summer)"}, -- Major Cities in New South Jangsong {city = "Skýrophos", climate = "Oceanic"}, {city = "Bjornopolis", climate = "Oceanic"}, {city = "Aegirheim", climate = "Subarctic"}, {city = "Norsolyra", climate = "Oceanic"}, {city = "Thorsalon", climate = "Oceanic"}, -- Minor Cities in New South Jangsong {city = "Pelagia", climate = "Hot Steppe"}, {city = "Myrene", climate = "Oceanic"}, {city = "Thyrea", climate = "Humid Subtropical"}, {city = "Ephyra", climate = "Subpolar Oceanic"}, {city = "Halicarn", climate = "Mediterranean (Hot Summer)"}, -- Major Cities in Haifan Bassaridia {city = "Keybir-Aviv", climate = "Humid Subtropical"}, {city = "Tel-Amin", climate = "Mediterranean (Hot Summer)"}, {city = "Diamandis", climate = "Mediterranean (Hot Summer)"}, {city = "Jogi", climate = "Oceanic"}, {city = "Lewisburg", climate = "Humid Subtropical"}, -- Minor Cities in Haifan Bassaridia {city = "Thermosalem", climate = "Oceanic"}, {city = "Akróstadium", climate = "Cold Steppe"}, {city = "Sufriya", climate = "Humid Subtropical"}, {city = "Lykopolis", climate = "Oceanic"} } --------------------------------------------------------- -- 5. Main Weather Forecast Function -- Called via {{#invoke:WeatherForecast|weatherForecast}} --------------------------------------------------------- function p.weatherForecast(frame) -- A) Determine the date and season local dateInfo = getCurrentDateInfo() local season = getSeason(dateInfo.dayOfYear) local output = {} table.insert(output, "== Daily Weather Forecast ==\n") table.insert(output, "''(Day " .. dateInfo.dayOfYear .. " of Year " .. dateInfo.psscYear .. " PSSC, " .. season .. ")''\n\n" ) -- B) Loop through each city for _, cityEntry in ipairs(cityData) do local cityName = cityEntry.city local climateName = cityEntry.climate local seasonTable = climateEvents[climateName] and climateEvents[climateName][season] local forecast = "No forecast data." if seasonTable and #seasonTable > 0 then local rndIndex = math.random(#seasonTable) forecast = seasonTable[rndIndex] end table.insert(output, "=== " .. cityName .. " ===\n") table.insert(output, "* '''Climate:''' " .. climateName .. "\n") table.insert(output, "* '''Season:''' " .. season .. "\n") table.insert(output, "* '''Today's Weather:''' " .. forecast .. "\n\n") end return table.concat(output) end return p