Permalink
Browse files

Old WIP

  • Loading branch information...
1 parent e458010 commit 3f5fca0f0b4598d7eb6c5d639cd6176ba8bb4b38 @MedeaMelana committed Aug 30, 2012
Showing with 76 additions and 101 deletions.
  1. +74 −78 M12.hs
  2. +2 −23 Predicates.hs
View
152 M12.hs
@@ -13,122 +13,118 @@ import Data.Boolean
import qualified Data.IntMap as IntMap
import Data.Label.MaybeM
import Data.Maybe (catMaybes)
+import Data.Monoid
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Text (Text)
-doomblade :: Card
-doomblade =
- mkInstant "Doomblade" [PayMana [Just Black, Nothing]] $
- \rSelf rOwner -> do
- let crit = notB (hasColor Black) &&* isOnBattlefield
- rTarget <- targetCreature crit
- stack rSelf $ do
- o <- gets (object rTarget)
- when (crit o) $ object rTarget .^ zone =: Graveyard
-
+-- doomblade :: Card
+-- doomblade =
+-- mkInstant "Doomblade" [PayMana [Just Black, Nothing]] $
+-- \rSelf rOwner -> do
+-- let crit = notB (hasColor Black) &&* isOnBattlefield
+-- rTarget <- targetCreature crit
+-- stack rSelf $ do
+-- o <- gets (object rTarget)
+-- when (crit o) $ object rTarget .^ zone =: Graveyard
+--
goblinFireslinger :: Card
goblinFireslinger = Card
{ enterWorld = \timestamp rOwner rSelf -> Object
{ _name = Just "Goblin Fireslinger"
, _colors = colorsFromCost cost
, _group = Permanent
{ _supertypes = Set.empty
- , _permanentTypes = Set.fromList
- [ Creature
- { _creatureTypes = Set.fromList [Goblin, Warrior]
- , _power = 1
- , _toughness = 1
- , _damage = 0
- }
- ]
+ , _creatureTypes = Set.fromList [Goblin, Warrior]
}
, _zone = Library
, _owner = rOwner
, _controller = rOwner
+
+ , _power = 1
+ , _toughness = 1
+ , _damage = 0
+
, _activatedAbilities =
[ Action
{ _available = \rp ->
- (isOnBattlefield &&* isControlledBy rp) <$>
+ (isInZone Battlefield &&* isControlledBy rp) <$>
gets (object rSelf)
- , _cost = [TapSelf]
+ , _cost = mempty { tapPermanents = [\(r, _) -> r == rSelf] }
, _effect = do
rt <- targetPlayer
stack rSelf $ player rt .^ life .~ subtract 1
}
]
, _play = Action
{ _available = \rp ->
- (isInHand &&* isControlledBy rp) <$>
+ (isInZone Hand &&* isControlledBy rp) <$>
gets (object rSelf)
- , _cost = [PayMana [Just Red]]
+ , _cost = cost
, _effect = stack rSelf $
object rSelf .^ zone =: Battlefield Untapped
}
, _timestamp = timestamp
, _staticAbilities = []
, _counters = []
- , _effects = []
+ , _continuousEffects = []
}
}
where
- cost = [PayMana [Just Red]]
-
-stack :: Ref Object -> Magic () -> Magic ()
-stack r a = move r (Stack a)
-
-move :: Ref Object -> Zone -> Magic ()
-move r z = do
- object r .^ zone =: z
- object r .^ effects =: []
- object r .^ counters =: [] -- [121.2]
- stamp >>= puts (object r .^ timestamp) -- [613.6c]
-
-target :: (Object -> Bool) -> Magic (Ref Object)
-target = undefined
-
-targetCreature :: (Object -> Bool) -> Magic (Ref Object)
-targetCreature = undefined
+ cost = mempty { payColoredMana = [Red] }
-targetPlayer :: Magic (Ref Player)
-targetPlayer = targetPlayer' (const True)
+-- stack :: Ref Object -> Magic () -> Magic ()
+-- stack r a = raise $ move r (Stack a)
-targetOpponent :: Ref Player -> Magic (Ref Player)
-targetOpponent rController = targetPlayer' (\(rp, _) -> rp /= rController)
+-- move :: Ref Object -> Zone -> Magic ()
+-- move r z = do
+-- object r .^ zone =: z
+-- object r .^ effects =: []
+-- object r .^ counters =: [] -- [121.2]
+-- stamp >>= puts (object r .^ timestamp) -- [613.6c]
-targetPlayer' :: (WithRef Player -> Bool) -> Magic (Ref Player)
-targetPlayer' f = do
- rpps <- IntMap.toList <$> gets players
- choose [ (TargetPlayer rp, rp) | rpp@(rp, _) <- rpps, f rpp ]
-
-mkInstant :: Text -> [Cost] -> (Ref Player -> Ref Object ->
- Magic ()) -> Card
-mkInstant name cost effect = Card
- { enterWorld = \timestamp rOwner rSelf -> Object
- { _name = Just name
- , _colors = colorsFromCost cost
- , _group = Spell Instant
- , _zone = Library
- , _owner = rOwner
- , _controller = rOwner
- , _activatedAbilities = []
- , _play = Action
- { _available = \rp ->
- (isInHand &&* isControlledBy rp) <$>
- gets (object rSelf)
- , _cost = cost
- , _effect = stack rSelf (effect rOwner rSelf)
- }
- , _timestamp = timestamp
- , _staticAbilities = []
- , _counters = []
- , _effects = []
- }
- }
+-- target :: (Object -> Bool) -> Magic (Ref Object)
+-- target = undefined
+--
+-- targetCreature :: (Object -> Bool) -> Magic (Ref Object)
+-- targetCreature = undefined
+--
+-- targetPlayer :: Magic (Ref Player)
+-- targetPlayer = targetPlayer' (const True)
+--
+-- targetOpponent :: Ref Player -> Magic (Ref Player)
+-- targetOpponent rController = targetPlayer' (\(rp, _) -> rp /= rController)
+--
+-- targetPlayer' :: (WithRef Player -> Bool) -> Magic (Ref Player)
+-- targetPlayer' f = do
+-- rpps <- IntMap.toList <$> gets players
+-- choose [ (TargetPlayer rp, rp) | rpp@(rp, _) <- rpps, f rpp ]
+--
+-- mkInstant :: Text -> [Cost] -> (Ref Player -> Ref Object ->
+-- Magic ()) -> Card
+-- mkInstant name cost effect = Card
+-- { enterWorld = \timestamp rOwner rSelf -> Object
+-- { _name = Just name
+-- , _colors = colorsFromCost cost
+-- , _group = Spell Instant
+-- , _zone = Library
+-- , _owner = rOwner
+-- , _controller = rOwner
+-- , _activatedAbilities = []
+-- , _play = Action
+-- { _available = \rp ->
+-- (isInHand &&* isControlledBy rp) <$>
+-- gets (object rSelf)
+-- , _cost = cost
+-- , _effect = stack rSelf (effect rOwner rSelf)
+-- }
+-- , _timestamp = timestamp
+-- , _staticAbilities = []
+-- , _counters = []
+-- , _effects = []
+-- }
+-- }
-colorsFromCost :: [Cost] -> Set Color
-colorsFromCost = Set.fromList . concatMap f
- where
- f (PayMana colors) = catMaybes colors
- f _ = []
+colorsFromCost :: Cost -> Set Color
+colorsFromCost = Set.fromList . payColoredMana
View
@@ -20,26 +20,5 @@ isControlledBy rp o = rp == get controller o
-- Zones
-isInLibrary :: Object -> Bool
-isInLibrary o =
- case get zone o of
- Library -> True
- _ -> False
-
-isInHand :: Object -> Bool
-isInHand o =
- case get zone o of
- Hand -> True
- _ -> False
-
-isOnStack :: Object -> Bool
-isOnStack o =
- case get zone o of
- Stack _ -> True
- _ -> False
-
-isOnBattlefield :: Object -> Bool
-isOnBattlefield o =
- case get zone o of
- Battlefield _ -> True
- _ -> False
+isInZone :: Zone -> Object -> Bool
+isInZone z o = get zone o == z

0 comments on commit 3f5fca0

Please sign in to comment.