Commit before extending selection sections: overlapping elements
This commit is contained in:
+2
-21
@@ -9,7 +9,7 @@ import Dodge.Data.Item.Use.Consumption.LoadAction
|
||||
import Control.Lens
|
||||
import Dodge.Data.Creature
|
||||
import Data.Maybe
|
||||
import qualified IntMapHelp as IM
|
||||
--import qualified IntMapHelp as IM
|
||||
|
||||
crCancelReloading :: Creature -> Creature
|
||||
crCancelReloading cr =
|
||||
@@ -53,26 +53,7 @@ tryStartLoading cr = fromMaybe cr $ do
|
||||
as <- cr ^? crInv . ix i . itUse . heldConsumption . laSource
|
||||
case as of
|
||||
InternalSource ia -> return $ startLoading ia cr
|
||||
ExternalSource ea -> return $ toggleExternalLoadSource i ea cr
|
||||
|
||||
toggleExternalLoadSource :: Int -> Maybe Int -> Creature -> Creature
|
||||
toggleExternalLoadSource invid mcureqid cr = fromMaybe cr $ do
|
||||
st <- inv ^? ix invid . itUse . heldConsumption . laSourceType
|
||||
(eqid,eqitm) <- ifind (\_ a -> Just st == a ^? itUse . equipEffect . eeUse . euseAmmoSourceType) msplit
|
||||
return $ cr
|
||||
& crInv . ix invid . itUse . heldConsumption . laSource . _ExternalSource ?~ eqid
|
||||
& crInv . ix eqid . itUse . equipEffect . eeUse . euseAmmoLink ?~ invid
|
||||
& detachExternalSource eqitm
|
||||
where
|
||||
inv = cr ^. crInv
|
||||
msplit = fromMaybe inv $ do
|
||||
cureqid <- mcureqid
|
||||
return . snd $ IM.split cureqid inv
|
||||
|
||||
detachExternalSource :: Item -> Creature -> Creature
|
||||
detachExternalSource itm cr = fromMaybe cr $ do
|
||||
i <- itm ^? itUse . equipEffect . eeUse . euseAmmoLink . _Just
|
||||
return $ cr & crInv . ix i . itUse . heldConsumption . laSource . _ExternalSource .~ Nothing
|
||||
AboveSource -> return cr
|
||||
|
||||
startLoading :: InternalAmmo -> Creature -> Creature
|
||||
startLoading ic cr = case ic ^? iaProgress . _Just . ix 0 of
|
||||
|
||||
Reference in New Issue
Block a user