diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | onecard.cabal | 19 | ||||
-rw-r--r-- | src/Card.hs (renamed from Card.hs) | 0 | ||||
-rw-r--r-- | src/Color.hs (renamed from Color.hs) | 0 | ||||
-rw-r--r-- | src/Game.hs (renamed from Game.hs) | 8 | ||||
-rw-r--r-- | src/Main.hs (renamed from Main.hs) | 0 | ||||
-rw-r--r-- | src/Player.hs (renamed from Player.hs) | 4 |
7 files changed, 26 insertions, 6 deletions
@@ -1,4 +1,5 @@ .undodir/ +dist-newstyle/ *.hi *.o Main diff --git a/onecard.cabal b/onecard.cabal new file mode 100644 index 0000000..c4d2ef4 --- /dev/null +++ b/onecard.cabal @@ -0,0 +1,19 @@ +name: onecard +version: 0.1.0 +build-type: Simple +cabal-version: 1.18 + +library + default-language: Haskell2010 + exposed-modules: Game, Player, Card, Color + hs-source-dirs: src + build-depends: base, random + ghc-options: -dynamic + +executable onecard + default-language: Haskell2010 + hs-source-dirs: src + build-depends: base, random, optparse-applicative, onecard + main-is: Main.hs + other-modules: Game, Player, Card, Color + ghc-options: -dynamic @@ -34,12 +34,8 @@ beginGame setup@(Setup n r d c a) = do gen <- getStdGen let decks = C.shuffle gen $ C.fullDecks d let stock = drop n decks - let defaultPlayers = [ Player "Alice" 0 [] - , Player "Bob" 0 [] - , Player "Carol" 0 [] - ] - pidx <- firstPlayer defaultPlayers decks - let game = Game { players = defaultPlayers + pidx <- firstPlayer P.defaultPlayers decks + let game = Game { players = P.defaultPlayers , playerIdx = pidx , attack = 1 , direction = 1 diff --git a/Player.hs b/src/Player.hs index 3bec60c..8b64c79 100644 --- a/Player.hs +++ b/src/Player.hs @@ -10,6 +10,10 @@ data Player = Player { name :: String , cards :: [Card] } +defaultPlayers :: [Player] +defaultPlayers = map (\name -> Player name 0 []) $ + ["Alice", "Bob", "Carol", "David", "Eve", "Frank", "Gina", "Howard"] + -- | Update `i`-th player in `ps` to `p`. update :: [Player] -> Int -> Player -> [Player] update ps i p = |