Make analyser into one machine
This commit is contained in:
@@ -34,6 +34,47 @@ import Data.Maybe
|
||||
--import Control.Monad.State
|
||||
--import System.Random
|
||||
|
||||
|
||||
initMCUpdate
|
||||
:: (Machine -> World -> World)
|
||||
-> (Machine -> World -> World)
|
||||
-> Machine -> World -> World
|
||||
initMCUpdate initup f mc
|
||||
= (machines . ix (_mcID mc) . mcUpdate .~ f)
|
||||
. initup mc
|
||||
|
||||
analyser'
|
||||
:: [String] -- | initial text
|
||||
-> String -- | succeed text
|
||||
-> String -- | fail text
|
||||
-> [String] -- | after text
|
||||
-> (Machine -> World -> World)
|
||||
-> PlacementSpot
|
||||
-> PlacementSpot
|
||||
-> Placement
|
||||
analyser' starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \tp ->
|
||||
Just $ updatebuttonname $ plSpot .~ psmc $ putTerminal' aquamarine (termupdate tp)
|
||||
where
|
||||
termupdate tp btid = initMCUpdate
|
||||
(\mc -> buttons . ix btid . btTerminalParams .~
|
||||
TerminalParams
|
||||
{ _termDisplayedLines = []
|
||||
, _termFutureLines = map simpleline starts
|
||||
++ [testline' (_mcID mc)]
|
||||
++ map simpleline afters
|
||||
, _termMaxLines = 7
|
||||
, _termTitle = "ANALYSER"
|
||||
}
|
||||
)
|
||||
(\mc -> upf mc . (triggers . ix (fromJust $ _plMID tp) .~ const (_mcSensorToggle mc))
|
||||
)
|
||||
simpleline str = TerminalLineDisplay {_tlPause = 0, _tlString = const (str,white)}
|
||||
testline' mcid = TerminalLineDisplay 0 (testline mcid)
|
||||
testline mcid w = case w ^? machines . ix mcid . mcSensorToggle of
|
||||
Just True -> (sucs,green)
|
||||
_ -> (fails,red)
|
||||
updatebuttonname = plType . putButton . btText .~ "ANALYSER"
|
||||
|
||||
analyser
|
||||
:: [String] -- | initial text
|
||||
-> String -- | succeed text
|
||||
@@ -52,12 +93,13 @@ analyser starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \tp
|
||||
}
|
||||
) $ \anmc -> Just
|
||||
$ plSpot .~ shiftRelativeToPS (V2 20 0) (_plSpot anmc)
|
||||
$ putTerminal $ const $ TerminalParams
|
||||
$ updatebuttontext $ putTerminal $ const $ TerminalParams
|
||||
{ _termDisplayedLines = []
|
||||
, _termFutureLines = map simpleline starts
|
||||
++ [testline' (fromJust $ _plMID anmc)]
|
||||
++ map simpleline afters
|
||||
, _termMaxLines = 7
|
||||
, _termTitle = "ANALYSER"
|
||||
}
|
||||
where
|
||||
simpleline str = TerminalLineDisplay {_tlPause = 0, _tlString = const (str,white)}
|
||||
@@ -65,6 +107,7 @@ analyser starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \tp
|
||||
testline mcid w = case w ^? machines . ix mcid . mcSensorToggle of
|
||||
Just True -> (sucs,green)
|
||||
_ -> (fails,red)
|
||||
updatebuttontext = plType . putButton . btText .~ "ANALYSER"
|
||||
|
||||
testYourHealth :: Int -> Machine -> World -> World
|
||||
testYourHealth hp mc w
|
||||
|
||||
Reference in New Issue
Block a user