equal
deleted
inserted
replaced
12 --------------- |
12 --------------- |
13 import CoreTypes |
13 import CoreTypes |
14 |
14 |
15 |
15 |
16 saveReplay :: RoomInfo -> IO () |
16 saveReplay :: RoomInfo -> IO () |
17 saveReplay r = do |
17 saveReplay r = when allPlayersHaveRegisteredAccounts $ do |
18 time <- getCurrentTime |
18 time <- getCurrentTime |
19 u <- liftM hashUnique newUnique |
19 u <- liftM hashUnique newUnique |
20 let fileName = "replays/" ++ show time ++ "-" ++ show u |
20 let fileName = "replays/" ++ show time ++ "-" ++ show u |
21 let gi = fromJust $ gameInfo r |
21 let gi = fromJust $ gameInfo r |
22 let replayInfo = (teamsAtStart gi, Map.toList $ mapParams r, Map.toList $ params r, roundMsgs gi) |
22 let replayInfo = (teamsAtStart gi, Map.toList $ mapParams r, Map.toList $ params r, roundMsgs gi) |
23 E.catch |
23 E.catch |
24 (writeFile fileName (show replayInfo)) |
24 (writeFile fileName (show replayInfo)) |
25 (\(e :: IOException) -> warningM "REPLAYS" $ "Couldn't write to " ++ fileName ++ ": " ++ show e) |
25 (\(e :: IOException) -> warningM "REPLAYS" $ "Couldn't write to " ++ fileName ++ ": " ++ show e) |
26 |
|