Implemented toggling functionality for Level Acceleration Mode

This commit is contained in:
hello 2024-12-06 15:32:32 +05:30
parent b0c7f6c557
commit f074add7a3
7 changed files with 222 additions and 75 deletions

View file

@ -9,7 +9,7 @@ import qualified System.Directory as D
import System.FilePath ((</>))
import Tetris (Game(..))
import UI.PickLevel (pickLevel)
import UI.PickLevel (pickLevel, LevelConfig(..))
import UI.Game (playGame)
data Opts = Opts
@ -70,11 +70,11 @@ hdOptStr (CustomChars s) = Just s
main :: IO ()
main = do
(Opts hd ml hs) <- execParser fullopts -- get CLI opts/args
when hs (getHighScore >>= printM >> exitSuccess) -- show high score and exit
l <- maybe pickLevel return ml -- pick level prompt if necessary
g <- playGame l (hdOptStr hd) -- play game
handleEndGame (_score g) -- save & print score
(Opts hd ml hs) <- execParser fullopts
when hs (getHighScore >>= printM >> exitSuccess)
levelConfig <- maybe pickLevel (\l -> return $ LevelConfig l False) ml
g <- playGame (levelNumber levelConfig) (hdOptStr hd) (progression levelConfig)
handleEndGame (_score g)
handleEndGame :: Int -> IO ()
handleEndGame s = do