thock 0.2.0.0 → 0.2.1.0
raw patch · 7 files changed
+34/−29 lines, 7 filesdep ~text
Dependency ranges changed: text
Files
- ChangeLog.md +7/−0
- README.md +2/−0
- src/Server.hs +1/−1
- src/UI/Common.hs +4/−2
- src/UI/Offline.hs +5/−8
- src/UI/Online.hs +6/−9
- thock.cabal +9/−9
ChangeLog.md view
@@ -1,5 +1,12 @@ # Changelog for thock +## 0.2.1.0++Bug fixes:++- [#8](https://github.com/rmehri01/thock/pull/8) Fix replaced words in quotes thanks to [@dedifferentiator](https://github.com/dedifferentiator).+- [#9](https://github.com/rmehri01/thock/pull/9) Stop strokes from increasing after finished thanks to [@dedifferentiator](https://github.com/dedifferentiator).+ ## 0.2.0.0 Fixes:
README.md view
@@ -1,5 +1,7 @@ # thock + [](https://hackage.haskell.org/package/thock)+  ## Installation
src/Server.hs view
@@ -108,7 +108,7 @@ if canStart (map (^. state) $ (ss ^. rooms) Map.! room) && isNothing (Map.lookup room (ss ^. activeGames)) then do- newS <- modifyMVar mState $ \s -> do+ newS <- modifyMVar mState $ \s -> let s' = makeActive room s in return (s', s') q <- generateQuote broadcastTo id room (StartGame q) (newS ^. activeGames)
src/UI/Common.hs view
@@ -30,7 +30,7 @@ import qualified Brick.Widgets.Center as C import qualified Brick.Widgets.Edit as E import qualified Brick.Widgets.ProgressBar as P-import Control.Lens ((^.))+import Control.Lens ((&), (+~), (^.)) import Control.Monad.IO.Class (MonadIO (liftIO)) import Data.FileEmbed (embedFile) import qualified Data.Text as T@@ -52,6 +52,7 @@ numIncorrectChars, quote, secondsElapsed,+ strokes, updateTime, ) import UI.Attributes@@ -165,6 +166,7 @@ -- updating the 'GameState' accordingly updateGameState :: GameState -> Event -> EventM ResourceName GameState updateGameState g ev = do- gEdited <- handleEventLensed g input E.handleEditorEvent ev+ let gWithStroke = g & strokes +~ 1+ gEdited <- handleEventLensed gWithStroke input E.handleEditorEvent ev currentTime <- liftIO getCurrentTime return . updateTime currentTime $ movePromptCursor gEdited
src/UI/Offline.hs view
@@ -31,7 +31,7 @@ import qualified Brick.Widgets.Center as C import qualified Brick.Widgets.List as L import Client (runClient)-import Control.Lens ((&), (+~), (^.))+import Control.Lens ((^.)) import Control.Monad.IO.Class (MonadIO (liftIO)) import qualified Data.Text as T import qualified Graphics.Vty as V@@ -212,11 +212,8 @@ V.EvKey V.KEsc [] -> M.continue initialGame V.EvKey (V.KChar 'r') [V.MCtrl] -> M.continue (startPracticeGame (g ^. quote)) V.EvKey (V.KChar 'n') [V.MCtrl] -> liftIO generateQuote >>= M.continue . startPracticeGame- V.EvKey (V.KChar _) [] -> nextState (g & strokes +~ 1)- _ -> nextState g- where- nextState g' =- if isDone g'- then M.continue (Practice g')- else updateGameState g' ev >>= M.continue . Practice+ _ ->+ if isDone g+ then M.continue (Practice g)+ else updateGameState g ev >>= M.continue . Practice handleKeyPractice g _ = M.continue (Practice g)
src/UI/Online.hs view
@@ -16,7 +16,7 @@ ) import qualified Brick.Main as M import qualified Brick.Widgets.Center as C-import Control.Lens ((%~), (&), (+~), (.~), (^.))+import Control.Lens ((%~), (&), (.~), (^.)) import Control.Monad.IO.Class (MonadIO (liftIO)) import qualified Graphics.Vty as V import Online@@ -141,19 +141,16 @@ handleKeyOnlineState o (VtyEvent ev) = case ev of V.EvKey V.KEsc [] -> liftIO (sendJsonData (o ^. connection) (BackToLobby $ o ^. username)) >> M.continue (OnlineGame o)- V.EvKey (V.KChar _) [] -> nextState (o & (localGame . strokes) +~ 1)- _ -> nextState o- where- nextState o' =- if isDone (o' ^. localGame)- then M.continue (OnlineGame o')+ _ ->+ if isDone (o ^. localGame)+ then M.continue (OnlineGame o) else do- updatedGame <- updateGameState (o' ^. localGame) ev+ updatedGame <- updateGameState (o ^. localGame) ev let newClientState = GameClientState (o ^. username) (calculateProgress updatedGame) (calculateWpm updatedGame) _ <- liftIO $ sendJsonData (o ^. connection) (GameClientUpdate newClientState)- M.continue (OnlineGame $ o' & localGame .~ updatedGame)+ M.continue (OnlineGame $ o & localGame .~ updatedGame) handleKeyOnlineState o _ = M.continue (OnlineGame o)
thock.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: thock-version: 0.2.0.0+version: 0.2.1.0 license: MIT license-file: LICENSE copyright: Copyright (c) 2020 Ryan Mehri@@ -39,7 +39,7 @@ hs-source-dirs: src other-modules: Paths_thock default-language: Haskell2010- default-extensions: OverloadedStrings+ default-extensions: FlexibleContexts OverloadedStrings build-depends: aeson >=1.4.7.1 && <1.5, base >=4.7 && <5,@@ -50,7 +50,7 @@ mtl >=2.2.2 && <2.3, network >=3.1.1.1 && <3.2, random ==1.1.*,- text >=1.2.4.0 && <1.3,+ text >=1.2.3.0 && <1.3, text-zipper >=0.10.1 && <0.11, time >=1.9.3 && <1.10, vector >=0.12.1.2 && <0.13,@@ -62,7 +62,7 @@ hs-source-dirs: app other-modules: Paths_thock default-language: Haskell2010- default-extensions: OverloadedStrings+ default-extensions: FlexibleContexts OverloadedStrings ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall build-depends: aeson >=1.4.7.1 && <1.5,@@ -74,7 +74,7 @@ mtl >=2.2.2 && <2.3, network >=3.1.1.1 && <3.2, random ==1.1.*,- text >=1.2.4.0 && <1.3,+ text >=1.2.3.0 && <1.3, text-zipper >=0.10.1 && <0.11, thock -any, time >=1.9.3 && <1.10,@@ -87,7 +87,7 @@ hs-source-dirs: app other-modules: Paths_thock default-language: Haskell2010- default-extensions: OverloadedStrings+ default-extensions: FlexibleContexts OverloadedStrings ghc-options: -O3 -threaded -rtsopts -with-rtsopts=-N -Wall build-depends: aeson >=1.4.7.1 && <1.5,@@ -99,7 +99,7 @@ mtl >=2.2.2 && <2.3, network >=3.1.1.1 && <3.2, random ==1.1.*,- text >=1.2.4.0 && <1.3,+ text >=1.2.3.0 && <1.3, text-zipper >=0.10.1 && <0.11, thock -any, time >=1.9.3 && <1.10,@@ -113,7 +113,7 @@ hs-source-dirs: test other-modules: Paths_thock default-language: Haskell2010- default-extensions: OverloadedStrings+ default-extensions: FlexibleContexts OverloadedStrings ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall build-depends: aeson >=1.4.7.1 && <1.5,@@ -125,7 +125,7 @@ mtl >=2.2.2 && <2.3, network >=3.1.1.1 && <3.2, random ==1.1.*,- text >=1.2.4.0 && <1.3,+ text >=1.2.3.0 && <1.3, text-zipper >=0.10.1 && <0.11, thock -any, time >=1.9.3 && <1.10,