Work on terminals

This commit is contained in:
2023-05-03 11:19:47 +01:00
parent 61f88aeb4a
commit ed8d8f0e93
8 changed files with 79 additions and 107 deletions
+18 -20
View File
@@ -1,9 +1,9 @@
module Dodge.WorldEffect
( doWdWd
, accessTerminal
, doTmWdWd
, lineOutputTerminal
) where
module Dodge.WorldEffect (
doWdWd,
accessTerminal,
doTmWdWd,
lineOutputTerminal,
) where
import Data.Foldable
import qualified Data.Map.Strict as M
@@ -46,20 +46,20 @@ doItCrWdWd icww = case icww of
ItCrWdItemEffect -> flip itemEffect
accessTerminal :: Maybe Int -> World -> World
accessTerminal mtmid w = case mtmid of
Nothing -> w
Just tmid ->
accessTerminal mtmid w = fromMaybe w $ do
tmid <- mtmid
return $
w & hud . hudElement . subInventory .~ DisplayTerminal tmid
& cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus .~ True
& cWorld . lWorld . terminals . ix tmid %~ tryToBoot
where
tryToBoot tm = case _tmStatus tm of
TerminalReady -> tm
TerminalBusy -> tm
TerminalOff ->
tm
& tmFutureLines .~ doTerminalBootProgram (_tmBootProgram tm) tm w
& tmStatus .~ TerminalBusy
where
tryToBoot tm = case _tmStatus tm of
TerminalReady -> tm
TerminalBusy -> tm
TerminalOff ->
tm
& tmFutureLines .~ doTerminalBootProgram (_tmBootProgram tm) tm w
& tmStatus .~ TerminalBusy
torqueCr :: Float -> Int -> World -> World
torqueCr x cid w
@@ -82,9 +82,7 @@ lineOutputTerminal tls =
}
doDeathTriggers :: Terminal -> World -> World
doDeathTriggers tm w =
w
& cWorld . lWorld . triggers %~ flip (foldl' $ flip doDeathToggle) xs
doDeathTriggers tm = cWorld . lWorld . triggers %~ flip (foldl' $ flip doDeathToggle) xs
where
xs = M.elems $ _tmToggles tm