Broken: refactor terminals

This commit is contained in:
2022-07-25 00:45:15 +01:00
parent d1bf49319a
commit d219d8d889
25 changed files with 505 additions and 364 deletions
+10 -3
View File
@@ -4,6 +4,9 @@ Module : Dodge.Update
Description : Simulation update
-}
module Dodge.Update ( updateUniverse ) where
import Dodge.TmTm
import Dodge.Terminal
import Color
import Dodge.DrWdWd
import Dodge.TractorBeam.Update
import Dodge.Prop.Update
@@ -164,20 +167,24 @@ updateWorldSelect w = f . g $ case (w ^? mouseButtons . ix ButtonLeft, w ^? mous
-- | _mcHP mc > 0 = _mcUpdate mc mc'
-- | otherwise = destroyMachine mc
displayTerminalLineString :: TerminalLineString -> World -> (String,Color)
displayTerminalLineString tls = case tls of
TerminalLineConst str col -> const (str,col)
tmUpdate :: Terminal -> World -> World
tmUpdate tm w = case w ^? terminals . ix (_tmID tm) . tmFutureLines . ix 0 of
Nothing -> w
Just tl | _tlPause tl > 0 -> w & pointTermParams . tmFutureLines . ix 0 . tlPause -~ 1
Just (TerminalLineDisplay _ f) -> w & pointTermParams %~
( ( tmFutureLines %~ tail )
. ( tmDisplayedLines .:~ f w )
. ( tmDisplayedLines .:~ displayTerminalLineString f w )
)
Just (TerminalLineEffect _ eff) -> w
& pointTermParams . tmFutureLines %~ tail
& eff tm
& doTmWdWd eff tm
Just (TerminalLineTerminalEffect _ eff) -> w
& pointTermParams . tmFutureLines %~ tail
& pointTermParams %~ eff
& pointTermParams %~ doTmTm eff
where
pointTermParams = terminals . ix (_tmID tm)