Skip to content
Snippets Groups Projects
Commit b52fc7fc authored by Unai Zalakain's avatar Unai Zalakain
Browse files

Call the winner reporting function only once for all the local players

parent cf3a02d7
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ module Snorkels.Game ( LocalConfig (..)
, ComputerConfig (..)
, PlayerType (..)
, Game (..)
, isLocal
, getSurvivors
, advancePlayer
, getNextPlayer
......@@ -38,6 +39,11 @@ data Game = Game {
}
isLocal :: PlayerType -> Bool
isLocal (LocalPlayer _) = True
isLocal _ = False
getSurvivors :: Game -> [Player]
getSurvivors game = case filter hasSurvived players of
[] -> [game&currentPlayer]
......
......@@ -42,9 +42,11 @@ playRound playFunc game = do g <- playFunc game Nothing
reportWinnerAround :: Game -> IO ()
reportWinnerAround game = case getWinner game of
Just winner -> mapM_ (reportToPT winner) pts
Just winner -> do mapM_ (reportToPT winner) nonlocals
maybe (return ()) (reportToPT winner) (listToMaybe locals)
Nothing -> return ()
where pts = Map.elems $ game&playerTypes
(locals, nonlocals) = partition isLocal pts
reportToPT winner pt = reportWinner pt game winner
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment