/
BasicLands.hs
48 lines (39 loc) · 1.43 KB
/
BasicLands.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{-# LANGUAGE OverloadedStrings #-}
module BasicLands where
import Predicates
import Types
import Utils
import Control.Applicative
import Data.Boolean
import Data.Label.PureM
import Data.Monoid
import Data.Set as Set
import Data.String
plains, island, swamp, mountain, forest :: Card
plains = mkBasicLandCard Plains White
island = mkBasicLandCard Island Blue
swamp = mkBasicLandCard Swamp Black
mountain = mkBasicLandCard Mountain Red
forest = mkBasicLandCard Forest Green
mkBasicLandCard :: LandType -> Color -> Card
mkBasicLandCard ty color = mkCard $ do
name =: Just (fromString (show ty))
types =: basicType <> objectType ty
play =: Just playLand
activatedAbilities =: [tapToAddMana (Just color)]
playLand :: Ability
playLand rSource rActivator = ClosedAbility
{ _available = checkObject rSource (isControlledBy rActivator &&* isInZone Hand)
, _manaCost = mempty
, _additionalCosts = []
, _effect = SpecialAction (return [MoveObject rSource Library Battlefield])
}
tapToAddMana :: Maybe Color -> Ability
tapToAddMana mc rSource rActivator = ClosedAbility
{ _available = checkObject rSource (isControlledBy rActivator &&* isInZone Battlefield)
, _manaCost = mempty
, _additionalCosts = []
, _effect = SpecialAction (return [AddToManaPool rActivator mc])
}
checkObject :: Ref Object -> (Object -> Bool) -> View Bool
checkObject ref ok = ok . (! ref) <$> asks objects