Module:BassaridiaForecast: Difference between revisions

From MicrasWiki
Jump to navigationJump to search
(Created page with "--------------------------------------------------------- -- 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 getCurrentDateIn...")
 
No edit summary
Line 1: Line 1:
---------------------------------------------------------
---------------------------------------------------------
-- Module:WeatherForecast
-- Module:WeatherForecastTable
-- Provides a daily weather forecast for each city
-- Generates a Wikipedia-style table of daily weather
-- using spelled-out climate names, a PSSC date system,
-- forecasts for each city in Bassaridia Vaeringheim,
-- and random event selection by season.
-- using spelled-out climate names, the PSSC date system,
-- up to 10 weather events per climate-season, and random
-- event selection.
---------------------------------------------------------
---------------------------------------------------------


Line 31: Line 33:


---------------------------------------------------------
---------------------------------------------------------
-- 2. Determine the Season
-- 2. Determine the Season by dayOfYear
--    Spring: 1..61
--    1..61       => Atosiel
--    Summer: 62..122
--    62..122     => Thalassiel
--    Fall/Winter: 123..183
--    123..183   => Opsitheiel
---------------------------------------------------------
---------------------------------------------------------


local function getSeason(dayOfYear)
local function getSeasonName(dayOfYear)
     if dayOfYear <= 61 then
     if dayOfYear <= 61 then
         return "Spring"
         return "Atosiel"
     elseif dayOfYear <= 122 then
     elseif dayOfYear <= 122 then
         return "Summer"
         return "Thalassiel"
     else
     else
         return "Fall/Winter"
         return "Opsitheiel"
     end
     end
end
end


---------------------------------------------------------
---------------------------------------------------------
-- 3. Weather Events Table
-- 3. Weather Events Table, up to 10 events per climate
--    Keyed by spelled-out climate name -> season -> array of events
--    for each of the 3 seasons (Atosiel, Thalassiel, Opsitheiel).
--   Feel free to expand these lists to as many as 20 if desired.
---------------------------------------------------------
---------------------------------------------------------


