Tweak ammo distribution
This commit is contained in:
@@ -447,7 +447,7 @@ distributerRoom atype aamount = do
|
|||||||
& rmInPmnt <>~ [(0,dst),(1,thepipe)]
|
& rmInPmnt <>~ [(0,dst),(1,thepipe)]
|
||||||
|
|
||||||
tmDistributeLines :: [TerminalLine]
|
tmDistributeLines :: [TerminalLine]
|
||||||
tmDistributeLines = [TLine 1 [TerminalLineConst "DISTRIBUTING AMMO" white] TmDistributeAmmo]
|
tmDistributeLines = [TLine 1 [TerminalLineConst "DISTRIBUTING..." white] TmDistributeAmmo]
|
||||||
|
|
||||||
-- cor <- shuffleLinks corridor
|
-- cor <- shuffleLinks corridor
|
||||||
-- return $ tToBTree "corDoor" $ treePost [door,cor,cleatOnward door]
|
-- return $ tToBTree "corDoor" $ treePost [door,cor,cleatOnward door]
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ module Dodge.WorldEffect (
|
|||||||
doTmWdWd,
|
doTmWdWd,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import ShortShow
|
||||||
import Data.Traversable (mapAccumR)
|
import Data.Traversable (mapAccumR)
|
||||||
import Dodge.Item.MagAmmoType
|
import Dodge.Item.MagAmmoType
|
||||||
import qualified Data.IntSet as IS
|
import qualified Data.IntSet as IS
|
||||||
@@ -123,10 +124,14 @@ tmDistributeAmmo tm w = fromMaybe w $ do
|
|||||||
return $ w'
|
return $ w'
|
||||||
& cWorld . lWorld . machines . ix sid . mcType . mcsAmount .~ x'
|
& cWorld . lWorld . machines . ix sid . mcType . mcsAmount .~ x'
|
||||||
& cWorld . lWorld . terminals . ix (tm ^. tmID) . tmFutureLines .~
|
& cWorld . lWorld . terminals . ix (tm ^. tmID) . tmFutureLines .~
|
||||||
[TLine 1 [TerminalLineConst (show x' <>" "<>show atype<>" REMAINING IN STORAGE") white] TmWdId
|
[TLine 1 [TerminalLineConst (g (aamount - x')) white] TmWdId
|
||||||
,TLine 1 [TerminalLineConst "" yellow] (TmTmSetStatus (TerminalPressTo "RETRY"))
|
,TLine 1 [TerminalLineConst (shortShow x' <>" "<>show atype<>" AVAILABLE") white] TmWdId
|
||||||
|
,TLine 1 [TerminalLineConst "" yellow] (TmTmSetStatus (TerminalPressTo ""))
|
||||||
,TLine 1 [TerminalLineConst "" white] TmWdWdPowerDownTerminal
|
,TLine 1 [TerminalLineConst "" white] TmWdWdPowerDownTerminal
|
||||||
]
|
]
|
||||||
|
where
|
||||||
|
g 0 = "NO SUITABLE RECIPIENTS"
|
||||||
|
g _ = "SUCCESFUL"
|
||||||
|
|
||||||
distributeAmmoToYou :: AmmoType -> Int -> World -> (Int,World)
|
distributeAmmoToYou :: AmmoType -> Int -> World -> (Int,World)
|
||||||
distributeAmmoToYou atype x w = fromMaybe (0,w) $ do
|
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
|
(x',itmams) = mapAccumR distributeAmmoToItem x itms
|
||||||
return (x', IM.foldlWithKey' f w itmams)
|
return (x', IM.foldlWithKey' f w itmams)
|
||||||
where
|
where
|
||||||
|
f w' _ 0 = w'
|
||||||
f w' i y = w' & cWorld . highlightItems . at i ?~ 20
|
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 :: Int -> Item -> (Int,Int)
|
||||||
distributeAmmoToItem x itm = fromMaybe (x,0) $ do
|
distributeAmmoToItem x itm = fromMaybe (x,0) $ do
|
||||||
@@ -146,7 +151,7 @@ distributeAmmoToItem x itm = fromMaybe (x,0) $ do
|
|||||||
cur <- itm ^. itConsumables
|
cur <- itm ^. itConsumables
|
||||||
let d = m - cur
|
let d = m - cur
|
||||||
t = min x d
|
t = min x d
|
||||||
return (x-t,cur+t)
|
return (x-t,t)
|
||||||
|
|
||||||
resetTerminal :: TerminalStatus -> Terminal -> World -> World
|
resetTerminal :: TerminalStatus -> Terminal -> World -> World
|
||||||
resetTerminal x tm =
|
resetTerminal x tm =
|
||||||
|
|||||||
Reference in New Issue
Block a user