Skip to content

Commit

Permalink
fix issues I didn't test for in Main.elm
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Apr 5, 2021
1 parent d7ea770 commit e7e7809
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
22 changes: 11 additions & 11 deletions src/Main.elm
Expand Up @@ -267,7 +267,7 @@ currentMatch model =
Just (League.Match playerA playerB) ->
let
chanceAWins =
Elo.odds playerA.rating playerB.rating
Elo.odds (Player.rating playerA) (Player.rating playerB)
in
Html.section
[ css
Expand Down Expand Up @@ -403,7 +403,7 @@ activePlayer player =
, openSans
]
]
[ Html.text player.name ]
[ Html.text (Player.name player) ]


rankings : Model -> Html Msg
Expand All @@ -413,8 +413,8 @@ rankings model =
History.peekBack model.history
|> Maybe.withDefault (History.current model.history)
|> League.players
|> List.sortBy (\player -> -player.rating)
|> List.indexedMap (\rank player -> ( player.name, rank ))
|> List.sortBy (\player -> -(Player.rating player))
|> List.indexedMap (\rank player -> ( Player.name player, rank ))
|> Dict.fromList

numeric =
Expand Down Expand Up @@ -465,21 +465,21 @@ rankings model =
in
History.current model.history
|> League.players
|> List.sortBy (\player -> -player.rating)
|> List.sortBy (\player -> -(Player.rating player))
|> List.indexedMap
(\rank player ->
let
previousRank =
Dict.get player.name previousStandings
Dict.get (Player.name player) previousStandings
|> Maybe.withDefault rank

isPlaying =
History.current model.history
|> League.currentMatch
|> Maybe.map (\(League.Match a b) -> player == a || player == b)
|> Maybe.map (\(League.Match a b) -> Player.id player == Player.id a || Player.id player == Player.id b)
|> Maybe.withDefault False
in
( player.name
( Player.htmlKey player
, Html.tr
[ css [ Css.height (Css.px 60) ] ]
[ Html.td
Expand Down Expand Up @@ -523,13 +523,13 @@ rankings model =
[ Html.text (String.fromInt (rank + 1)) ]
, Html.td
[ css [ numeric, shrinkWidth, center ] ]
[ Html.text (String.fromInt player.rating) ]
[ Html.text (String.fromInt (Player.rating player)) ]
, Html.td
[ css [ numeric, shrinkWidth, center ] ]
[ Html.text (String.fromInt player.matches) ]
[ Html.text (String.fromInt (Player.matchesPlayed player)) ]
, Html.td
[ css [ textual, left ] ]
[ Html.text player.name ]
[ Html.text (Player.name player) ]
, Html.td
[ css [ textual, shrinkWidth, center ] ]
[ redButton "Retire" (Just (KeeperWantsToRetirePlayer player)) ]
Expand Down
18 changes: 13 additions & 5 deletions src/Player.elm
@@ -1,16 +1,15 @@
module Player exposing
( Player, init
( Player, init, htmlKey
, PlayerId, id, idSorter
, name
, rating, setRating
, matchesPlayed, setMatchesPlayedTestOnly, incrementMatchesPlayed
, encode
, decoder
, encode, decoder
)

{-|
@docs Player, init
@docs Player, init, htmlKey
@docs PlayerId, id, idSorter
Expand All @@ -20,7 +19,7 @@ module Player exposing
@docs matchesPlayed, setMatchesPlayedTestOnly, incrementMatchesPlayed
@docs encode, decode
@docs encode, decoder
-}

Expand Down Expand Up @@ -50,6 +49,15 @@ init name_ =
}


htmlKey : Player -> String
htmlKey (Player player) =
let
(PlayerId idInt) =
player.id
in
String.fromInt idInt



-- ID

Expand Down

0 comments on commit e7e7809

Please sign in to comment.