This repository has been archived on 2025-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tingle-bot/src/modules/weather/getRegionRestrictions.ts
2024-09-26 11:37:00 -07:00

43 lines
1.3 KiB
TypeScript

import { inarikoSeasons } from "../../data/weather/regions/inarikoSeasons";
import { rudaniaSeasons } from "../../data/weather/regions/rudaniaSeasons";
import { vhintlSeasons } from "../../data/weather/regions/vhintlSeasons";
import { RegionName } from "../../interfaces/weather/names/RegionName";
import { Season } from "../../interfaces/weather/names/Season";
import { RegionRestriction } from "../../interfaces/weather/regions/RegionRestriction";
/**
* Module to get the allowed weather for a region based on the season.
* Will throw an error if the data is not found.
*
* @param {RegionName} region The name of the region.
* @param {Season} season The season.
* @returns {RegionRestriction} The allowed weather for the region.
*/
export const getRegionRestrictions = (
region: RegionName,
season: Season
): RegionRestriction | null => {
let restrictions = null;
switch (region) {
case "Rudania":
restrictions = rudaniaSeasons;
break;
case "Inariko":
restrictions = inarikoSeasons;
break;
case "Vhintl":
restrictions = vhintlSeasons;
break;
default:
return null;
}
const seasonalRestriction = restrictions.find((el) => el.season === season);
if (!seasonalRestriction) {
return null;
}
return seasonalRestriction;
};