magic/Magic.hs

31 lines
895 B
Haskell

module Magic where
import Mana
-------------------------------------------------------------------------------
-- Cards
-------------------------------------------------------------------------------
data Rarity = Land
| Common
| Uncommon
| Rare
| Mythic
| Special
deriving (Show, Eq)
data Card = Card Rarity String Cost
deriving (Show, Eq)
instance ManaCost Card where
converted (Card _ _ cost) = converted cost
data Deck = Deck [Card]
curve :: Deck -> [(Int, Int)]
curve (Deck cards) = do
let largest = maximum (map converted cards)
map (\x -> (x, length (filter (\(Card rarity _ cost) -> rarity /= Land && converted cost == x) cards))) [0..largest]
deck = Deck ((replicate 13 (Card Land "Swamp" (Cost []))) ++ (replicate 13 (Card Land "Plains" (Cost [])))
++ replicate 4 (Card Mythic "Jace Beleren" (Cost [Mana 1 Colorless, Mana 2 Blue])))