local climateEvents = {
local climateEvents = {
     ["Humid Subtropical"] = {
     ["Humid Subtropical"] = {
         Spring = {
         Atosiel = {
             "Light rain in the morning, sun breaks by afternoon",
             "Morning drizzle and warm afternoon sunshine",
             "Warm, breezy day with scattered sprinkles",
            "Mild thunderstorm building by midday",
             "Cloudy skies, chance of mild thunderstorms",
             "Patchy fog at dawn, clearing toward lunch",
             "Sunny spells with rising humidity",
            "Light rain with sunny breaks after noon",
             "Patchy fog early, clearing toward midday",
             "Gentle breezes, blossoming warmth, low humidity",
             "Gentle breeze, comfortable temperatures",
             "Scattered clouds with a brief shower by dusk",
             "Overcast afternoon with drizzle"
             "Humid sunrise, comfortable high around midday",
             "Overcast for part of the day, mild temperatures",
             "Warm breezes carrying faint floral scents",
            "Partial sun, warm with a slight chance of rain"
         },
         },
         Summer = {
         Thalassiel = {
             "Hot and humid with afternoon thunderstorms",
             "Hot, steamy day with intense midday heat",
             "Steamy day, high humidity, potential heat index",
             "Tropical-like humidity, afternoon thunder possible",
             "Intermittent downpours, warm all day",
             "Intermittent heavy downpours, muggy evenings",
             "Sultry evening with lightning in the distance",
             "High humidity and patchy thunderstorms late",
             "Sunny morning, hazy midday, scattered storms",
             "Sun-scorched morning, scattered storms by dusk",
             "Damp overnight, lingering warm humidity",
             "Hazy sunshine, extremely warm all day",
             "Heat advisory in effect, minimal clouds"
            "Thick humidity, chance of lightning late evening",
            "Sticky air, short downpours in isolated spots",
             "Heat advisory with only brief cooling at night",
            "Nighttime storms lingering into early morning"
         },
         },
         ["Fall/Winter"] = {
         Opsitheiel = {
             "Warm daytime temperatures, mild nights",
             "Warm daytime, gentle evening breezes",
             "Occasional rainfall with persistent warmth",
            "Occasional rain, otherwise mild temperatures",
             "Cooler mornings, sunny afternoons",
             "Late-season warmth, scattered rain after sunset",
             "Low humidity, slight chance of drizzle by dusk",
             "Cooler mornings, returning to warmth by midday",
             "Partial cloud cover, gentle breezes",
            "Sparse cloud cover, tranquil weather overall",
             "Warm midday, late-evening shower chance",
             "Fog at dawn, warm midday, pleasant night",
             "Dawn fog, warm haze through late afternoon"
             "Partial sun, comfortable humidity levels",
            "Evening drizzle with mild breezes",
             "Patchy haze, moderate warmth throughout the day",
             "Short-lived shower, then clearing skies"
         }
         }
     },
     },


     ["Oceanic"] = {
     ["Oceanic"] = {
         Spring = {
         Atosiel = {
             "Frequent light showers, fresh breeze",
             "Frequent light rain, cool breezes all day",
             "Cool morning mist, moderate afternoon sun",
             "Foggy dawn, mild midmorning sunshine",
             "Variable cloudiness, gentle drizzle off and on",
             "Short sunbreaks among passing showers",
             "Partly cloudy with hints of sunshine",
            "Consistent drizzle, fresh winds from the sea",
             "Occasional gusts, temperatures staying mild",
             "Cloudy intervals with a few bright spells",
             "Patchy fog early, scattered rain midday",
            "Late-afternoon clearing, crisp evening air",
             "Steady breeze keeping temperatures moderate"
             "Slow-moving clouds, mild temperatures",
             "Gentle but persistent rain, green foliage thriving",
            "Off-and-on showers, brief sunny interludes",
             "Steady breeze, moderate humidity levels"
         },
         },
         Summer = {
         Thalassiel = {
             "Mild temperatures, steady rain intervals",
             "Light rain off and on, mild temperatures",
             "Overcast skies with pleasant breezes",
             "Overcast with comfortable breezes throughout",
             "Intermittent drizzle, comfortable humidity",
             "Drizzly morning, partly cloudy afternoon",
             "Sun breaks between passing showers",
            "Soft rains, lush vegetation, stable temps",
             "Cloudy spells, occasional light rain",
             "Cool, damp start, drying toward evening",
             "Long periods of soft rainfall, mild all day",
             "Frequent cloud cover, gentle summer breeze",
             "Morning and evening drizzle, mild midday sun"
            "Moist air with lingering fog near streams",
             "Rain-laden air, occasional breaks of sun",
            "Maritime winds bringing light spray inland",
             "Cloudy midday, mild sunshine before dusk"
         },
         },
         ["Fall/Winter"] = {
         Opsitheiel = {
             "Cool and damp, heavy clouds overhead",
             "Overcast skies, cool drizzle through the day",
             "Prolonged drizzle, breezy conditions",
             "Sporadic showers, chillier in the evening",
             "Low visibility in morning fog, gradual clearing",
             "Low visibility in morning fog, slow clearing",
             "Passing showers with occasional gusts",
             "Gray skies, frequent rain squalls, cool wind",
             "Chilly evenings, overcast all day",
             "Chilly nightfall, damp ground all day",
             "Frequent light rain, temperatures staying cool",
             "Heavier showers arriving late afternoon",
             "Intermittent wind-driven rain, gray skies"
            "Periodic drizzle, temperatures on the cool side",
            "Morning gloom, occasional pockets of clearing",
            "Evening rainfall pushing in from the coast",
             "Dense cloud cover, breezy and damp"
         }
         }
     },
     },


     ["Subpolar Oceanic"] = {
     ["Subpolar Oceanic"] = {
         Spring = {
         Atosiel = {
             "Cold mornings, patchy snow melt by afternoon",
             "Near-freezing dawn, cold drizzle by midday",
             "Light rain mixed with wet flurries",
            "Mist over melting snow patches, breezy afternoon",
             "Breezy, near-freezing dawn warming slightly",
             "Overcast skies, mix of rain and sleet",
             "Overcast skies, damp winds through valleys",
             "Cool, damp air, slight warmup after noon",
             "Cool drizzle turning to sleet in late day",
            "Late-day sleet turning to light rain",
             "Sun occasionally peeking through cloud deck",
             "Mountaintop flurries, valley drizzle",
             "Early frost, mild midday with possible showers"
             "Cloudy morning, partial clearing in late afternoon",
             "Chilly breeze, scattered showers off and on",
             "Gray skies, some slushy buildup on paths",
            "Snowmelt water raising local streams"
         },
         },
         Summer = {
         Thalassiel = {
             "Short, cool days with off-and-on drizzle",
             "Cool, short days with periodic drizzle",
             "Overcast skies, constant low-hanging clouds",
             "Heavy low clouds, pockets of bright breaks",
             "Light rain, scattered breaks of weak sunshine",
             "Gentle rain, evening chill deeper than normal",
             "Moist air with frequent mist in foothills",
            "Intermittent showers, damp wind from hills",
             "Gentle breezes, chilly evenings despite summer",
            "Cloud deck lingering, occasional lighter drizzle",
             "Occasional bright spells, but generally gray",
             "Faint sunlight, overshadowed by thick cloud",
             "Rain showers followed by cool, breezy nights"
             "Subdued warmth, sporadic mist across ridges",
             "Surprisingly bright morning, clouding by dusk",
             "Short bursts of rain followed by fog",
            "Late-night chill with drizzle or brief sleet"
         },
         },
         ["Fall/Winter"] = {
         Opsitheiel = {
             "Snow flurries mixing with cold rain",
             "Steady cold rain mixing with wet snow",
             "Prolonged cold, occasional freezing rain",
            "Freezing drizzle at dawn, raw gusty winds",
             "Heavy cloud cover, sleet in the afternoon",
             "Snowfall likely at higher elevations, rain below",
             "Frequent snow showers, gusty winds",
             "Cloudy, damp day with potential sleet storms",
             "Thick overcast, subfreezing nights",
             "Early morning frost turning to slush midday",
             "Lake-effect rain-snow mix near large water bodies",
            "Occasional heavy showers with flurry bursts",
             "Wind chill making days feel colder"
             "Gray gloom, subfreezing nights across valleys",
             "Pelting sleet for an hour, then calm, cold air",
            "Gusty evening, possible snow accumulations",
             "Sun rarely visible, persistent winter gloom"
         }
         }
     },
     },


     ["Mediterranean (Hot Summer)"] = {
     ["Mediterranean (Hot Summer)"] = {
         Spring = {
         Atosiel = {
             "Mild day, bright sun, low humidity",
             "Mild temperatures, bright sunshine, dry air",
             "Occasional shower, but mostly sunny",
             "Morning dew, warming fast under clear skies",
             "Warm afternoon, cool evening breezes",
             "Cool breezes off the sea, comfortable afternoon",
             "Clear sunrise, gentle inland wind",
            "Sunny midday with a crisp, light wind",
             "Budding vegetation after light morning dew",
             "Short drizzly spell, then mostly clear",
             "Sunny midday, scattered clouds by nightfall",
             "Early bloom across hills, moderate warmth",
             "Light breeze, temperature steadily rising"
             "Mostly sunny, a few scattered clouds late",
            "Light shower possible at sunrise, drying by noon",
             "Warming trend, low humidity, pleasant day",
            "Gradual warming under spotless sky"
         },
         },
         Summer = {
         Thalassiel = {
             "Hot, dry heat with strong midday sun",
             "Very hot midday sun, minimal clouds",
             "Clear skies, intense afternoon warmth",
             "Scorching days, slight breeze at dusk",
             "Minimal rain, soaring temperatures",
            "Parched hillsides, no sign of rainfall",
             "Late evening breeze offering slight relief",
            "High UV index, bright, glaring sunlight",
             "High UV index under cloudless skies",
             "Coastal dryness, strong midday glare",
             "Occasional dust carried by inland winds",
             "Overnight relief, but intense heat returns early",
             "Parched landscapes, zero precipitation"
            "Dust in the wind from inland hills",
             "Cloudless sky, near-record high temps",
             "Salt-laden breezes if near the coast, scorching inland",
             "Heatwaves persisting, zero rain expected"
         },
         },
         ["Fall/Winter"] = {
         Opsitheiel = {
             "Mild to cool days, some light rainfall",
             "Cooler spells, brief showery intervals",
             "Cloudy periods with gentle sea breezes",
             "Cloudy periods bringing mild relief from heat",
             "Moderate temperatures, short bursts of rain",
            "Pleasant afternoons, occasional dusk rains",
             "Crisp mornings, pleasant afternoons",
             "Moderate days, crisp mornings, calm nights",
             "Overcast nights, dew forming on fields",
             "Sporadic light rainfall, refreshing breezes",
             "Rain-laden front passing once a week",
             "Cloudbanks drifting inland, mild drizzle at times",
             "Light wind with occasional heavier showers"
             "Patchy overcast, comfortable midday temps",
             "Clear dawn, mild sunshine, gentle wind late",
            "Intervals of cloud cover, potential short rain",
            "Moist sea air, moderate daytime warmth"
         }
         }
     },
     },


     ["Hot Desert"] = {
     ["Hot Desert"] = {
         Spring = {
         Atosiel = {
             "Warm days, cooler nights, cloudless skies",
             "Hot afternoons, cooler late nights, wide temp swing",
             "Low humidity, moderate daytime heat",
            "Dry air, bright sunshine, no clouds in sight",
             "Occasional dust devil, mostly clear conditions",
             "Gentle breezes raising light sand by midday",
             "Dry air with gentle warming trend",
            "Evening chill setting in after hot daytime",
             "Sunny skies, evenings dropping in temperature",
             "Minor dust devil scouring the dunes",
             "Gusty winds stirring light sand",
            "Visibility excellent, stable high pressure",
             "Visibility high, no rainfall"
             "Patchy desert haze, strong sun overhead",
             "No hint of precipitation, cloudless horizon",
             "Daytime warmth, refreshing if slight breeze arrives",
             "Sun-warmed rock surfaces, mild nights"
         },
         },
         Summer = {
         Thalassiel = {
             "Intense daytime heat, well above average",
             "Extreme heat from mid-morning onward",
             "Scorching midday, zero cloud cover",
            "Blistering midday sun, risk of heat stroke",
             "Possible heat advisories, shimmering horizons",
             "Near-record highs, swirling dust at times",
             "Extremely dry air with frequent dust storms",
             "Virtually no clouds, scorching open sands",
             "Sun sets late, relief only after dark",
             "Occasional dust storm cutting visibility briefly",
             "Mirage-like conditions over open dunes",
             "Mirage-like shimmer across flat terrain",
             "No precipitation, parched desert floor"
            "Sunset brings partial relief, still quite warm",
             "Dry conditions, subpar humidity all day",
             "Baking desert floor, potential for blowing sand",
            "Intense heat building day after day"
         },
         },
         ["Fall/Winter"] = {
         Opsitheiel = {
             "Warm sunlight, chilly nights",
             "Warm, mostly sunny with cooler nights",
             "Occasional wind picking up sand in gusts",
             "Sparse winds carrying fine sand sporadically",
             "Sparse clouds, moderate daytime temps",
             "Large day-night temperature gap, no precipitation",
             "Stable conditions, large day-night range",
             "Stable conditions, sunlit afternoons, brisk evenings",
             "Sun-drenched afternoons, mild late evenings",
            "Mildly hot days, star-filled clear skies at night",
             "Periodic dust storms after frontal passages",
             "Shallow dust clouds after brief winds",
             "Minimal chance of any rain"
            "Occasional gust picking up desert grit",
            "Gentle warmth, dryness prevalent, no clouds",
             "Cool breezes shortly after sunset, mild day overall",
             "Hazy horizon, soft morning glow across dunes"
         }
         }
     },
     },


     ["Cold Steppe"] = {
     ["Cold Steppe"] = {
         Spring = {
         Atosiel = {
             "Cool morning, warm midday sun, breezy",
             "Cool mornings, moderate midday warmth, breezy",
             "Light rain showers across grasslands",
             "Light rain passing through grasslands midday",
             "Variable cloud cover with mild gusts",
             "Variable cloud cover, mild temperature swings",
             "Patchy frost early, gradually warming",
             "Patchy frost at dawn, warming soon after",
             "Short bursts of sunshine, possible hail",
             "Crisp air, possible small hail if storms appear",
             "Clearing by afternoon, crisp dry air",
            "Sunny afternoon, cooler late evening",
             "Temperature swings dawn to dusk"
            "Gentle breeze, fleeting sun amidst scattered clouds",
             "Slow temperature rise, slight dryness in mid-afternoon",
            "Brief drizzle, otherwise bright and breezy",
             "Day-night difference noticeable, mild but windy"
         },
         },
         Summer = {
         Thalassiel = {
             "Warm daytime, occasional thunderstorms",
             "Warm day, potential for gusty thunderstorms",
             "Hot afternoons, breezy, slight dryness",
             "Hot midday sun, dryness intensifying by late day",
             "Cloud buildup leading to scattered showers",
             "Cloud buildup, short but intense showers possible",
             "Clear early morning, gusty storms later",
             "Clear morning, chance of late afternoon storms",
             "Warm overall, cooler at night in open steppe",
            "Long daylight hours, rolling thunder near dusk",
             "Long sunlit evenings, thunder at dusk",
            "Slight dryness, patchy heat with limited shade",
             "Rainfall minimal but not absent"
            "Periodic storms bringing relief from heat",
             "Warm evening, slight nighttime cooldown",
             "Sky remains mostly clear, grassland shimmering",
             "Thunderheads visible in distance, might pass by"
         },
         },
         ["Fall/Winter"] = {
         Opsitheiel = {
             "Cool to cold days, frosty nights",
             "Cool to cold days, frosty nights on open steppe",
             "Occasional snow flurries on grassland",
             "Possible light snowfall, especially overnight",
             "Wind-driven chill under gray skies",
             "Wind-driven chill under gray skies",
             "Sparse precipitation, dryness persists",
             "Sparse precipitation, dryness persists, cold air",
             "Temps below freezing after sunset",
             "Subfreezing after sunset, sometimes sunny midday",
             "Brisk winds, dusting of snow at times",
             "Short bursts of sunshine, otherwise chilly conditions",
             "Sunny breaks mixed with sharp cold air"
            "Occasional dusting of snow, quickly melting by noon",
             "Biting wind, few clouds, stark horizon",
            "Clearing late morning, crisp, cold nightfall",
            "Daytime near freezing, nights well below"
         }
         }
     },
     },


     ["Hot Steppe"] = {
     ["Hot Steppe"] = {
         Spring = {
         Atosiel = {
             "Hot day, low humidity, strong sunshine",
             "Hot daytime sun, slight breeze, no rain",
             "Gusty wind with dust swirling midday",
             "Gusty wind with dust swirling near midday",
             "Warm mornings, hotter afternoons, no rain",
             "Warm mornings, scorching afternoon, very low humidity",
            "Sun exposure high, sparse vegetation",
             "Light breeze after sundown, starry overhead",
             "Light breeze after sunset, starry night",
             "Some haze from heated ground, minimal cloud cover",
             "Some haze on horizon from dry soils",
            "Sun intensity rising toward midday peak",
             "Dry conditions, mild warming trend"
             "Dry soil conditions, no sign of moisture",
            "Sparse vegetation, daily heat climbing gradually",
            "Clear horizon, wind picking up in late evening",
            "Sun exposure high, consistent dryness"
         },
         },
         Summer = {
         Thalassiel = {
             "Very hot, sporadic dust storms",
             "Brutally hot midday sun, patchy dust storms",
             "Scorching midday sun, high evaporation",
             "Scorching conditions, faint breeze offers minimal relief",
             "Light breezes but lingering heat",
            "Occasional swirling wind gusts, drifting dust",
             "Dust-laden air, minimal rainfall chance",
            "Heated ground emits rippling mirages at distance",
             "Warm nights with limited relief",
            "Persistent dryness, minimal nighttime cooldown",
             "Periodic windy gusts raising dust plumes",
             "Skies remain cloudless, high evaporation rate",
             "Enduring dryness, heat extremes persist"
             "Dust-laden air in late afternoon swirl",
             "Rare cloud can appear but quickly vanishes",
             "Daily highs remain extreme, nights only mild",
             "Lingering warmth through sunset, dryness unwavering"
         },
         },
         ["Fall/Winter"] = {
         Opsitheiel = {
             "Hot days, warm evenings, stable dryness",
             "Hot days, moderate evenings, stable dryness",
             "Rare rainfall, short bursts if clouds appear",
             "Rare short rains if storm fronts approach, mostly none",
             "Temps remain high, some cooler nights",
             "Daytime heat lingering, nights slightly cooler",
             "Periodic hazy mornings from airborne dust",
             "Periodically hazy morning from airborne dust",
             "Mild breezes, daytime remains hot",
             "Mild breezes, daytime remains intensely hot",
             "Cloudless skies, slight drop in humidity",
             "Cloudless skies, gentle drop in temps overnight",
             "Wind shifts occasionally bringing cooler gusts"
             "Dust devils possible over parched plains",
            "Occasional relief from mild wind, no precipitation",
            "Hot, tranquil afternoon, moderate wind at dusk",
            "Minimal cloud presence, dryness dominating environment"
         }
         }
     },
     },


     ["Subarctic"] = {
     ["Subarctic"] = {
         Spring = {
         Atosiel = {
             "Snow gradually melting, slushy paths",
             "Snow melting, slushy paths, daytime sunshine",
             "Chilly breezes, frequent flurries possible",
             "Chilly breezes, frequent flurry patches possible",
             "Long nights slowly shortening, crisp mornings",
             "Long nights gradually shortening, crisp mornings",
             "Light snowfall in higher elevations, cold rain lower",
             "Mixed precipitation, cold rain at lower altitudes",
             "Sunny breaks on clear days, sub-zero nights",
            "Slush build-up midmorning, partial sun midday",
             "Occasional storms with mixed precipitation",
             "Sunny breaks around noon, subzero by late night",
             "Icy patches remain until late season"
             "Sporadic storm with sleet or melting snow",
             "Icy patches linger, overall chilly but bright",
            "Early thaw, mild midday, returning chill after dusk",
            "Reluctant spring with freezing nights, slow warm days"
         },
         },
         Summer = {
         Thalassiel = {
             "Short, cool days, moderate sunshine",
             "Short, cool days, moderate sunshine at times",
             "Rainy spells, possible sleet in higher areas",
             "Rainy intervals, potential sleet in highest peaks",
             "Snow line retreating, green valleys emerging",
             "Snow line retreating, green valleys emerging slowly",
             "Lengthy twilight, crisp air after sundown",
             "Extended twilight, crisp air after sundown",
             "Sudden temperature dips even midday",
             "Sudden midafternoon chill despite mid-summer period",
             "Drizzle common, heavy rainfall occasional",
             "Drizzle commonly, heavier rainfall occasionally",
             "Cool breezes from mountain passes"
            "Mountain passes remain cool, breezy conditions",
            "Mostly cloudy, occasional glimpses of sun",
             "Brisk wind, earlier nightfall than lower latitudes",
            "Daytime highs remain mild, nights quite cold"
         },
         },
         ["Fall/Winter"] = {
         Opsitheiel = {
             "Early snowfall, ground freezing quickly",
             "Early snowfall returning, freezing ground rapidly",
             "Prolonged darkness, bitter cold sets in",
             "Prolonged darkness, bitterness sets in quickly",
             "Gusty winds carrying ice crystals",
             "Gusty winds carrying ice crystals through valleys",
             "Heavy accumulations, drifting snowbanks",
             "Heavy drifts forming, multiple snowfall events",
             "Frequent sub-zero nights, minimal thaw",
             "Frequent subzero lows, no hint of thaw",
             "Blizzard conditions with strong fronts",
             "Blizzard-like conditions with large snow accumulations",
             "Persistent ice coverage on lakes and rivers"
             "Icy rivers, widespread frost in daylight",
            "Mountains see near-constant snow, valleys freeze nightly",
            "Rare clear spells, intense wind chill outside",
            "Deep winter mode, swirling snow flurries all day"
         }
         }
     }
     }
Line 295: Line 370:


---------------------------------------------------------
---------------------------------------------------------
-- 4. List of Cities, spelled out, no abbreviations
-- 4. List of Cities (Spelled Out, No Abbreviations)
---------------------------------------------------------
---------------------------------------------------------


Line 351: Line 426:


---------------------------------------------------------
---------------------------------------------------------
-- 5. Main Weather Forecast Function
-- 5. Main Weather Forecast Table Function
--    Called via {{#invoke:WeatherForecast|weatherForecast}}
---------------------------------------------------------
---------------------------------------------------------


function p.weatherForecast(frame)
function p.weatherForecast(frame)
    -- A) Determine the date and season
     local dateInfo = getCurrentDateInfo()
     local dateInfo = getCurrentDateInfo()
     local season = getSeason(dateInfo.dayOfYear)
     local dayOfYear = dateInfo.dayOfYear
    local yearNumber = dateInfo.psscYear


    local seasonName = getSeasonName(dayOfYear)
    -- Start building wiki output
     local output = {}
     local output = {}
     table.insert(output, "== Daily Weather Forecast ==\n")
     table.insert(output, "== Daily Weather Forecast ==\n")
     table.insert(output, "''(Day " .. dateInfo.dayOfYear
     table.insert(output, "''(Day " .. dayOfYear
         .. " of Year " .. dateInfo.psscYear
         .. " of Year " .. yearNumber
         .. " PSSC, " .. season .. ")''\n\n"
         .. " PSSC, " .. seasonName .. ")''\n\n"
     )
     )


     -- B) Loop through each city
     -- Begin table
    table.insert(output, '{| class="wikitable sortable" style="width:100%; text-align:left;"\n')
    table.insert(output, '! City !! Climate !! Season !! Today’s Weather\n')
 
    -- For each city, pick one random event from climateEvents
     for _, cityEntry in ipairs(cityData) do
     for _, cityEntry in ipairs(cityData) do
         local cityName = cityEntry.city
         local cityName = cityEntry.city
         local climateName = cityEntry.climate
         local climateName = cityEntry.climate


         local seasonTable = climateEvents[climateName] and climateEvents[climateName][season]
         local climateTable = climateEvents[climateName]
         local forecast = "No forecast data."
        local seasonTable = climateTable and climateTable[seasonName]
         local forecast = "No weather data."


         if seasonTable and #seasonTable > 0 then
         if seasonTable and #seasonTable > 0 then
Line 380: Line 463:
         end
         end


         table.insert(output, "=== " .. cityName .. " ===\n")
         table.insert(output, "|-\n")
         table.insert(output, "* '''Climate:''' " .. climateName .. "\n")
         table.insert(output, "| " .. cityName .. " || " .. climateName .. " || " .. seasonName .. " || " .. forecast .. "\n")
        table.insert(output, "* '''Season:''' " .. season .. "\n")
        table.insert(output, "* '''Today's Weather:''' " .. forecast .. "\n\n")
     end
     end
    -- Close table
    table.insert(output, "|}\n")


     return table.concat(output)
     return table.concat(output)

Revision as of 03:23, 26 December 2024

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

---------------------------------------------------------
-- Module:WeatherForecastTable
-- Generates a Wikipedia-style table of daily weather
-- forecasts for each city in Bassaridia Vaeringheim,
-- using spelled-out climate names, the PSSC date system,
-- up to 10 weather events per climate-season, and random
-- event selection.
---------------------------------------------------------

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 by dayOfYear
--    1..61       => Atosiel
--    62..122     => Thalassiel
--    123..183    => Opsitheiel
---------------------------------------------------------

local function getSeasonName(dayOfYear)
    if dayOfYear <= 61 then
        return "Atosiel"
    elseif dayOfYear <= 122 then
        return "Thalassiel"
    else
        return "Opsitheiel"
    end
end

---------------------------------------------------------
-- 3. Weather Events Table, up to 10 events per climate
--    for each of the 3 seasons (Atosiel, Thalassiel, Opsitheiel).
--    Feel free to expand these lists to as many as 20 if desired.
---------------------------------------------------------

local climateEvents = {
    ["Humid Subtropical"] = {
        Atosiel = {
            "Morning drizzle and warm afternoon sunshine",
            "Mild thunderstorm building by midday",
            "Patchy fog at dawn, clearing toward lunch",
            "Light rain with sunny breaks after noon",
            "Gentle breezes, blossoming warmth, low humidity",
            "Scattered clouds with a brief shower by dusk",
            "Humid sunrise, comfortable high around midday",
            "Overcast for part of the day, mild temperatures",
            "Warm breezes carrying faint floral scents",
            "Partial sun, warm with a slight chance of rain"
        },
        Thalassiel = {
            "Hot, steamy day with intense midday heat",
            "Tropical-like humidity, afternoon thunder possible",
            "Intermittent heavy downpours, muggy evenings",
            "High humidity and patchy thunderstorms late",
            "Sun-scorched morning, scattered storms by dusk",
            "Hazy sunshine, extremely warm all day",
            "Thick humidity, chance of lightning late evening",
            "Sticky air, short downpours in isolated spots",
            "Heat advisory with only brief cooling at night",
            "Nighttime storms lingering into early morning"
        },
        Opsitheiel = {
            "Warm daytime, gentle evening breezes",
            "Occasional rain, otherwise mild temperatures",
            "Late-season warmth, scattered rain after sunset",
            "Cooler mornings, returning to warmth by midday",
            "Sparse cloud cover, tranquil weather overall",
            "Fog at dawn, warm midday, pleasant night",
            "Partial sun, comfortable humidity levels",
            "Evening drizzle with mild breezes",
            "Patchy haze, moderate warmth throughout the day",
            "Short-lived shower, then clearing skies"
        }
    },

    ["Oceanic"] = {
        Atosiel = {
            "Frequent light rain, cool breezes all day",
            "Foggy dawn, mild midmorning sunshine",
            "Short sunbreaks among passing showers",
            "Consistent drizzle, fresh winds from the sea",
            "Cloudy intervals with a few bright spells",
            "Late-afternoon clearing, crisp evening air",
            "Slow-moving clouds, mild temperatures",
            "Gentle but persistent rain, green foliage thriving",
            "Off-and-on showers, brief sunny interludes",
            "Steady breeze, moderate humidity levels"
        },
        Thalassiel = {
            "Light rain off and on, mild temperatures",
            "Overcast with comfortable breezes throughout",
            "Drizzly morning, partly cloudy afternoon",
            "Soft rains, lush vegetation, stable temps",
            "Cool, damp start, drying toward evening",
            "Frequent cloud cover, gentle summer breeze",
            "Moist air with lingering fog near streams",
            "Rain-laden air, occasional breaks of sun",
            "Maritime winds bringing light spray inland",
            "Cloudy midday, mild sunshine before dusk"
        },
        Opsitheiel = {
            "Overcast skies, cool drizzle through the day",
            "Sporadic showers, chillier in the evening",
            "Low visibility in morning fog, slow clearing",
            "Gray skies, frequent rain squalls, cool wind",
            "Chilly nightfall, damp ground all day",
            "Heavier showers arriving late afternoon",
            "Periodic drizzle, temperatures on the cool side",
            "Morning gloom, occasional pockets of clearing",
            "Evening rainfall pushing in from the coast",
            "Dense cloud cover, breezy and damp"
        }
    },

    ["Subpolar Oceanic"] = {
        Atosiel = {
            "Near-freezing dawn, cold drizzle by midday",
            "Mist over melting snow patches, breezy afternoon",
            "Overcast skies, mix of rain and sleet",
            "Cool, damp air, slight warmup after noon",
            "Late-day sleet turning to light rain",
            "Mountaintop flurries, valley drizzle",
            "Cloudy morning, partial clearing in late afternoon",
            "Chilly breeze, scattered showers off and on",
            "Gray skies, some slushy buildup on paths",
            "Snowmelt water raising local streams"
        },
        Thalassiel = {
            "Cool, short days with periodic drizzle",
            "Heavy low clouds, pockets of bright breaks",
            "Gentle rain, evening chill deeper than normal",
            "Intermittent showers, damp wind from hills",
            "Cloud deck lingering, occasional lighter drizzle",
            "Faint sunlight, overshadowed by thick cloud",
            "Subdued warmth, sporadic mist across ridges",
            "Surprisingly bright morning, clouding by dusk",
            "Short bursts of rain followed by fog",
            "Late-night chill with drizzle or brief sleet"
        },
        Opsitheiel = {
            "Steady cold rain mixing with wet snow",
            "Freezing drizzle at dawn, raw gusty winds",
            "Snowfall likely at higher elevations, rain below",
            "Cloudy, damp day with potential sleet storms",
            "Early morning frost turning to slush midday",
            "Occasional heavy showers with flurry bursts",
            "Gray gloom, subfreezing nights across valleys",
            "Pelting sleet for an hour, then calm, cold air",
            "Gusty evening, possible snow accumulations",
            "Sun rarely visible, persistent winter gloom"
        }
    },

    ["Mediterranean (Hot Summer)"] = {
        Atosiel = {
            "Mild temperatures, bright sunshine, dry air",
            "Morning dew, warming fast under clear skies",
            "Cool breezes off the sea, comfortable afternoon",
            "Sunny midday with a crisp, light wind",
            "Short drizzly spell, then mostly clear",
            "Early bloom across hills, moderate warmth",
            "Mostly sunny, a few scattered clouds late",
            "Light shower possible at sunrise, drying by noon",
            "Warming trend, low humidity, pleasant day",
            "Gradual warming under spotless sky"
        },
        Thalassiel = {
            "Very hot midday sun, minimal clouds",
            "Scorching days, slight breeze at dusk",
            "Parched hillsides, no sign of rainfall",
            "High UV index, bright, glaring sunlight",
            "Coastal dryness, strong midday glare",
            "Overnight relief, but intense heat returns early",
            "Dust in the wind from inland hills",
            "Cloudless sky, near-record high temps",
            "Salt-laden breezes if near the coast, scorching inland",
            "Heatwaves persisting, zero rain expected"
        },
        Opsitheiel = {
            "Cooler spells, brief showery intervals",
            "Cloudy periods bringing mild relief from heat",
            "Pleasant afternoons, occasional dusk rains",
            "Moderate days, crisp mornings, calm nights",
            "Sporadic light rainfall, refreshing breezes",
            "Cloudbanks drifting inland, mild drizzle at times",
            "Patchy overcast, comfortable midday temps",
            "Clear dawn, mild sunshine, gentle wind late",
            "Intervals of cloud cover, potential short rain",
            "Moist sea air, moderate daytime warmth"
        }
    },

    ["Hot Desert"] = {
        Atosiel = {
            "Hot afternoons, cooler late nights, wide temp swing",
            "Dry air, bright sunshine, no clouds in sight",
            "Gentle breezes raising light sand by midday",
            "Evening chill setting in after hot daytime",
            "Minor dust devil scouring the dunes",
            "Visibility excellent, stable high pressure",
            "Patchy desert haze, strong sun overhead",
            "No hint of precipitation, cloudless horizon",
            "Daytime warmth, refreshing if slight breeze arrives",
            "Sun-warmed rock surfaces, mild nights"
        },
        Thalassiel = {
            "Extreme heat from mid-morning onward",
            "Blistering midday sun, risk of heat stroke",
            "Near-record highs, swirling dust at times",
            "Virtually no clouds, scorching open sands",
            "Occasional dust storm cutting visibility briefly",
            "Mirage-like shimmer across flat terrain",
            "Sunset brings partial relief, still quite warm",
            "Dry conditions, subpar humidity all day",
            "Baking desert floor, potential for blowing sand",
            "Intense heat building day after day"
        },
        Opsitheiel = {
            "Warm, mostly sunny with cooler nights",
            "Sparse winds carrying fine sand sporadically",
            "Large day-night temperature gap, no precipitation",
            "Stable conditions, sunlit afternoons, brisk evenings",
            "Mildly hot days, star-filled clear skies at night",
            "Shallow dust clouds after brief winds",
            "Occasional gust picking up desert grit",
            "Gentle warmth, dryness prevalent, no clouds",
            "Cool breezes shortly after sunset, mild day overall",
            "Hazy horizon, soft morning glow across dunes"
        }
    },

    ["Cold Steppe"] = {
        Atosiel = {
            "Cool mornings, moderate midday warmth, breezy",
            "Light rain passing through grasslands midday",
            "Variable cloud cover, mild temperature swings",
            "Patchy frost at dawn, warming soon after",
            "Crisp air, possible small hail if storms appear",
            "Sunny afternoon, cooler late evening",
            "Gentle breeze, fleeting sun amidst scattered clouds",
            "Slow temperature rise, slight dryness in mid-afternoon",
            "Brief drizzle, otherwise bright and breezy",
            "Day-night difference noticeable, mild but windy"
        },
        Thalassiel = {
            "Warm day, potential for gusty thunderstorms",
            "Hot midday sun, dryness intensifying by late day",
            "Cloud buildup, short but intense showers possible",
            "Clear morning, chance of late afternoon storms",
            "Long daylight hours, rolling thunder near dusk",
            "Slight dryness, patchy heat with limited shade",
            "Periodic storms bringing relief from heat",
            "Warm evening, slight nighttime cooldown",
            "Sky remains mostly clear, grassland shimmering",
            "Thunderheads visible in distance, might pass by"
        },
        Opsitheiel = {
            "Cool to cold days, frosty nights on open steppe",
            "Possible light snowfall, especially overnight",
            "Wind-driven chill under gray skies",
            "Sparse precipitation, dryness persists, cold air",
            "Subfreezing after sunset, sometimes sunny midday",
            "Short bursts of sunshine, otherwise chilly conditions",
            "Occasional dusting of snow, quickly melting by noon",
            "Biting wind, few clouds, stark horizon",
            "Clearing late morning, crisp, cold nightfall",
            "Daytime near freezing, nights well below"
        }
    },

    ["Hot Steppe"] = {
        Atosiel = {
            "Hot daytime sun, slight breeze, no rain",
            "Gusty wind with dust swirling near midday",
            "Warm mornings, scorching afternoon, very low humidity",
            "Light breeze after sundown, starry overhead",
            "Some haze from heated ground, minimal cloud cover",
            "Sun intensity rising toward midday peak",
            "Dry soil conditions, no sign of moisture",
            "Sparse vegetation, daily heat climbing gradually",
            "Clear horizon, wind picking up in late evening",
            "Sun exposure high, consistent dryness"
        },
        Thalassiel = {
            "Brutally hot midday sun, patchy dust storms",
            "Scorching conditions, faint breeze offers minimal relief",
            "Occasional swirling wind gusts, drifting dust",
            "Heated ground emits rippling mirages at distance",
            "Persistent dryness, minimal nighttime cooldown",
            "Skies remain cloudless, high evaporation rate",
            "Dust-laden air in late afternoon swirl",
            "Rare cloud can appear but quickly vanishes",
            "Daily highs remain extreme, nights only mild",
            "Lingering warmth through sunset, dryness unwavering"
        },
        Opsitheiel = {
            "Hot days, moderate evenings, stable dryness",
            "Rare short rains if storm fronts approach, mostly none",
            "Daytime heat lingering, nights slightly cooler",
            "Periodically hazy morning from airborne dust",
            "Mild breezes, daytime remains intensely hot",
            "Cloudless skies, gentle drop in temps overnight",
            "Dust devils possible over parched plains",
            "Occasional relief from mild wind, no precipitation",
            "Hot, tranquil afternoon, moderate wind at dusk",
            "Minimal cloud presence, dryness dominating environment"
        }
    },

    ["Subarctic"] = {
        Atosiel = {
            "Snow melting, slushy paths, daytime sunshine",
            "Chilly breezes, frequent flurry patches possible",
            "Long nights gradually shortening, crisp mornings",
            "Mixed precipitation, cold rain at lower altitudes",
            "Slush build-up midmorning, partial sun midday",
            "Sunny breaks around noon, subzero by late night",
            "Sporadic storm with sleet or melting snow",
            "Icy patches linger, overall chilly but bright",
            "Early thaw, mild midday, returning chill after dusk",
            "Reluctant spring with freezing nights, slow warm days"
        },
        Thalassiel = {
            "Short, cool days, moderate sunshine at times",
            "Rainy intervals, potential sleet in highest peaks",
            "Snow line retreating, green valleys emerging slowly",
            "Extended twilight, crisp air after sundown",
            "Sudden midafternoon chill despite mid-summer period",
            "Drizzle commonly, heavier rainfall occasionally",
            "Mountain passes remain cool, breezy conditions",
            "Mostly cloudy, occasional glimpses of sun",
            "Brisk wind, earlier nightfall than lower latitudes",
            "Daytime highs remain mild, nights quite cold"
        },
        Opsitheiel = {
            "Early snowfall returning, freezing ground rapidly",
            "Prolonged darkness, bitterness sets in quickly",
            "Gusty winds carrying ice crystals through valleys",
            "Heavy drifts forming, multiple snowfall events",
            "Frequent subzero lows, no hint of thaw",
            "Blizzard-like conditions with large snow accumulations",
            "Icy rivers, widespread frost in daylight",
            "Mountains see near-constant snow, valleys freeze nightly",
            "Rare clear spells, intense wind chill outside",
            "Deep winter mode, swirling snow flurries all day"
        }
    }
}

---------------------------------------------------------
-- 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 Table Function
---------------------------------------------------------

function p.weatherForecast(frame)
    local dateInfo = getCurrentDateInfo()
    local dayOfYear = dateInfo.dayOfYear
    local yearNumber = dateInfo.psscYear

    local seasonName = getSeasonName(dayOfYear)

    -- Start building wiki output
    local output = {}

    table.insert(output, "== Daily Weather Forecast ==\n")
    table.insert(output, "''(Day " .. dayOfYear
        .. " of Year " .. yearNumber
        .. " PSSC, " .. seasonName .. ")''\n\n"
    )

    -- Begin table
    table.insert(output, '{| class="wikitable sortable" style="width:100%; text-align:left;"\n')
    table.insert(output, '! City !! Climate !! Season !! Today’s Weather\n')

    -- For each city, pick one random event from climateEvents
    for _, cityEntry in ipairs(cityData) do
        local cityName = cityEntry.city
        local climateName = cityEntry.climate

        local climateTable = climateEvents[climateName]
        local seasonTable = climateTable and climateTable[seasonName]
        local forecast = "No weather data."

        if seasonTable and #seasonTable > 0 then
            local rndIndex = math.random(#seasonTable)
            forecast = seasonTable[rndIndex]
        end

        table.insert(output, "|-\n")
        table.insert(output, "| " .. cityName .. " || " .. climateName .. " || " .. seasonName .. " || " .. forecast .. "\n")
    end

    -- Close table
    table.insert(output, "|}\n")

    return table.concat(output)
end

return p