Also consider game finished when the last player reports ROUNDFINISHED despite the correctness parameter.
--- a/gameServer/Actions.hs Wed Feb 29 18:30:37 2012 -0500
+++ b/gameServer/Actions.hs Thu Mar 01 23:35:13 2012 +0400
@@ -311,6 +311,7 @@
AnswerClients chans ["EM", rmTeamMsg],
ModifyRoom (\r -> r{
gameInfo = liftM (\g -> g{
+ teamsInGameNumber = teamsInGameNumber g - 1,
roundMsgs = roundMsgs g Seq.|> rmTeamMsg
}) $ gameInfo r
})
--- a/gameServer/CoreTypes.hs Wed Feb 29 18:30:37 2012 -0500
+++ b/gameServer/CoreTypes.hs Thu Mar 01 23:35:13 2012 +0400
@@ -69,6 +69,7 @@
roundMsgs :: Seq B.ByteString,
leftTeams :: [B.ByteString],
teamsAtStart :: [TeamInfo],
+ teamsInGameNumber :: Int,
allPlayersHaveRegisteredAccounts :: Bool,
giMapParams :: Map.Map B.ByteString B.ByteString,
giParams :: Map.Map B.ByteString [B.ByteString]
--- a/gameServer/HWProtoInRoomState.hs Wed Feb 29 18:30:37 2012 -0500
+++ b/gameServer/HWProtoInRoomState.hs Thu Mar 01 23:35:13 2012 +0400
@@ -179,7 +179,7 @@
return [
ModifyRoom
(\r -> r{
- gameInfo = Just $ newGameInfo (teams rm) allPlayersRegistered (mapParams rm) (params rm)
+ gameInfo = Just $ newGameInfo (teams rm) (length $ teams rm) allPlayersRegistered (mapParams rm) (params rm)
}
),
AnswerClients chans ["RUN_GAME"]
@@ -211,9 +211,10 @@
rm <- thisRoom
chans <- roomClientsChans
let clTeams = map teamname . filter (\t -> teamowner t == nick cl) . teams $ rm
+ let isLastPlayer = (teamsInGameNumber . fromJust . gameInfo $ rm) == length clTeams
if isJust $ gameInfo rm then
- if isMaster cl && isCorrect then
+ if (isMaster cl && isCorrect) || isLastPlayer then
return $
SaveReplay
: ModifyRoom