From f4b0e4ec20cd903b7a603edfb043a21bb175b246 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Thu, 30 Jul 2020 17:02:43 +0200 Subject: Refactor name changing --- server/lib/Cafp/Game.hs | 6 +++--- server/lib/Cafp/Messages.hs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'server/lib/Cafp') 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 -- cgit v1.2.3