summaryrefslogtreecommitdiff
path: root/Game.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Game.hs')
-rw-r--r--Game.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/Game.hs b/Game.hs
index 203b66f..c55acf5 100644
--- a/Game.hs
+++ b/Game.hs
@@ -5,14 +5,13 @@ import Control.Monad (when)
import System.Random (RandomGen)
import Player (Player, shed, draw)
import qualified Player as P
-import Card (Card)
+import Card (Card(..))
import qualified Card as C
-data Direction = CCW | CW
data Game = Game { players :: [Player]
, playerIdx :: Int
, attack :: Integer
- , direction :: Direction
+ , direction :: Int -- ^ 1 when CCW, -1 when CW
, stockPile :: [Card]
, discardPile :: [Card]
}
@@ -29,6 +28,7 @@ nextRound n game = do
-- | Let current player take their turn.
nextTurn :: Game -> IO Game
nextTurn game@(Game plyrs pidx att dir stock disc) = do
+ putStrLn $ replicate 80 '-'
decision <- prompt game
let player = plyrs !! pidx
let player' = case decision of
@@ -42,8 +42,13 @@ nextTurn game@(Game plyrs pidx att dir stock disc) = do
Just card -> card:disc
let (left, right) = splitAt pidx plyrs
let plyrs' = left ++ [player'] ++ (tail right)
- let pidx' = (pidx + 1) `mod` (length plyrs)
- let game' = Game plyrs' pidx' att dir stock' disc'
+ let dir' = case decision of
+ Just (Card _ C.Queen) -> negate dir
+ _ -> dir
+ let pidx' = case decision of
+ Just (Card _ C.Jack) -> (pidx + 2 * dir') `mod` length plyrs
+ _ -> (pidx + dir') `mod` length plyrs
+ let game' = Game plyrs' pidx' att dir' stock' disc'
case decision of
Nothing -> do