Permalink
Browse files

Distinguished between Abilities and ClosedAbilities

  • Loading branch information...
1 parent d6d97b2 commit 3be2ed69a55b0728474c24a592e3b682d16e66fc @MedeaMelana committed Aug 31, 2012
Showing with 35 additions and 18 deletions.
  1. +27 −12 BasicLands.hs
  2. +8 −6 Types.hs
View
@@ -12,7 +12,7 @@ import Data.Label.PureM
plains :: Card
-plains = Card $ \ts rOwner rSelf ->
+plains = Card $ \ts rOwner ->
Object
{ _name = Just "Plains"
, _colors = mempty
@@ -36,19 +36,34 @@ plains = Card $ \ts rOwner rSelf ->
, _toughness = Nothing
, _damage = Nothing
- , _play = Ability
- { _available = \rp -> do
- os <- asks objects
- let self = os ! rSelf
- let ok = (isControlledBy rp &&* isInZone Hand) self
- return ok
- , _manaCost = mempty
- , _additionalCosts = []
- , _effect = SpecialAction (return [MoveObject rSelf Library Battlefield])
- }
+ , _play = defaultPlay
, _staticKeywordAbilities = []
, _continuousEffects = []
- , _activatedAbilities = []
+ , _activatedAbilities = [tapToAddMana (Just White)]
, _triggeredAbilities = []
, _replacementEffects = []
}
+
+defaultPlay :: Ability
+defaultPlay rSource rActivator = ClosedAbility
+ { _available = do
+ os <- asks objects
+ let source = os ! rSource
+ let ok = (isControlledBy rActivator &&* isInZone Hand) source
+ return ok
+ , _manaCost = mempty
+ , _additionalCosts = []
+ , _effect = SpecialAction (return [MoveObject rSource Library Battlefield])
+ }
+
+tapToAddMana :: Maybe Color -> Ability
+tapToAddMana mc rSource rActivator = ClosedAbility
+ { _available = do
+ os <- asks objects
+ let source = os ! rSource
+ let ok = (isControlledBy rActivator &&* isInZone Battlefield) source
+ return ok
+ , _manaCost = mempty
+ , _additionalCosts = []
+ , _effect = SpecialAction (return [AddToManaPool rActivator mc])
+ }
View
@@ -82,8 +82,8 @@ data Player = Player
-- Objects
data Card = Card
- -- timestamp, owner (and controller), new ref
- { enterWorld :: Timestamp -> Ref Player -> Ref Object -> Object
+ -- timestamp, owner (and controller)
+ { enterWorld :: Timestamp -> Ref Player -> Object
}
data Object = Object
@@ -114,7 +114,7 @@ data Object = Object
, _play :: Ability
, _staticKeywordAbilities :: Bag StaticKeywordAbility
, _continuousEffects :: [ContinuousEffect] -- special form of static ability
- , _activatedAbilities :: [Action]
+ , _activatedAbilities :: [Ability]
, _triggeredAbilities :: [Event -> Action]
, _replacementEffects :: [OneShotEffect -> Magic [OneShotEffect]]
}
@@ -184,8 +184,10 @@ data PlaneswalkerType = Chandra | Elspeth | Garruk | Gideon | Jace
-- Actions
-data Ability = Ability
- { _available :: Ref Player -> View Bool -- check for cost is implied
+type Ability = Ref Object -> Ref Player -> ClosedAbility
+
+data ClosedAbility = ClosedAbility
+ { _available :: View Bool -- check for cost is implied
, _manaCost :: ManaCost
, _additionalCosts :: [AdditionalCost]
, _effect :: Action
@@ -284,7 +286,7 @@ data OneShotEffect
| AddCounter (Ref Object) CounterType
| RemoveCounter (Ref Object) CounterType
| CreateObject Object -- create a token, emblem or spell
- | AddToManaPool (Ref Player) (Bag (Maybe Color))
+ | AddToManaPool (Ref Player) (Maybe Color)
| AttachPermanent (Ref Object) (Maybe (Ref Object)) (Maybe (Ref Object)) -- aura/equipment, old target, new target
| RemoveFromCombat (Ref Object)

0 comments on commit 3be2ed6

Please sign in to comment.