Add lasCircle

This commit is contained in:
2022-07-08 22:14:44 +01:00
parent 68cb191063
commit ce533c22cb
8 changed files with 91 additions and 21 deletions
+8 -2
View File
@@ -17,6 +17,7 @@ import Control.Lens
import Text.Read (readMaybe)
import Data.List --(isPrefixOf, isInfixOf, intercalate)
import Data.Maybe
import Control.Applicative
import LensHelp
import qualified Data.Text as T
import qualified IntMapHelp as IM
@@ -61,10 +62,15 @@ applyTerminalCommand s = case s of
applyTerminalCommandArguments :: String -> [String] -> Universe -> Universe
applyTerminalCommandArguments command args u = case command of
"ITEM" -> fromMaybe u $ do
ibt <- safeHead args >>= readMaybe
return $ u & uvWorld %~ (snd . createPutItem (itemFromBase ibt))
ibt <- (safeHead args >>= readMaybe) <|> (safeTake2 args >>= (readMaybe . unwords))
n <- (args ^? ix 1 >>= readMaybe) <|> Just 1
return $ u & uvWorld %~ (flip (foldr ($)) $ replicate n (snd . createPutItem (itemFromBase ibt)))
_ -> u
safeTake2 :: [a] -> Maybe [a]
safeTake2 (x:y:_) = Just (x:y:[])
safeTake2 _ = Nothing
showTerminalError :: String -> String -> Universe -> Universe
showTerminalError cmd s = menuLayers .:~ InputScreen (T.pack cmd) s