Cadel Watson 1 an în urmă
părinte
comite
0cdd4604b8
3 a modificat fișierele cu 46 adăugiri și 1 ștergeri
  1. 19 1
      src/Card.elm
  2. 19 0
      src/Database.elm
  3. 8 0
      src/Main.elm

+ 19 - 1
src/Card.elm

@@ -1,4 +1,16 @@
-module Card exposing (CardData, CardDetails, CardPerformanceData, CardType(..), ManaColor(..), Power(..), alpa, alsa, gihwr, pickRate)
+module Card exposing
+    ( CardData
+    , CardDetails
+    , CardPerformanceData
+    , CardType(..)
+    , ManaColor(..)
+    , Power(..)
+    , alpa
+    , alsa
+    , gihwr
+    , iwd
+    , pickRate
+    )
 
 
 type ManaColor
@@ -51,6 +63,7 @@ type alias CardPerformanceData =
     , averagePickPosition : Maybe Float
     , averageSeenPosition : Maybe Float
     , gameInHandWinRate : Maybe Float
+    , improvementWhenDrawn : Maybe Float
     }
 
 
@@ -76,3 +89,8 @@ alpa card =
 gihwr : CardData -> Maybe Float
 gihwr card =
     card.performance.gameInHandWinRate
+
+
+iwd : CardData -> Maybe Float
+iwd card =
+    card.performance.improvementWhenDrawn

+ 19 - 0
src/Database.elm

@@ -63,9 +63,28 @@ decodeCardPerformance =
             |> required "ATA" decodeMaybeFloatString
             |> required "ALSA" decodeMaybeFloatString
             |> required "GIH WR" decodeMaybePercentageString
+            |> required "IWD" decodeImprovementWhenDrawn
         )
 
 
+decodeImprovementWhenDrawn : Decoder (Maybe Float)
+decodeImprovementWhenDrawn =
+    Decode.string
+        |> Decode.andThen
+            (\s ->
+                if s == "" then
+                    Decode.succeed Nothing
+
+                else
+                    case String.toFloat (String.replace "pp" "" s) of
+                        Just i ->
+                            Decode.succeed (Just i)
+
+                        Nothing ->
+                            Decode.succeed Nothing
+            )
+
+
 decodeIntString : Decoder Int
 decodeIntString =
     Decode.string

+ 8 - 0
src/Main.elm

@@ -42,6 +42,7 @@ type FocusStat
     | FocusALPA
     | FocusGIHWR
     | FocusPickRate
+    | FocusIWD
 
 
 type alias ReadyModel =
@@ -325,6 +326,9 @@ viewDraft model =
 
                         FocusALSA ->
                             "ALSA"
+
+                        FocusIWD ->
+                            "IWD"
                 ]
     in
     -- Making this a keyed node forces Elm to recreate each card when the card name changes,
@@ -338,6 +342,7 @@ viewDraft model =
             , viewFocusStatButton FocusALPA
             , viewFocusStatButton FocusGIHWR
             , viewFocusStatButton FocusALSA
+            , viewFocusStatButton FocusIWD
             ]
         ]
 
@@ -435,6 +440,9 @@ viewKeyedCard model wasChosen { name, frontImage, backImage } =
 
                 FocusPickRate ->
                     Maybe.map (formatPercentage << Card.pickRate) stats
+
+                FocusIWD ->
+                    Maybe.map (Round.round 2) (Maybe.andThen Card.iwd stats)
     in
     ( name
     , div