From fa261e0e21264f06b4b02cac8b5e85a5558510ed Mon Sep 17 00:00:00 2001 From: Flavio Di Natale Date: Tue, 8 Oct 2024 01:24:16 +0200 Subject: [PATCH] Replace allowableConversionType with conversionGroup --- src/GradeParser.ts | 4 ++-- src/GradeScale.ts | 2 +- src/scales/ai.ts | 2 +- src/scales/aid.ts | 2 +- src/scales/brazilian.ts | 2 +- src/scales/ewbank.ts | 2 +- src/scales/font.ts | 2 +- src/scales/french.ts | 2 +- src/scales/norwegian.ts | 2 +- src/scales/saxon.ts | 2 +- src/scales/uiaa.ts | 2 +- src/scales/v.ts | 2 +- src/scales/wi.ts | 2 +- src/scales/yds.ts | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/GradeParser.ts b/src/GradeParser.ts index c4bfaa5..af2da6e 100644 --- a/src/GradeParser.ts +++ b/src/GradeParser.ts @@ -56,8 +56,8 @@ export const convertGrade = ( if (fromScale === null || toScale === null) { return '' } - const checkScaleToConvert: boolean = fromScale.allowableConversionType.includes(toGradeScaleType) - if (!checkScaleToConvert) { + const sameConversionGroup: boolean = fromScale.conversionGroup === toScale.conversionGroup + if (!sameConversionGroup) { console.warn( `Scale: ${fromScale.displayName} doesn't support converting to Scale: ${toScale.displayName}` ) diff --git a/src/GradeScale.ts b/src/GradeScale.ts index 01e016b..7abae36 100644 --- a/src/GradeScale.ts +++ b/src/GradeScale.ts @@ -10,7 +10,7 @@ export default interface GradeScale { displayName: string name: GradeScalesTypes offset: number - allowableConversionType: GradeScalesTypes[] + conversionGroup: string grades?: string[] } diff --git a/src/scales/ai.ts b/src/scales/ai.ts index c93d998..68b6844 100644 --- a/src/scales/ai.ts +++ b/src/scales/ai.ts @@ -13,7 +13,7 @@ const AIScale: GradeScale = { displayName: 'AI Grade', name: GradeScales.AI, offset: 1000, - allowableConversionType: [GradeScales.WI], + conversionGroup: 'Ice', isType: (grade: string): boolean => { if (isAI(grade) === null) { return false diff --git a/src/scales/aid.ts b/src/scales/aid.ts index 48b27d3..359f4f7 100644 --- a/src/scales/aid.ts +++ b/src/scales/aid.ts @@ -12,7 +12,7 @@ const AidScale: GradeScale = { displayName: 'Aid Grade', name: GradeScales.AID, offset: 1000, - allowableConversionType: [], + conversionGroup: 'Aid', isType: (grade: string): boolean => { if (isAid(grade) === null) { return false diff --git a/src/scales/brazilian.ts b/src/scales/brazilian.ts index 0b6d391..96e5c02 100644 --- a/src/scales/brazilian.ts +++ b/src/scales/brazilian.ts @@ -71,7 +71,7 @@ const BrazilianCrux: GradeScale = { displayName: 'Brazilian Crux Scale', name: GradeScales.BRAZILIAN_CRUX, offset: 1000, - allowableConversionType: [GradeScales.YDS, GradeScales.SAXON, GradeScales.EWBANK, GradeScales.FRENCH, GradeScales.NORWEGIAN], + conversionGroup: 'Free', isType: (grade: string): boolean => isBrazilianCrux(grade) !== null, getScore, getGrade: (score: number | Tuple): string => { diff --git a/src/scales/ewbank.ts b/src/scales/ewbank.ts index ebe112e..3f58dd2 100644 --- a/src/scales/ewbank.ts +++ b/src/scales/ewbank.ts @@ -15,7 +15,7 @@ const EwbankScale: GradeScale = { displayName: 'Ewbank Grade', name: GradeScales.EWBANK, offset: 1000, - allowableConversionType: [GradeScales.YDS, GradeScales.FRENCH, GradeScales.SAXON], + conversionGroup: 'Free', isType: (grade: string): boolean => { if (isEwbank(grade) === null) { return false diff --git a/src/scales/font.ts b/src/scales/font.ts index caf7dbd..46d98ad 100644 --- a/src/scales/font.ts +++ b/src/scales/font.ts @@ -14,7 +14,7 @@ const FontScale: GradeScale = { displayName: 'Fontainebleau', name: GradeScales.FONT, offset: 1000, - allowableConversionType: [GradeScales.VSCALE], + conversionGroup: 'Bouldering', isType: (grade: string): boolean => { if (isFont(grade) === null) { return false diff --git a/src/scales/french.ts b/src/scales/french.ts index 065de2b..c4f1452 100644 --- a/src/scales/french.ts +++ b/src/scales/french.ts @@ -13,7 +13,7 @@ const FrenchScale: GradeScale = { displayName: 'French Scale', name: GradeScales.FRENCH, offset: 1000, - allowableConversionType: [GradeScales.YDS, GradeScales.EWBANK, GradeScales.SAXON], + conversionGroup: 'Free', isType: (grade: string): boolean => { if (isFrench(grade) === null) { return false diff --git a/src/scales/norwegian.ts b/src/scales/norwegian.ts index 8175722..7478683 100644 --- a/src/scales/norwegian.ts +++ b/src/scales/norwegian.ts @@ -13,7 +13,7 @@ const Norwegian: GradeScale = { displayName: 'Norwegian Scale', name: GradeScales.NORWEGIAN, offset: 1000, - allowableConversionType: [], + conversionGroup: 'Free', isType: (grade: string): boolean => { if (isNorwegian(grade) === null) { return false diff --git a/src/scales/saxon.ts b/src/scales/saxon.ts index 400811d..ba62732 100644 --- a/src/scales/saxon.ts +++ b/src/scales/saxon.ts @@ -14,7 +14,7 @@ const SaxonScale: GradeScale = { displayName: 'Saxon Scale', name: GradeScales.SAXON, offset: 1000, - allowableConversionType: [GradeScales.YDS, GradeScales.EWBANK, GradeScales.FRENCH], + conversionGroup: 'Free', isType: (grade: string): boolean => { if (isSaxon(grade) === null) { return false diff --git a/src/scales/uiaa.ts b/src/scales/uiaa.ts index 4d0070f..6104f8b 100644 --- a/src/scales/uiaa.ts +++ b/src/scales/uiaa.ts @@ -14,7 +14,7 @@ const UIAAScale: GradeScale = { displayName: 'UIAA Scale', name: GradeScales.UIAA, offset: 2000, - allowableConversionType: [GradeScales.YDS, GradeScales.SAXON, GradeScales.EWBANK, GradeScales.FRENCH], + conversionGroup: 'Free', isType: (grade: string): boolean => { if (isUIAA(grade) === null) { return false diff --git a/src/scales/v.ts b/src/scales/v.ts index ca72ad6..ec64593 100644 --- a/src/scales/v.ts +++ b/src/scales/v.ts @@ -9,7 +9,7 @@ const VScale: GradeScale = { displayName: 'V Scale', name: GradeScales.VSCALE, offset: 1000, - allowableConversionType: [GradeScales.FONT], + conversionGroup: 'Bouldering', isType: (grade: string): boolean => { const isVGrade = grade.match(vGradeRegex) // If there isn't a match sort it to the bottom diff --git a/src/scales/wi.ts b/src/scales/wi.ts index cf372b9..8f4ab8b 100644 --- a/src/scales/wi.ts +++ b/src/scales/wi.ts @@ -13,7 +13,7 @@ const WIScale: GradeScale = { displayName: 'WI Grade', name: GradeScales.WI, offset: 1000, - allowableConversionType: [GradeScales.AI], + conversionGroup: 'Ice', isType: (grade: string): boolean => { if (isWI(grade) === null) { return false diff --git a/src/scales/yds.ts b/src/scales/yds.ts index 30b0894..c6ea265 100644 --- a/src/scales/yds.ts +++ b/src/scales/yds.ts @@ -19,7 +19,7 @@ const YosemiteDecimal: GradeScale = { displayName: 'Yosemite Decimal System', name: GradeScales.YDS, offset: 1000, - allowableConversionType: [GradeScales.FRENCH, GradeScales.EWBANK, GradeScales.SAXON], + conversionGroup: 'Free', isType: (grade: string): boolean => { if (isYds(grade) === null) { return false