Skip to content

Commit

Permalink
Define ConversionGroups enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Agilulfo authored and musoke committed Oct 28, 2024
1 parent 7e9dc93 commit 7badf00
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 25 deletions.
11 changes: 10 additions & 1 deletion src/GradeScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default interface GradeScale {
displayName: string
name: GradeScalesTypes
offset: number
conversionGroup: string
conversionGroup: ConversionGroupsTypes
grades?: string[]
}

Expand All @@ -31,6 +31,15 @@ export const GradeScales = {

export type GradeScalesTypes = typeof GradeScales[keyof typeof GradeScales]

export const ConversionGroups = {
AID: 'aid',
FREE: 'free',
BOULDERING: 'bouldering',
ICE: 'ice'
} as const

export type ConversionGroupsTypes = typeof ConversionGroups[keyof typeof ConversionGroups]

export const findScoreRange = (compareFn, list): number | Tuple => {
const scores = list.filter(compareFn)
.map(b => b.score)
Expand Down
4 changes: 2 additions & 2 deletions src/scales/ai.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple } from '../GradeScale'
import ice_table from '../data/ice.json'
import { IceGrade } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
Expand All @@ -13,7 +13,7 @@ const AIScale: GradeScale = {
displayName: 'AI Grade',
name: GradeScales.AI,
offset: 1000,
conversionGroup: 'Ice',
conversionGroup: ConversionGroups.ICE,
isType: (grade: string): boolean => {
if (isAI(grade) === null) {
return false
Expand Down
4 changes: 2 additions & 2 deletions src/scales/aid.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple } from '../GradeScale'
import aid_table from '../data/aid.json'
import { AidGrade } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
Expand All @@ -12,7 +12,7 @@ const AidScale: GradeScale = {
displayName: 'Aid Grade',
name: GradeScales.AID,
offset: 1000,
conversionGroup: 'Aid',
conversionGroup: ConversionGroups.AID,
isType: (grade: string): boolean => {
if (isAid(grade) === null) {
return false
Expand Down
4 changes: 2 additions & 2 deletions src/scales/brazilian.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple, getRoundedScoreTuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple, getRoundedScoreTuple } from '../GradeScale'
import routes from '../data/routes.json'
import { Route } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
Expand Down Expand Up @@ -71,7 +71,7 @@ const BrazilianCrux: GradeScale = {
displayName: 'Brazilian Crux Scale',
name: GradeScales.BRAZILIAN_CRUX,
offset: 1000,
conversionGroup: 'Free',
conversionGroup: ConversionGroups.FREE,
isType: (grade: string): boolean => isBrazilianCrux(grade) !== null,
getScore,
getGrade: (score: number | Tuple): string => {
Expand Down
4 changes: 2 additions & 2 deletions src/scales/ewbank.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, getRoundedScoreTuple, Tuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, getRoundedScoreTuple, Tuple } from '../GradeScale'
import routes from '../data/routes.json'
import { Route } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
Expand All @@ -15,7 +15,7 @@ const EwbankScale: GradeScale = {
displayName: 'Ewbank Grade',
name: GradeScales.EWBANK,
offset: 1000,
conversionGroup: 'Free',
conversionGroup: ConversionGroups.FREE,
isType: (grade: string): boolean => {
if (isEwbank(grade) === null) {
return false
Expand Down
4 changes: 2 additions & 2 deletions src/scales/font.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import boulder from '../data/boulder.json'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple, getRoundedScoreTuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple, getRoundedScoreTuple } from '../GradeScale'

import { Boulder } from '.'
import { boulderScoreToBand, GradeBandTypes } from '../GradeBands'
Expand All @@ -14,7 +14,7 @@ const FontScale: GradeScale = {
displayName: 'Fontainebleau',
name: GradeScales.FONT,
offset: 1000,
conversionGroup: 'Bouldering',
conversionGroup: ConversionGroups.BOULDERING,
isType: (grade: string): boolean => {
if (isFont(grade) === null) {
return false
Expand Down
4 changes: 2 additions & 2 deletions src/scales/french.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple, getRoundedScoreTuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple, getRoundedScoreTuple } from '../GradeScale'
import routes from '../data/routes.json'
import { Route } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
Expand All @@ -13,7 +13,7 @@ const FrenchScale: GradeScale = {
displayName: 'French Scale',
name: GradeScales.FRENCH,
offset: 1000,
conversionGroup: 'Free',
conversionGroup: ConversionGroups.FREE,
isType: (grade: string): boolean => {
if (isFrench(grade) === null) {
return false
Expand Down
4 changes: 2 additions & 2 deletions src/scales/norwegian.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple, getRoundedScoreTuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple, getRoundedScoreTuple } from '../GradeScale'
import routes from '../data/routes.json'
import { Route } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
Expand All @@ -13,7 +13,7 @@ const Norwegian: GradeScale = {
displayName: 'Norwegian Scale',
name: GradeScales.NORWEGIAN,
offset: 1000,
conversionGroup: 'Free',
conversionGroup: ConversionGroups.FREE,
isType: (grade: string): boolean => {
if (isNorwegian(grade) === null) {
return false
Expand Down
4 changes: 2 additions & 2 deletions src/scales/saxon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple, getRoundedScoreTuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple, getRoundedScoreTuple } from '../GradeScale'
import routes from '../data/routes.json'
import { Route } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
Expand All @@ -14,7 +14,7 @@ const SaxonScale: GradeScale = {
displayName: 'Saxon Scale',
name: GradeScales.SAXON,
offset: 1000,
conversionGroup: 'Free',
conversionGroup: ConversionGroups.FREE,
isType: (grade: string): boolean => {
if (isSaxon(grade) === null) {
return false
Expand Down
4 changes: 2 additions & 2 deletions src/scales/uiaa.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple, getRoundedScoreTuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple, getRoundedScoreTuple } from '../GradeScale'
import routes from '../data/routes.json'
import { Route } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
Expand All @@ -14,7 +14,7 @@ const UIAAScale: GradeScale = {
displayName: 'UIAA Scale',
name: GradeScales.UIAA,
offset: 2000,
conversionGroup: 'Free',
conversionGroup: ConversionGroups.FREE,
isType: (grade: string): boolean => {
if (isUIAA(grade) === null) {
return false
Expand Down
4 changes: 2 additions & 2 deletions src/scales/v.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple, getRoundedScoreTuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple, getRoundedScoreTuple } from '../GradeScale'
import boulder from '../data/boulder.json'
import { Boulder } from '.'
import { boulderScoreToBand, GradeBandTypes } from '../GradeBands'
Expand All @@ -9,7 +9,7 @@ const VScale: GradeScale = {
displayName: 'V Scale',
name: GradeScales.VSCALE,
offset: 1000,
conversionGroup: 'Bouldering',
conversionGroup: ConversionGroups.BOULDERING,
isType: (grade: string): boolean => {
const isVGrade = grade.match(vGradeRegex)
// If there isn't a match sort it to the bottom
Expand Down
4 changes: 2 additions & 2 deletions src/scales/wi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple } from '../GradeScale'
import ice_table from '../data/ice.json'
import { IceGrade } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
Expand All @@ -13,7 +13,7 @@ const WIScale: GradeScale = {
displayName: 'WI Grade',
name: GradeScales.WI,
offset: 1000,
conversionGroup: 'Ice',
conversionGroup: ConversionGroups.ICE,
isType: (grade: string): boolean => {
if (isWI(grade) === null) {
return false
Expand Down
4 changes: 2 additions & 2 deletions src/scales/yds.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GradeScale, { findScoreRange, getAvgScore, GradeScales, Tuple, getRoundedScoreTuple } from '../GradeScale'
import GradeScale, { findScoreRange, getAvgScore, GradeScales, ConversionGroups, Tuple, getRoundedScoreTuple } from '../GradeScale'
import routes from '../data/routes.json'
import { Route } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
Expand All @@ -19,7 +19,7 @@ const YosemiteDecimal: GradeScale = {
displayName: 'Yosemite Decimal System',
name: GradeScales.YDS,
offset: 1000,
conversionGroup: 'Free',
conversionGroup: ConversionGroups.FREE,
isType: (grade: string): boolean => {
if (isYds(grade) === null) {
return false
Expand Down

0 comments on commit 7badf00

Please sign in to comment.