Add lasCircle
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user