Continue work on terminals
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Dodge.WorldEffect (
|
||||
doWdWd,
|
||||
accessTerminal,
|
||||
@@ -99,6 +100,9 @@ doTmWdWd tmwdwd = case tmwdwd of
|
||||
tid <- tm ^? tmID
|
||||
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
|
||||
@@ -124,3 +128,12 @@ 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
|
||||
"REQUIREMENT" -> maybe [] f $ w ^? cWorld . lWorld . machines . ix (tm ^. tmMachineID) . mcType . _McSensor . proxRequirement
|
||||
"DISTANCE" -> maybe [] f $ w ^? cWorld . lWorld . machines . ix (tm ^. tmMachineID) . mcType . _McSensor . proxDist
|
||||
"STATUS" -> maybe [] f $ w ^? cWorld . lWorld . machines . ix (tm ^. tmMachineID) . mcType . _McSensor . sensToggle
|
||||
_ -> []
|
||||
where
|
||||
f s = [makeTermLine $ show s]
|
||||
|
||||
Reference in New Issue
Block a user