Cleanup
This commit is contained in:
+30
-10
@@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Dodge.WorldEffect (
|
||||
doWdWd,
|
||||
accessTerminal,
|
||||
@@ -52,10 +53,9 @@ doWdWd we = case we of
|
||||
return $ heldEffectMuzzles loc cr w
|
||||
|
||||
accessTerminal :: Int -> World -> World
|
||||
accessTerminal tid w = fromMaybe w $ do -- should possibly check the terminal actually exists
|
||||
return $
|
||||
w & hud . hudElement . subInventory .~ DisplayTerminal tid
|
||||
& cWorld . lWorld . terminals . ix tid %~ tryToBoot
|
||||
accessTerminal tid =
|
||||
(hud . hudElement . subInventory .~ DisplayTerminal tid)
|
||||
. (cWorld . lWorld . terminals . ix tid %~ tryToBoot)
|
||||
where
|
||||
tryToBoot tm = case _tmStatus tm of
|
||||
TerminalTextInput{} -> tm
|
||||
@@ -98,17 +98,18 @@ doTmWdWd tmwdwd = case tmwdwd of
|
||||
return $ cWorld . lWorld . terminals . ix tid . tmDisplayedLines .~ []
|
||||
TmGetDamageCoding st -> \tm w -> fromMaybe w $ do
|
||||
tid <- tm ^? tmID
|
||||
return $ w & cWorld . lWorld . terminals . ix tid . tmFutureLines
|
||||
.~ decodeSensorType st w
|
||||
return $
|
||||
w & cWorld . lWorld . terminals . ix tid . tmFutureLines
|
||||
.~ decodeSensorType st w
|
||||
TmGetSensor s -> \tm w -> fromMaybe w $ do
|
||||
tid <- tm ^? tmID
|
||||
return $ w & cWorld . lWorld . terminals . ix tid . tmFutureLines .~ getSensorInfo w tm s
|
||||
TmTmSetStatus x -> \tm -> fromMaybe id $ do
|
||||
tid <- tm ^? tmID
|
||||
return $ cWorld . lWorld . terminals . ix tid . tmStatus .~ x
|
||||
-- TmDisplayCommands -> \tm -> fromMaybe id $ do
|
||||
-- tid <- tm ^? tmID
|
||||
-- return $ cWorld . lWorld . terminals . ix tid %~ tabComplete ""
|
||||
-- TmDisplayCommands -> \tm -> fromMaybe id $ do
|
||||
-- tid <- tm ^? tmID
|
||||
-- return $ cWorld . lWorld . terminals . ix tid %~ tabComplete ""
|
||||
--return $ cWorld . lWorld . terminals . ix tid . tmFutureLines .~
|
||||
-- makeColorTermPara commandColor
|
||||
-- (unwords (map fst (PTE.toList $ getCommands tm)))
|
||||
@@ -124,11 +125,30 @@ doTmWdWd tmwdwd = case tmwdwd of
|
||||
TmWdWdDoDeathTriggers -> doDeathTriggers
|
||||
TmWdWdfromWdWd f -> \_ -> doWdWd f
|
||||
|
||||
powerDownTerminal :: Terminal -> World -> World
|
||||
powerDownTerminal tm =
|
||||
(cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ TerminalOff)
|
||||
. (cWorld . lWorld . terminals . ix (_tmID tm) . tmDisplayedLines .~ [])
|
||||
. exitTerminalSubInv
|
||||
|
||||
deactivateTerminal :: Terminal -> World -> World
|
||||
deactivateTerminal tm =
|
||||
(cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ TerminalDeactivated)
|
||||
. (cWorld . lWorld . terminals . ix (_tmID tm) . tmDisplayedLines .~ [])
|
||||
. exitTerminalSubInv
|
||||
|
||||
exitTerminalSubInv :: World -> World
|
||||
exitTerminalSubInv w = case w ^? hud . hudElement . subInventory . termID of
|
||||
Just _ ->
|
||||
w & hud . hudElement . subInventory
|
||||
.~ NoSubInventory --MouseInvNothing
|
||||
_ -> w
|
||||
|
||||
decodeSensorType :: SensorType -> World -> [TerminalLine]
|
||||
decodeSensorType st w = fromMaybe [] $ do
|
||||
x <- w ^? cWorld . cwGen . cwgParams . sensorCoding . ix st
|
||||
return [makeTermLine $ show x]
|
||||
|
||||
|
||||
-- ugly, when changing check sensorCommand
|
||||
getSensorInfo :: World -> Terminal -> String -> [TerminalLine]
|
||||
getSensorInfo w tm = \case
|
||||
|
||||
Reference in New Issue
Block a user