diff options
author | Jasper Van der Jeugt | 2020-07-30 17:02:43 +0200 |
---|---|---|
committer | Jasper Van der Jeugt | 2020-07-30 17:02:43 +0200 |
commit | f4b0e4ec20cd903b7a603edfb043a21bb175b246 (patch) | |
tree | 72e16e3b6851d238698c1d076c73a04e0a618786 /server | |
parent | f5a7875d605010540ec7c9c8f2a3ff4ed0702597 (diff) |
Refactor name changing
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/Cafp/Game.hs | 6 | ||||
-rw-r--r-- | server/lib/Cafp/Messages.hs | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/server/lib/Cafp/Game.hs b/server/lib/Cafp/Game.hs index f3d500f..af958ae 100644 --- a/server/lib/Cafp/Game.hs +++ b/server/lib/Cafp/Game.hs @@ -48,7 +48,7 @@ leaveGame pid = over gamePlayers $ HMS.delete pid processClientMessage :: PlayerId -> ClientMessage -> Game -> Game processClientMessage pid msg game = case msg of - ChangeName name -> + ChangeMyName name -> game & gamePlayers . ix pid .~ name gameViewForPlayer :: PlayerId -> Game -> GameView @@ -56,6 +56,6 @@ gameViewForPlayer self game = let opponents = map snd . HMS.toList . HMS.delete self $ game ^. gamePlayers name = fromMaybe "" $ game ^. gamePlayers . at self in GameView - { gameViewOpponents = opponents - , gameViewPlayerName = name + { gameViewOpponents = opponents + , gameViewMyName = name } diff --git a/server/lib/Cafp/Messages.hs b/server/lib/Cafp/Messages.hs index d92ce80..29f5575 100644 --- a/server/lib/Cafp/Messages.hs +++ b/server/lib/Cafp/Messages.hs @@ -9,8 +9,8 @@ import Data.Text (Text) import Elm.Derive data GameView = GameView - { gameViewOpponents :: [Text] - , gameViewPlayerName :: Text + { gameViewOpponents :: [Text] + , gameViewMyName :: Text } deriving (Show) data ServerMessage @@ -20,7 +20,7 @@ data ServerMessage deriving (Show) data ClientMessage - = ChangeName Text + = ChangeMyName Text deriving (Show) deriveBoth (defaultOptionsDropLower 8) ''GameView |