generated from nhcarrigan/template
feat: initial commit
This commit is contained in:
42
src/modules/weather/getRegionRestrictions.ts
Normal file
42
src/modules/weather/getRegionRestrictions.ts
Normal file
@ -0,0 +1,42 @@
|
||||
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;
|
||||
};
|
Reference in New Issue
Block a user