Tweak ammo distribution

This commit is contained in:
2025-12-09 23:51:33 +00:00
parent f6e0514408
commit eac80d2b43
2 changed files with 11 additions and 6 deletions
+10 -5
View File
@@ -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 =