Work on airlocks

This commit is contained in:
2025-08-23 17:42:36 +01:00
parent f641805845
commit 32d7120177
19 changed files with 380 additions and 334 deletions
+14 -7
View File
@@ -16,6 +16,7 @@ module Dodge.Terminal (
tlDoEffect,
) where
import Dodge.Item.Display
import Color
import Data.Char
import qualified Data.List as List
@@ -59,11 +60,12 @@ getCommand :: World
getCommand w tm = \case
TCInfo x z -> PTE.singleton x (PTE.singleton "" (makeTermPara z))
TCBase -> quitCommand <> toggleCommands tm
TCDamageCommand -> damageCodeCommand w
TCDamageCommand -> damageCodeCommand w tm
TCSensorInfo -> sensorCommand w tm
damageCodeCommand :: World -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
damageCodeCommand w = PTE.singleton "DAMAGECODE" $ PTE.fromList $ mapMaybe f [minBound ..]
damageCodeCommand :: World -> Terminal -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
damageCodeCommand w tm
= PTE.singleton "DAMAGECODE" $ PTE.fromList $ mapMaybe f [minBound ..]
where
f :: SensorType -> Maybe (String, [TerminalLine])
f st = do
@@ -82,12 +84,17 @@ decodeSensorType st w = fromMaybe [] $ do
-- ugly
sensorCommand :: World -> Terminal -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
sensorCommand w tm = PTE.singleton "SENSOR" $ fromMaybe mempty $ do
ProximitySensor _ d r b <- w ^? cWorld . lWorld . machines . ix (tm ^. tmMachineID) . mcType . _McSensor
ProximitySensor _ _ r b <- w ^? cWorld . lWorld . machines . ix (tm ^. tmMachineID) . mcType . _McSensor
return $ PTE.fromList
[ ("REQUIREMENT", [makeTermLine $ show r] )
, ("RADIUS", [makeTermLine $ show d])
, ("STATUS", [makeTermLine $ show b])
[ ("", makeTermPara $ sensorReqToString r b)
]
sensorReqToString :: ProximityRequirement -> Bool -> String
sensorReqToString pr = \case
True -> "SENSOR TEST PASSED."
False -> "SENSOR REQUIRES: " ++ case pr of
RequireHealth x -> "HEALTH ABOVE " ++ show x
RequireEquipment x -> itemBaseName x
toggleCommands :: Terminal -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])