module Card exposing (CardData, CardDetails, CardPerformanceData, CardType(..), ManaColor(..), Power(..), alpa, alsa, gihwr, pickRate)


type ManaColor
    = Red
    | Blue
    | Green
    | White
    | Black
    | Colorless


type CardType
    = Creature
    | Instant
    | Sorcery
    | Enchantment
    | Artifact
    | Planeswalker
    | Land
    | Other


type Power
    = ConstantPower Int
    | VariablePower


type alias CardData =
    { details : CardDetails
    , performance : CardPerformanceData
    }


type alias CardDetails =
    { cmc : Int
    , cardType : CardType
    , typeLine : String
    , oracleText : Maybe String
    , power : Maybe Power
    , toughness : Maybe Power
    , colors : List ManaColor

    --, manaCost : List ManaColor
    }


type alias CardPerformanceData =
    { totalTimesSeen : Int
    , totalTimesPicked : Int
    , averagePickPosition : Maybe Float
    , averageSeenPosition : Maybe Float
    , gameInHandWinRate : Maybe Float
    }


pickRate : CardData -> Float
pickRate card =
    if card.performance.totalTimesSeen == 0 then
        0

    else
        toFloat card.performance.totalTimesPicked / toFloat card.performance.totalTimesSeen


alsa : CardData -> Maybe Float
alsa card =
    card.performance.averageSeenPosition


alpa : CardData -> Maybe Float
alpa card =
    card.performance.averagePickPosition


gihwr : CardData -> Maybe Float
gihwr card =
    card.performance.gameInHandWinRate
