From eac80d2b439e6562449438145879b97ec992b568 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 9 Dec 2025 23:51:33 +0000 Subject: [PATCH] Tweak ammo distribution --- src/Dodge/Room/Room.hs | 2 +- src/Dodge/WorldEffect.hs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Dodge/Room/Room.hs b/src/Dodge/Room/Room.hs index 12f793026..d710fe006 100644 --- a/src/Dodge/Room/Room.hs +++ b/src/Dodge/Room/Room.hs @@ -447,7 +447,7 @@ distributerRoom atype aamount = do & rmInPmnt <>~ [(0,dst),(1,thepipe)] tmDistributeLines :: [TerminalLine] -tmDistributeLines = [TLine 1 [TerminalLineConst "DISTRIBUTING AMMO" white] TmDistributeAmmo] +tmDistributeLines = [TLine 1 [TerminalLineConst "DISTRIBUTING..." white] TmDistributeAmmo] -- cor <- shuffleLinks corridor -- return $ tToBTree "corDoor" $ treePost [door,cor,cleatOnward door] diff --git a/src/Dodge/WorldEffect.hs b/src/Dodge/WorldEffect.hs index 867a28003..c0fe40979 100644 --- a/src/Dodge/WorldEffect.hs +++ b/src/Dodge/WorldEffect.hs @@ -6,6 +6,7 @@ module Dodge.WorldEffect ( doTmWdWd, ) where +import ShortShow import Data.Traversable (mapAccumR) import Dodge.Item.MagAmmoType import qualified Data.IntSet as IS @@ -123,10 +124,14 @@ tmDistributeAmmo tm w = fromMaybe w $ do return $ w' & cWorld . lWorld . machines . ix sid . mcType . mcsAmount .~ x' & cWorld . lWorld . terminals . ix (tm ^. tmID) . tmFutureLines .~ - [TLine 1 [TerminalLineConst (show x' <>" "<>show atype<>" REMAINING IN STORAGE") white] TmWdId - ,TLine 1 [TerminalLineConst "" yellow] (TmTmSetStatus (TerminalPressTo "RETRY")) + [TLine 1 [TerminalLineConst (g (aamount - x')) white] TmWdId + ,TLine 1 [TerminalLineConst (shortShow x' <>" "<>show atype<>" AVAILABLE") white] TmWdId + ,TLine 1 [TerminalLineConst "" yellow] (TmTmSetStatus (TerminalPressTo "")) ,TLine 1 [TerminalLineConst "" white] TmWdWdPowerDownTerminal ] + where + g 0 = "NO SUITABLE RECIPIENTS" + g _ = "SUCCESFUL" distributeAmmoToYou :: AmmoType -> Int -> World -> (Int,World) distributeAmmoToYou atype x w = fromMaybe (0,w) $ do @@ -136,9 +141,9 @@ distributeAmmoToYou atype x w = fromMaybe (0,w) $ do (x',itmams) = mapAccumR distributeAmmoToItem x itms return (x', IM.foldlWithKey' f w itmams) where + f w' _ 0 = w' f w' i y = w' & cWorld . highlightItems . at i ?~ 20 - & cWorld . lWorld . items . ix i . itConsumables . _Just .~ y - + & cWorld . lWorld . items . ix i . itConsumables . _Just +~ y distributeAmmoToItem :: Int -> Item -> (Int,Int) distributeAmmoToItem x itm = fromMaybe (x,0) $ do @@ -146,7 +151,7 @@ distributeAmmoToItem x itm = fromMaybe (x,0) $ do cur <- itm ^. itConsumables let d = m - cur t = min x d - return (x-t,cur+t) + return (x-t,t) resetTerminal :: TerminalStatus -> Terminal -> World -> World resetTerminal x tm =