aboutsummaryrefslogtreecommitdiff
path: root/server/lib/Cafp
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/Cafp')
-rw-r--r--server/lib/Cafp/Game.hs11
-rw-r--r--server/lib/Cafp/Messages.hs1
2 files changed, 7 insertions, 5 deletions
diff --git a/server/lib/Cafp/Game.hs b/server/lib/Cafp/Game.hs
index 0f80857..db904d6 100644
--- a/server/lib/Cafp/Game.hs
+++ b/server/lib/Cafp/Game.hs
@@ -106,9 +106,9 @@ newGame cards gen = flip execState state0 $ do
joinGame :: Game -> (PlayerId, Game)
joinGame = runState $ do
pid <- gameNextPlayerId %%= (\x -> (x, x + 1))
- hasAdmin <- use (gamePlayers . traverse . playerAdmin . Any)
+ haveAdmin <- use (gamePlayers . traverse . playerAdmin . to Any)
let name = "Player " <> T.pack (show pid)
- admin = not (getAny hasAdmin)
+ admin = not (getAny haveAdmin)
hand <- V.replicateM 6 popWhiteCard
gamePlayers %= HMS.insert pid (Player name hand admin)
pure pid
@@ -170,9 +170,10 @@ gameViewForPlayer self game =
let opponents = do
(pid, p) <- HMS.toList $ game ^. gamePlayers
guard $ pid /= self
- pure $ Opponent (p ^. playerName) $ case game ^. gameTable of
- TableProposing _ proposals -> HMS.member pid proposals
- TableVoting _ _ votes -> HMS.member pid votes
+ let ready = case game ^. gameTable of
+ TableProposing _ proposals -> HMS.member pid proposals
+ TableVoting _ _ votes -> HMS.member pid votes
+ pure $ Opponent (p ^. playerName) (p ^. playerAdmin) ready
player = game ^. gamePlayers . at self
diff --git a/server/lib/Cafp/Messages.hs b/server/lib/Cafp/Messages.hs
index df447c3..cfc8597 100644
--- a/server/lib/Cafp/Messages.hs
+++ b/server/lib/Cafp/Messages.hs
@@ -32,6 +32,7 @@ data Cards = Cards
data Opponent = Opponent
{ opponentName :: Text
+ , opponentAdmin :: Bool
, opponentReady :: Bool
} deriving (Show)