From 10157dcadec8a519235b5a3439840d624443e706 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Fri, 14 Oct 2011 01:31:33 -0400 Subject: [PATCH] Deck mana curve --- Magic.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Magic.hs b/Magic.hs index 3c2b054..af52235 100644 --- a/Magic.hs +++ b/Magic.hs @@ -55,5 +55,12 @@ data Card = Card Rarity String Cost 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])) +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])))