aboutsummaryrefslogtreecommitdiff
path: root/server/lib
diff options
context:
space:
mode:
authorJasper Van der Jeugt2020-08-02 21:52:46 +0200
committerJasper Van der Jeugt2020-08-02 21:52:46 +0200
commit477dae400d5f32a0572698ba132a26bc4a340975 (patch)
treeb74ebd8d52c4be5523ff478240cc6731ecf1b61f /server/lib
parentfce7342703e8d6353f65cf28914948366f54ef81 (diff)
Admin but it's broken
Diffstat (limited to 'server/lib')
-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)