Add distance indicator for forcefield gun
This commit is contained in:
+15
-13
@@ -108,23 +108,20 @@ getCommandsHelp :: Terminal -> World -> M.Map String [TerminalLine]
|
||||
--getCommandsHelp tm w = fromMaybe mempty $ do
|
||||
-- tcs <- getCommands tm w
|
||||
-- return $ foldr f mempty tcs
|
||||
getCommandsHelp tm w = maybe mempty (foldr f mempty) (getCommands tm w)
|
||||
getCommandsHelp tm w = foldr f mempty $ getCommands tm
|
||||
where
|
||||
f tc = M.insert (_tcString tc)
|
||||
( [makeTermLine "COMMAND:"
|
||||
, makeColorTermLine yellow (_tcString tc)
|
||||
, makeColorTermLine commandColor (_tcString tc)
|
||||
,makeTermLine "ALIASES:"
|
||||
, makeColorTermLine yellow ( unwords (_tcAlias tc)) ]
|
||||
, makeColorTermLine commandColor ( unwords (_tcAlias tc)) ]
|
||||
++ case argumentHelp tc tm w of
|
||||
(arghelp,Nothing) -> makeTermPara $ _tcHelp tc ++ " " ++ arghelp
|
||||
(arghelp,Just args) -> makeTermPara (_tcHelp tc ++ " " ++ arghelp)
|
||||
++ [makeColorTermLine yellow $ unwords args]
|
||||
++ [makeColorTermLine commandColor $ unwords args]
|
||||
)
|
||||
getCommands :: Terminal -> World -> Maybe [TerminalCommand]
|
||||
getCommands tm w = do
|
||||
commands1 <- w ^? terminals . ix (_tmID tm) . tmScrollCommands
|
||||
commands2 <- w ^? terminals . ix (_tmID tm) . tmWriteCommands
|
||||
return $ commands1 ++ commands2
|
||||
getCommands :: Terminal -> [TerminalCommand]
|
||||
getCommands tm = _tmScrollCommands tm ++ _tmWriteCommands tm
|
||||
|
||||
infoClearInput :: Terminal -> [TerminalLine] -> World -> World
|
||||
infoClearInput tm tls = terminals . ix (_tmID tm) %~
|
||||
@@ -142,6 +139,9 @@ argumentHelp tc tm w = case _tcEffect tc tm w of
|
||||
makeTermPara :: String -> [TerminalLine]
|
||||
makeTermPara = map makeTermLine . makeParagraph 60
|
||||
|
||||
makeColorTermPara :: Color -> String -> [TerminalLine]
|
||||
makeColorTermPara col = map (makeColorTermLine col) . makeParagraph 60
|
||||
|
||||
makeColorTermLine :: Color -> String -> TerminalLine
|
||||
makeColorTermLine col str = TerminalLineDisplay 0 $ const (str,col)
|
||||
|
||||
@@ -168,12 +168,15 @@ commandsCommand = TerminalCommand
|
||||
{ _tcString = "COMMANDS"
|
||||
, _tcAlias = ["COMMAND","COM"]
|
||||
, _tcHelp = "DISPLAYS AVAILABLE COMMANDS."
|
||||
, _tcEffect = \tm w -> NoArguments
|
||||
, _tcEffect = \tm _ -> NoArguments
|
||||
( makeTermLine "AVAILABLE COMMANDS:"
|
||||
: makeTermPara (unwords (maybe [""] (map _tcString) $ getCommands tm w))
|
||||
: makeColorTermPara commandColor (unwords (map _tcString $ getCommands tm))
|
||||
)
|
||||
}
|
||||
|
||||
commandColor :: Color
|
||||
commandColor = yellow
|
||||
|
||||
singleCommand :: [String] -> String -> [String] -> String -> (World -> World) -> TerminalCommand
|
||||
singleCommand followingLines command aliases htext eff = TerminalCommand
|
||||
{_tcString = command
|
||||
@@ -197,9 +200,8 @@ terminalReturnEffect tm w = fromMaybe w $ do
|
||||
|
||||
commandFutureLines :: String -> Terminal -> World -> [TerminalLine]
|
||||
commandFutureLines s tm w = fromMaybe [errline "^ INVALID COMMAND"] $ do
|
||||
commands <- getCommands tm w
|
||||
(str,args) <- safeUncons $ words s
|
||||
command <- find (\tc -> _tcString tc == str || str `elem` _tcAlias tc) commands
|
||||
command <- find (\tc -> _tcString tc == str || str `elem` _tcAlias tc) (getCommands tm)
|
||||
case _tcEffect command tm w of
|
||||
NoArguments tls -> Just tls
|
||||
OneArgument argtype m -> Just $ fromMaybe [errline $ "^ INVALID ARGUMENT: EXPECTS "++ argtype]
|
||||
|
||||
Reference in New Issue
Block a user