Convert cost of costs and cards

This commit is contained in:
Correl Roush 2011-10-14 00:51:34 -04:00
parent eae41ba556
commit c820551baa

View file

@ -18,12 +18,12 @@ data Mana = Mana Int Color
data Cost = Cost [Mana]
deriving (Show, Eq)
converted :: Cost -> Int
converted (Cost []) = 0
converted (Cost cost) = (foldl (\t (Mana x _) -> t + x) 0) cost
class ManaCost a where
converted :: a -> Int
converted_card :: Card -> Int
converted_card (Card _ _ cost) = converted cost
instance ManaCost Cost where
converted (Cost []) = 0
converted (Cost cost) = (foldl (\t (Mana x _) -> t + x) 0) cost
color :: Color -> Cost -> Int
color c (Cost cost) = converted (Cost (filter (\(Mana _ col) -> col == c) cost))
@ -52,5 +52,8 @@ data Rarity = Land
data Card = Card Rarity String Cost
deriving (Show, Eq)
instance ManaCost Card where
converted (Card _ _ cost) = converted cost
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]))