Skip to content

Commit

Permalink
Added valid shot by shot values to their own functions like constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
rapind committed Nov 17, 2023
1 parent 7e754f7 commit d5bc92f
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions src/Scoring.elm
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,6 @@ type alias TeamCurler =
}


type TurnType
= Inturn
| Outturn


type ThrowType
= Esomthing
| Fsomething
| Hsomething


type alias RockColor =
{ pos : Int
, key : String
Expand All @@ -138,6 +127,22 @@ type SideResult



-- Define acceptable (valid) values for turns, throws, and ratings.


validShotTurns =
[ "I", "O", "X" ]


validShotThrows =
[ "A", "B", "C", "D", "E", "F", "G", "H", "J", "X" ]


validShotRatings =
[ "0", "1", "2", "3", "4", "V", "X" ]



-- DECODERS


Expand Down Expand Up @@ -1267,11 +1272,8 @@ update msg model =
formattedVal =
String.toUpper val

valids =
[ "I", "O", "X" ]

validated =
if List.member formattedVal valids then
if List.member formattedVal validShotTurns then
Just formattedVal

else
Expand Down Expand Up @@ -1317,11 +1319,8 @@ update msg model =
formattedVal =
String.toUpper val

valids =
[ "A", "B", "C", "D", "E", "F", "G", "H", "J", "X" ]

validated =
if List.member formattedVal valids then
if List.member formattedVal validShotThrows then
Just formattedVal

else
Expand Down Expand Up @@ -1368,11 +1367,8 @@ update msg model =
formattedVal =
String.toUpper val

valids =
[ "0", "1", "2", "3", "4", "V", "X" ]

validated =
if List.member formattedVal valids then
if List.member formattedVal validShotRatings then
Just formattedVal

else
Expand Down

0 comments on commit d5bc92f

Please sign in to comment.