Modify analyser sounds

This commit is contained in:
2022-03-22 18:42:48 +00:00
parent 7b842bca4f
commit 72a1399da0
10 changed files with 176 additions and 160 deletions
+4 -5
View File
@@ -61,7 +61,7 @@ analyser' starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \t
TerminalParams
{ _termDisplayedLines = []
, _termFutureLines =
map simpleline topflush
map simpleline (topFlushStrings allstrings)
++ map simpleline starts
++ [testline' (_mcID mc)]
++ map simpleline afters
@@ -72,7 +72,6 @@ analyser' starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \t
(\mc -> upf mc . (triggers . ix (fromJust $ _plMID tp) .~ const (_sensToggle $ _mcSensor mc))
)
allstrings = sucs : fails : afters ++ starts
topflush = [replicate i ' ' ++ "*" | i <- [0,3 .. maximum (map length allstrings)]]
simpleline str = TerminalLineDisplay {_tlPause = 0, _tlString = const (str,white)}
testline' mcid = TerminalLineDisplay 0 (testline mcid)
testline mcid w = case w ^? machines . ix mcid . mcSensor . sensToggle of
@@ -124,9 +123,9 @@ analyserTest t mc w = case
(_,True,_,_) -> w
(_,False,True,True) -> w
& machines . ix (_mcID mc) . mcSensor . sensToggle .~ True
& playsound dededaS
& playsound dedaS
& machines . ix (_mcID mc) . mcSensor . sensCloseToggle .~ IsClose
(NotClose,_,False,True) -> w & playsound dededumS
(NotClose,_,False,True) -> w & playsound dedumS
& machines . ix (_mcID mc) . mcSensor . sensCloseToggle .~ IsClose
(_,_,_,False) -> w & machines . ix (_mcID mc) . mcSensor . sensCloseToggle .~ NotClose
_ -> w
@@ -136,7 +135,7 @@ analyserTest t mc w = case
sens = _mcSensor mc
testYouHave :: CombineType -> Machine -> World -> World
testYouHave ct = analyserTest (\w -> any (\itm -> _itType itm == ct) (_crInv (you w)))
testYouHave ct = analyserTest (any (\itm -> _itType itm == ct) . _crInv . you )
testYourHealth :: Int -> Machine -> World -> World
testYourHealth hp = analyserTest (\w -> _crHP (you w) >= hp)
+9 -4
View File
@@ -4,6 +4,7 @@ module Dodge.Placement.Instance.Terminal
, putTerminal'
, simpleTermMessage
, genTermMessage
, topFlushStrings
) where
import Dodge.Data
import Dodge.LevelGen.Data
@@ -86,27 +87,31 @@ simpleTermMessage :: [String] -> (GenParams -> TerminalParams)
simpleTermMessage ss = const $ TerminalParams
{_termDisplayedLines = []
,_termFutureLines = TerminalLineEffect 0 termsound
: map totermline (topflush ++ ss)
: map totermline (topFlushStrings ss ++ ss)
,_termMaxLines = 7
,_termTitle = "TERMINAL"
}
where
topflush = [replicate i ' ' ++ "*" | i <- [0,2 .. maximum (map length ss)]]
totermline s = TerminalLineDisplay 0 (const (s,white))
termsound subinv w' = soundStart TerminalSound tpos computerBeepingS Nothing w'
where
tpos = fromMaybe 0 $ w' ^? buttons . ix (_termID subinv) . btPos
topFlushStrings :: [String] -> [String]
topFlushStrings = topFlush . maximum . map length
topFlush :: Int -> [String]
topFlush twidth = [replicate i ' ' ++ "*" | i <- [0, max 1 $ twidth `div` 5 .. twidth]]
genTermMessage :: (GenParams -> [String]) -> (GenParams -> TerminalParams)
genTermMessage f = \gp -> TerminalParams
{_termDisplayedLines = []
,_termFutureLines = termSoundLine computerBeepingS
: map totermline (topflush (f gp) ++ f gp)
: map totermline (topFlushStrings (f gp) ++ f gp)
,_termMaxLines = 7
,_termTitle = "TERMINAL"
}
where
topflush ss = [replicate i ' ' ++ "*" | i <- [0,2 .. maximum (map length ss)]]
totermline s = TerminalLineDisplay 0 (const (s,white))
termSoundLine :: SoundID -> TerminalLine