Permalink
Browse files

Newlines

  • Loading branch information...
1 parent 674d44b commit 03412c50003be2c95ae707c743ecec7f194b57d7 @MedeaMelana committed Sep 3, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 Engine.hs
View
@@ -34,6 +34,9 @@ nextStep = do
activeStep =: s
return s
+
+-- Execution of steps
+
executeStep :: Step -> Engine ()
executeStep (BeginningPhase UntapStep) = do
@@ -137,28 +140,37 @@ executeEffect e = do
-- TODO apply replacement effects
compileEffect e
+
+-- Compilation of effects
+
compileEffect :: OneShotEffect -> Engine ()
+
compileEffect (UntapPermanent ro) =
battlefield .^ listEl ro .^ tapStatus =: Just Untapped
+
compileEffect (DrawCard rp) = do
lib <- gets (players .^ listEl rp .^ library)
case IdList.toList lib of
[] -> players .^ listEl rp .^ failedCardDraw =: True
(ro, _) : _ -> executeEffect (MoveObject (Library rp, ro) (Hand rp))
+
compileEffect (MoveObject (rFromZone, i) rToZone) = do
mObject <- IdList.removeM (compileZoneRef rFromZone) i
case mObject of
Nothing -> return ()
Just object -> do
t <- tick
void (IdList.consM (compileZoneRef rToZone) (set timestamp t object))
+
compileEffect (ShuffleLibrary rPlayer) = do
let libraryLabel = players .^ listEl rPlayer .^ library
lib <- gets libraryLabel
lib' <- lift (IdList.shuffle lib)
puts libraryLabel lib'
+
compileEffect _ = undefined
+
tick :: Engine Timestamp
tick = do
t <- gets time

0 comments on commit 03412c5

Please sign in to comment.