|
@@ -0,0 +1,59 @@
|
|
|
|
|
+module Signals exposing (..)
|
|
|
|
|
+
|
|
|
|
|
+import Card exposing (CardData, ManaColor(..))
|
|
|
|
|
+import Database exposing (Database)
|
|
|
|
|
+import Draft exposing (Draft, Pick)
|
|
|
|
|
+import List.Extra as List
|
|
|
|
|
+import Zipper
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+type alias CardsSeenPerColor =
|
|
|
|
|
+ { white : Int
|
|
|
|
|
+ , blue : Int
|
|
|
|
|
+ , black : Int
|
|
|
|
|
+ , red : Int
|
|
|
|
|
+ , green : Int
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+inferSignals : Bool -> Database -> Draft -> List ( Int, CardsSeenPerColor )
|
|
|
|
|
+inferSignals includeWholeDeck db draft =
|
|
|
|
|
+ let
|
|
|
|
|
+ numberOfPicks =
|
|
|
|
|
+ if includeWholeDeck then
|
|
|
|
|
+ Zipper.length draft
|
|
|
|
|
+
|
|
|
|
|
+ else
|
|
|
|
|
+ List.length (Zipper.left draft) + 1
|
|
|
|
|
+
|
|
|
|
|
+ relevantPicks =
|
|
|
|
|
+ List.take numberOfPicks (Zipper.toList draft)
|
|
|
|
|
+ in
|
|
|
|
|
+ List.range 0 (numberOfPicks - 1)
|
|
|
|
|
+ |> List.map (\i -> ( i, countCardsInPicks db (List.take (i + 1) relevantPicks) ))
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+countCardsInPicks : Database -> List Pick -> CardsSeenPerColor
|
|
|
|
|
+countCardsInPicks db picks =
|
|
|
|
|
+ let
|
|
|
|
|
+ allCards =
|
|
|
|
|
+ allCardsInPicks db picks
|
|
|
|
|
+
|
|
|
|
|
+ countColor color =
|
|
|
|
|
+ List.count (\card -> List.member color card.details.colors) allCards
|
|
|
|
|
+ in
|
|
|
|
|
+ { white = countColor White
|
|
|
|
|
+ , blue = countColor Blue
|
|
|
|
|
+ , black = countColor Black
|
|
|
|
|
+ , red = countColor Red
|
|
|
|
|
+ , green = countColor Green
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+allCardsInPicks : Database -> List Pick -> List CardData
|
|
|
|
|
+allCardsInPicks db picks =
|
|
|
|
|
+ let
|
|
|
|
|
+ cardsPicked =
|
|
|
|
|
+ List.concatMap .available picks
|
|
|
|
|
+ in
|
|
|
|
|
+ List.filterMap (\pick -> Database.get pick.name db) cardsPicked
|