Tweaks
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Dodge.Item.MagAmmoType (
|
||||
magAmmoType,
|
||||
magMax,
|
||||
) where
|
||||
module Dodge.Item.MagAmmoType (magAmmoType) where
|
||||
|
||||
import Control.Lens
|
||||
import Dodge.Data.AmmoType
|
||||
@@ -25,6 +22,3 @@ mAT = \case
|
||||
SHELLMAG -> LauncherAmmo
|
||||
BATTERY -> ElectricalAmmo
|
||||
CHEMFUELPOUCH -> GasAmmo
|
||||
|
||||
magMax :: Item -> Maybe Int
|
||||
magMax _ = Just 100
|
||||
|
||||
@@ -436,13 +436,16 @@ loadAmmoTut = do
|
||||
. addDoorAtNthLinkToggleInterrupt 0 ["DOOR LOCKDOWN ACTIVE"] j
|
||||
=<< shuffleLinks
|
||||
=<< roomRectAutoLights 100 100
|
||||
droom <- distributerRoom BulletAmmo (10 ^ (8::Int))
|
||||
return $
|
||||
tToBTree "loadAmmoTest" $
|
||||
treeFromPost
|
||||
treePost
|
||||
[amrm & rmPmnts .:~ sps (PS 50 0) (PutFlIt (drumMag & itConsumables ?~ 90))
|
||||
, triggerDoorRoom i
|
||||
, wprm & rmPmnts .:~ sps (PS 50 0) (PutFlIt burstRifle)
|
||||
] (triggerDoorRoom j)
|
||||
, triggerDoorRoom j
|
||||
, droom
|
||||
]
|
||||
|
||||
putSingleLight :: Room -> State LayoutVars Room
|
||||
putSingleLight rm = do
|
||||
|
||||
@@ -6,6 +6,7 @@ module Dodge.WorldEffect (
|
||||
doTmWdWd,
|
||||
) where
|
||||
|
||||
import Dodge.Item.MaxAmmo
|
||||
import ShortShow
|
||||
import Data.Traversable (mapAccumR)
|
||||
import Dodge.Item.MagAmmoType
|
||||
@@ -148,7 +149,7 @@ distributeAmmoToYou atype x w = fromMaybe (0,w) $ do
|
||||
|
||||
distributeAmmoToItem :: Int -> Item -> (Int,Int)
|
||||
distributeAmmoToItem x itm = fromMaybe (x,0) $ do
|
||||
m <- magMax itm
|
||||
m <- maxAmmo itm
|
||||
cur <- itm ^. itConsumables
|
||||
let d = m - cur
|
||||
t = max 0 $ min x d
|
||||
|
||||
+8
-6
@@ -27,6 +27,7 @@ module TreeHelp (
|
||||
safeUpdateSingleNode,
|
||||
numTraversable,
|
||||
treeAttachDeep,
|
||||
subtree,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
@@ -49,12 +50,7 @@ treePost xs = treeFromPost (init xs) (last xs)
|
||||
{- | Creates a tree with one trunk branch,
|
||||
input as a list, that ends in another tree.
|
||||
-}
|
||||
treeFromTrunk ::
|
||||
-- | The trunk
|
||||
[a] ->
|
||||
-- | The end of the tree
|
||||
Tree a ->
|
||||
Tree a
|
||||
treeFromTrunk :: [a] -> Tree a -> Tree a
|
||||
treeFromTrunk = flip $ foldr f
|
||||
where
|
||||
f x t = Node x [t]
|
||||
@@ -72,6 +68,12 @@ applyToSubtree :: [Int] -> (Tree a -> Tree a) -> Tree a -> Tree a
|
||||
applyToSubtree [] f t = f t
|
||||
applyToSubtree (i : is) f (Node x xs) = Node x (xs & ix i %~ applyToSubtree is f)
|
||||
|
||||
-- the following is probably better, but hasn't been checked
|
||||
subtree :: (Applicative g,Foldable f) => f Int -> (Tree b -> g (Tree b)) -> Tree b -> g (Tree b)
|
||||
subtree = foldr f id
|
||||
where
|
||||
f i g = (branches . ix i) . g
|
||||
|
||||
{- | Applies a function to a specific subforest determined by a list of indices.
|
||||
Partial.
|
||||
-}
|
||||
|
||||
Reference in New Issue
Block a user