aboutsummaryrefslogtreecommitdiff
path: root/server/lib/Cafp/Game.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt2020-07-30 19:42:26 +0200
committerJasper Van der Jeugt2020-07-30 19:42:26 +0200
commit3b7d11c6182b8aa3d3d4f9e36c213e4eba6c8d8f (patch)
treeefbf3a064adefa8cc1228edec835d7403068e779 /server/lib/Cafp/Game.hs
parentfe56ddfbd14b3e7fbaee8732641bcc00fbd0c856 (diff)
Add cards from CardsAgainstCryptography
Diffstat (limited to '')
-rw-r--r--server/lib/Cafp/Game.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/server/lib/Cafp/Game.hs b/server/lib/Cafp/Game.hs
index af958ae..a083e57 100644
--- a/server/lib/Cafp/Game.hs
+++ b/server/lib/Cafp/Game.hs
@@ -3,6 +3,7 @@
{-# LANGUAGE TemplateHaskell #-}
module Cafp.Game
( PlayerId
+ , Cards (..)
, Game (..)
, newGame
@@ -15,7 +16,7 @@ module Cafp.Game
) where
import Cafp.Messages
-import Control.Lens (at, ix, over, (%~), (&), (.~), (^.))
+import Control.Lens (at, ix, over, (%~), (&), (.~), (^.), (^?))
import Control.Lens.TH (makeLenses)
import qualified Data.HashMap.Strict as HMS
import Data.Maybe (fromMaybe)
@@ -24,15 +25,22 @@ import qualified Data.Text as T
type PlayerId = Int
+data Cards = Cards
+ { _cardsBlack :: [T.Text]
+ , _cardsWhite :: [T.Text]
+ } deriving (Show)
+
data Game = Game
- { _gamePlayers :: !(HMS.HashMap Int Text)
+ { _gameCards :: !Cards
+ , _gamePlayers :: !(HMS.HashMap Int Text)
, _gameNextPlayerId :: !Int
} deriving (Show)
+makeLenses ''Cards
makeLenses ''Game
-newGame :: Game
-newGame = Game HMS.empty 1
+newGame :: Cards -> Game
+newGame cards = Game cards HMS.empty 1
joinGame :: Game -> (PlayerId, Game)
joinGame game =
@@ -58,4 +66,5 @@ gameViewForPlayer self game =
GameView
{ gameViewOpponents = opponents
, gameViewMyName = name
+ , gameViewBlackCard = game ^? gameCards . cardsBlack . ix 0
}