diff --git a/ghcidOutput b/ghcidOutput index d583047a3..79ccba416 100644 --- a/ghcidOutput +++ b/ghcidOutput @@ -1 +1,86 @@ -All good (615 modules, at 22:22:36) +/home/justin/Haskell/loop/src/Dodge/Creature/State.hs:26:1-22: warning: [-Wunused-imports] + The import of ‘Dodge.Reloading’ is redundant + | +26 | import Dodge.Reloading + | ^^^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Creature/Impulse/UseItem.hs:20:1-22: warning: [-Wunused-imports] + The import of ‘Dodge.Reloading’ is redundant + | +20 | import Dodge.Reloading + | ^^^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Creature/Impulse/UseItem.hs:118:5-14: warning: [-Wunused-local-binds] + Defined but not used: ‘hammerTest’ + | +118 | hammerTest f = case _crHammerPosition cr of + | ^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Creature/Impulse/UseItem.hs:121:5-15: warning: [-Wunused-local-binds] + Defined but not used: ‘setuhamdown’ + | +121 | setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown + | ^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Inventory.hs:28:1-22: warning: [-Wunused-imports] + The import of ‘Dodge.Reloading’ is redundant + | +28 | import Dodge.Reloading + | ^^^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Item/Ammo.hs:7:1-29: warning: [-Wunused-imports] + The import of ‘Dodge.Reloading.Action’ is redundant + | +7 | import Dodge.Reloading.Action + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Reloading/Action.hs:3:1-49: warning: [-Wunused-imports] + The import of ‘Dodge.Data.Item.Use.Consumption.LoadAction’ is redundant + | +3 | import Dodge.Data.Item.Use.Consumption.LoadAction + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Reloading/Action.hs:4:1-49: warning: [-Wunused-imports] + The import of ‘Dodge.SoundLogic.ExternallyGeneratedSounds’ is redundant + | +4 | import Dodge.SoundLogic.ExternallyGeneratedSounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/CreatureEffect.hs:(50,13)-(54,28): warning: [-Wincomplete-patterns] + Pattern match(es) are non-exhaustive + In a case alternative: Patterns not matched: CrIsReloading + | +50 | doCrBl cb = case cb of + | ^^^^^^^^^^... +/home/justin/Haskell/loop/src/Dodge/Creature/Statistics.hs:8:1-26: warning: [-Wunused-imports] + The import of ‘Dodge.Creature.Test’ is redundant + | +8 | import Dodge.Creature.Test + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Item/Weapon/TriggerType.hs:72:1-22: warning: [-Wunused-imports] + The import of ‘Dodge.Reloading’ is redundant + | +72 | import Dodge.Reloading + | ^^^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Projectile/Create.hs:4:1-22: warning: [-Wunused-imports] + The import of ‘Dodge.Reloading’ is redundant + | +4 | import Dodge.Reloading + | ^^^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Reloading.hs:7:1-19: warning: [-Wunused-imports] + The import of ‘Control.Lens’ is redundant + | +7 | import Control.Lens + | ^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Reloading.hs:8:1-17: warning: [-Wunused-imports] + The import of ‘Data.Maybe’ is redundant + | +8 | import Data.Maybe + | ^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Reloading.hs:9:1-26: warning: [-Wunused-imports] + The import of ‘Dodge.Data.Creature’ is redundant + | +9 | import Dodge.Data.Creature + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Reloading.hs:10:1-20: warning: [-Wunused-imports] + The import of ‘Control.Monad’ is redundant + | +10 | import Control.Monad + | ^^^^^^^^^^^^^^^^^^^^ +/home/justin/Haskell/loop/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs:11:1-17: warning: [-Wunused-imports] + The import of ‘Sound.Data’ is redundant + | +11 | import Sound.Data + | ^^^^^^^^^^^^^^^^^ diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index 002e67b4f..b56ed1324 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -106,11 +106,13 @@ useItemLeftClick cr w = fromMaybe w $ do invid <- cr ^? crManipulation . manObject . inInventory . ispItem ituse <- cr ^? crInv . ix invid . itUse case ituse of - HeldUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crReloadToggle) + --HeldUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crReloadToggle) + HeldUse{} -> return w ConsumeUse{} -> return $ useItemRightClick cr w EquipUse{} -> return $ useItemRightClick cr w LeftUse{} -> return $ useItemRightClick cr w - AmmoMagUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crReloadToggle) + AmmoMagUse{} -> return w + --AmmoMagUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crReloadToggle) _ -> Nothing where hammerTest f = case _crHammerPosition cr of diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index c85a9aaad..8a71cdb3b 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -145,7 +145,7 @@ internalHammerUpdate :: Creature -> World -> World internalHammerUpdate cr = cWorld . lWorld . creatures . ix (_crID cr) %~ ( (crHammerPosition %~ moveHammerUp) - . stepReloading +-- . stepReloading . updateMovement ) @@ -233,7 +233,7 @@ equipmentEffects cr = flip (foldl' $ flip $ useEquipment cr) (IM.keys $ _crInvEq invSideEff :: Creature -> World -> World invSideEff cr w = updateTargeting (crGetTargeting cr) cr $ - weaponReloadSounds cr $ +-- weaponReloadSounds cr $ IM.foldl' f w (_crInv cr) where -- be careful with side effects that affect creature targeting @@ -288,18 +288,18 @@ crGetTargeting cr = do guard (canAttachTargeting tt itm) return tt -weaponReloadSounds :: Creature -> World -> World -weaponReloadSounds cr w = case cr ^? crManipulation . manObject . inInventory . iselAction of - Just ReloadAction{_reloadAction = la} -> - soundContinue - (CrReloadSound cid) - (_crPos cr) - (_actionSound la) - (Just 1) - w - _ -> w - where - cid = _crID cr +--weaponReloadSounds :: Creature -> World -> World +--weaponReloadSounds cr w = case cr ^? crManipulation . manObject . inInventory . iselAction of +-- Just ReloadAction{_reloadAction = la} -> +-- soundContinue +-- (CrReloadSound cid) +-- (_crPos cr) +-- (_actionSound la) +-- (Just 1) +-- w +-- _ -> w +-- where +-- cid = _crID cr updateMovement :: Creature -> Creature updateMovement cr diff --git a/src/Dodge/Creature/Statistics.hs b/src/Dodge/Creature/Statistics.hs index ea3544592..c76f241d6 100644 --- a/src/Dodge/Creature/Statistics.hs +++ b/src/Dodge/Creature/Statistics.hs @@ -36,7 +36,8 @@ crCurrentEquipment cr = strFromHeldItem :: Creature -> Int strFromHeldItem cr - | _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do +--x--- | _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do + | _posture (_crStance cr) == Aiming = negate $ fromMaybe 0 $ do i <- cr ^? crManipulation . manObject . inInventory . ispItem cr ^? crInv . ix i . itUse . heldAim . aimWeight | otherwise = 0 diff --git a/src/Dodge/Creature/Test.hs b/src/Dodge/Creature/Test.hs index bdd17283a..fb3212f40 100644 --- a/src/Dodge/Creature/Test.hs +++ b/src/Dodge/Creature/Test.hs @@ -7,7 +7,7 @@ in fact a creature with that id need not exist. -} module Dodge.Creature.Test ( crIsAiming, - crIsReloading, +-- crIsReloading, crIsArmouredFrom, oneH, twists, @@ -33,10 +33,10 @@ import Dodge.Base.Collide import Dodge.Data.World import Geometry -crIsReloading :: Creature -> Bool -crIsReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAction of - Just ReloadAction{} -> True - _ -> False +--crIsReloading :: Creature -> Bool +--crIsReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAction of +-- Just ReloadAction{} -> True +-- _ -> False -- Assumes the ammotype below the selected item is correct crWeaponReady :: Creature -> Bool diff --git a/src/Dodge/CreatureEffect.hs b/src/Dodge/CreatureEffect.hs index 0e7aa4250..d612d82b5 100644 --- a/src/Dodge/CreatureEffect.hs +++ b/src/Dodge/CreatureEffect.hs @@ -49,7 +49,7 @@ doWdCrBl wcb = case wcb of doCrBl :: CrBl -> Creature -> Bool doCrBl cb = case cb of CrCanShoot -> crCanShoot - CrIsReloading -> crIsReloading +-- CrIsReloading -> crIsReloading CrIsAiming -> crIsAiming CrIsAnimate -> isAnimate diff --git a/src/Dodge/Data/Item/Use/Consumption.hs b/src/Dodge/Data/Item/Use/Consumption.hs index 118e39d7a..dd0a4a8f5 100644 --- a/src/Dodge/Data/Item/Use/Consumption.hs +++ b/src/Dodge/Data/Item/Use/Consumption.hs @@ -20,9 +20,7 @@ import Dodge.Data.Item.Use.Consumption.LoadAction data ReloadStatus = ReloadStatus { _iaMax :: Int , _iaLoaded :: Int - , _iaPrimed :: Bool - , _iaCycle :: [LoadAction] - , _iaProgress :: Maybe [LoadAction] + -- , _iaPrimed :: Bool } deriving (Eq, Show, Read) --Generic, Flat) diff --git a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs index c679b881c..abf8e5c67 100644 --- a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs +++ b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs @@ -10,13 +10,6 @@ import Data.Aeson import Data.Aeson.TH import Sound.Data -data LoadAction - = LoadEject {_actionTime :: Int, _actionSound :: SoundID} - | LoadInsert {_actionTime :: Int, _actionSound :: SoundID} - | LoadAdd {_actionTime :: Int, _actionSound :: SoundID, _insertMax :: Int} - | LoadPrime {_actionTime :: Int, _actionSound :: SoundID} - deriving (Eq, Ord, Show, Read) --Generic, Flat) - data Manipulation -- should be ManipulatedObject? -- = InvSel {_isel :: SelPos} = Manipulator {_manObject :: ManipulatedObject @@ -42,16 +35,13 @@ data InventoryManipulation data InvSelAction = NoInvSelAction - | ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction, _reloadInvID :: Int} deriving (Eq, Ord, Show, Read) --Generic, Flat) -makeLenses ''LoadAction makeLenses ''ManipulatedObject makeLenses ''Manipulation makeLenses ''InventoryManipulation makeLenses ''NearbyManipulation makeLenses ''InvSelAction -deriveJSON defaultOptions ''LoadAction deriveJSON defaultOptions ''InvSelAction deriveJSON defaultOptions ''InventoryManipulation deriveJSON defaultOptions ''NearbyManipulation diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index 971807d55..dbe821f65 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -50,7 +50,7 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount & worldEventFlags . at InventoryChange ?~ () _ -> w - & pointcid %~ crCancelReloading +-- & pointcid %~ crCancelReloading & doanyitemeffect & dounequipfunction --the ordering of these is & pointcid . crInv %~ f -- important diff --git a/src/Dodge/Item/Ammo.hs b/src/Dodge/Item/Ammo.hs index 8fc2e35f5..9ec94bc2a 100644 --- a/src/Dodge/Item/Ammo.hs +++ b/src/Dodge/Item/Ammo.hs @@ -19,9 +19,6 @@ tinMag = ReloadStatus { _iaMax = 15 , _iaLoaded = 15 - , _iaPrimed = True - , _iaCycle = [loadEject 10, loadInsert 10, loadPrime 10] - , _iaProgress = Nothing } } @@ -31,7 +28,6 @@ revolveMag = & itType . iyBase .~ AMMOMAG REVOLVEMAG & itUse . amagLoadStatus . iaMax .~ 6 & itUse . amagLoadStatus . iaLoaded .~ 6 - & itUse . amagLoadStatus . iaCycle .~ [loadPartialInsert 10 1] drumMag :: Item drumMag = @@ -59,9 +55,6 @@ shellMag = ReloadStatus { _iaMax = 1 , _iaLoaded = 1 - , _iaPrimed = True - , _iaCycle = [loadEject 10, loadInsert 10, loadPrime 10] - , _iaProgress = Nothing } , _amagType = ProjectileAmmo } @@ -77,8 +70,5 @@ battery = ReloadStatus { _iaMax = 100 , _iaLoaded = 100 - , _iaPrimed = True - , _iaCycle = [loadEject 10, loadInsert 10, loadPrime 10] - , _iaProgress = Nothing } } diff --git a/src/Dodge/Item/Display.hs b/src/Dodge/Item/Display.hs index 67b77907d..be0cf0568 100644 --- a/src/Dodge/Item/Display.hs +++ b/src/Dodge/Item/Display.hs @@ -123,8 +123,8 @@ itemNumberDisplay cr itm = case iu of EquipUse{} -> showEquipmentNumber cr itm CraftUse x -> [show $ x ^. getItAmount] ConsumeUse {_useAmount = x} -> [show $ x ^. getItAmount] - AttachUse {} -> [showReloadProgress cr itm] - AmmoMagUse {} -> [showReloadProgress cr itm] + AttachUse {} -> [] --[showReloadProgress cr itm] + AmmoMagUse {} -> [showLoadedAmount itm] -- this could be cleaner here... where iu = itm ^?! itUse @@ -152,12 +152,15 @@ showEquipmentNumber _ itm = case _eeUse ee of -- ) -- <|> Just [x] -showReloadProgress :: Creature -> Item -> String -showReloadProgress _ itm = fromMaybe [] $ do - ia <- itm ^? itUse . amagLoadStatus - return $ case ia ^? iaProgress . _Just . ix 0 of - Nothing -> maybe "" show $ ia ^? iaLoaded - Just la -> showLoadActionType la ia +showLoadedAmount :: Item -> String +showLoadedAmount itm = fromMaybe [] $ fmap show $ itm ^? itUse . amagLoadStatus . iaLoaded + +--showReloadProgress :: Creature -> Item -> String +--showReloadProgress _ itm = fromMaybe [] $ do +-- ia <- itm ^? itUse . amagLoadStatus +-- return $ case ia ^? iaProgress . _Just . ix 0 of +-- Nothing -> maybe "" show $ ia ^? iaLoaded +-- Just la -> showLoadActionType la ia --showReloadProgress :: Creature -> Item -> String --showReloadProgress cr itm = case ic ^? laSource of -- Just (InternalSource ia) -> case ia ^? iaProgress . _Just . ix 0 of @@ -171,14 +174,14 @@ showReloadProgress _ itm = fromMaybe [] $ do -- where -- ic = itm ^?! itUse . heldConsumption -showLoadActionType :: LoadAction -> ReloadStatus -> String -showLoadActionType la as = case la of - LoadEject{} -> "E" - LoadInsert{} -> "L" - LoadAdd{} -> "A" ++ x - LoadPrime{} -> "P" - where - x = maybe "" show $ as ^? iaLoaded +--showLoadActionType :: LoadAction -> ReloadStatus -> String +--showLoadActionType la as = case la of +-- LoadEject{} -> "E" +-- LoadInsert{} -> "L" +-- LoadAdd{} -> "A" ++ x +-- LoadPrime{} -> "P" +-- where +-- x = maybe "" show $ as ^? iaLoaded maybeWarmupStatus :: Item -> Maybe String maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of diff --git a/src/Dodge/Item/Weapon/TriggerType.hs b/src/Dodge/Item/Weapon/TriggerType.hs index a23704c3a..78f1a22ce 100644 --- a/src/Dodge/Item/Weapon/TriggerType.hs +++ b/src/Dodge/Item/Weapon/TriggerType.hs @@ -148,7 +148,7 @@ ammoCheckI eff ams itm cr w = fromMaybe (failsound w) $ do matype <- ams ^? ix 0 . itUse . amagType iatype <- itm ^? itUse . heldConsumption . ix 0 guard $ matype == iatype - return $ eff ams itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading + return $ eff ams itm cr $ w -- & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading where failsound = case w ^? input . mouseButtons . ix SDL.ButtonLeft of Just 0 -> soundStart (CrReloadSound (_crID cr)) (_crPos cr) click1S Nothing diff --git a/src/Dodge/Projectile/Create.hs b/src/Dodge/Projectile/Create.hs index 478fb474b..c2daaf4a5 100644 --- a/src/Dodge/Projectile/Create.hs +++ b/src/Dodge/Projectile/Create.hs @@ -22,10 +22,11 @@ createProjectile ammoitem muz itm cr = fromMaybe failsound $ do CreateShell -> fireShell ammoitem muz itm cr . extrafuncs j CreateTrackingShell -> fireTrackingShell ammoitem muz itm cr . extrafuncs j where - extrafuncs j = cancelanyreloading . startthesound . useammo j + --extrafuncs j = cancelanyreloading . startthesound . useammo j + extrafuncs j = startthesound . useammo j useammo j = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix j . itUse . amagLoadStatus . iaLoaded -~ 1 - cancelanyreloading = cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading + --cancelanyreloading = cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading -- the sound should be moved to the projectile firing startthesound = soundMultiFrom [CrWeaponSound (_crID cr) j | j <- [0..3]] (_crPos cr) tap4S Nothing failsound w' = case w' ^? input . mouseButtons . ix SDL.ButtonLeft of diff --git a/src/Dodge/Reloading.hs b/src/Dodge/Reloading.hs index a56b8ee83..abd5dbbfc 100644 --- a/src/Dodge/Reloading.hs +++ b/src/Dodge/Reloading.hs @@ -1,7 +1,7 @@ module Dodge.Reloading ( - crCancelReloading, - crReloadToggle, - stepReloading, +-- crCancelReloading, +-- crReloadToggle, +-- stepReloading, ) where import Control.Lens @@ -10,108 +10,108 @@ import Dodge.Data.Creature import Control.Monad --import Data.Monoid -crCancelReloading :: Creature -> Creature -crCancelReloading cr = - cr - & updateProgress - & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction - where - updateProgress = fromMaybe id $ do - InInventory (SelItem i _) <- cr ^? crManipulation . manObject - return $ - crInv . ix (i + 1) . itUse . amagLoadStatus . iaProgress - %~ const Nothing - -stepReloading :: Creature -> Creature -stepReloading cr = case cr ^? crManipulation . manObject . inInventory of - Just (SelItem _ (ReloadAction x la j)) - | x > 0 -> - cr & crManipulation . manObject . inInventory . iselAction . actionProgress -~ 1 - | otherwise -> - cr - & crInv . ix j . itUse . amagLoadStatus %~ doLoadAction la - & crInv . ix j . itUse . amagLoadStatus %~ rotateActionProgress - & tryNextLoadAction - _ -> cr - -tryNextLoadAction :: Creature -> Creature -tryNextLoadAction cr = case cr ^? crManipulation . manObject . inInventory of - Just (SelItem i _) -> case cr ^? crInv . ix (i + 1) . itUse . amagLoadStatus . iaProgress . _Just . ix 0 of - Nothing -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction - Just la -> - cr & crManipulation . manObject . inInventory . iselAction . actionProgress .~ _actionTime la - & crManipulation . manObject . inInventory . iselAction . reloadAction .~ la - _ -> cr - -crReloadToggle :: Creature -> Creature -crReloadToggle cr = case cr ^? crManipulation . manObject . inInventory . iselAction of - Just NoInvSelAction -> cr & tryStartLoading - _ -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction - -tryStartLoading :: Creature -> Creature -tryStartLoading cr = fromMaybe cr $ do - i <- cr ^? crManipulation . manObject . inInventory . ispItem - magtypes <- cr ^? crInv . ix i . itUse . heldConsumption - --let mags = cr ^.. crInv . dropping (i + 1) traverse -- note this gets all items below the manipulated - let mags = cr ^.. crInv . dropping i traverse - iaj <- listToMaybe . catMaybes $ zipWith tryStartLoadMagazine mags magtypes - return $ startLoading iaj cr - -tryStartLoadMagazine :: Item -> AmmoType -> Maybe (ReloadStatus, Int) -tryStartLoadMagazine mag atype = do - magat <- mag ^? itUse . amagType - guard $ magat == atype - ia <- mag ^? itUse . amagLoadStatus - maxammo <- ia ^? iaMax - loadedammo <- ia ^? iaLoaded - guard $ loadedammo < maxammo - j <- mag ^? itLocation . ipInvID - return (ia, j) - --- case as of --- InternalSource ia -> return $ startLoading ia cr --- AboveSource -> return cr - -startLoading :: (ReloadStatus,Int) -> Creature -> Creature -startLoading (ic,j) cr = case ic ^? iaProgress . _Just . ix 0 of - Just la -> cr & startLoadingStep la j - Nothing -> case ic ^. iaCycle of - [] -> error "item has empty load cycle" - _ | _iaLoaded ic >= _iaMax ic -> cr -- THIS SHOULD TRY PUSHING TO THE NEXT MAGAZINE - (la : las) -> fromMaybe (error "item loading error") $ do - i <- cr ^? crManipulation . manObject . inInventory . ispItem - return $ - cr & startLoadingStep la i - & crInv . ix i . itUse . amagLoadStatus . iaProgress ?~ (la : las) - -startLoadingStep :: LoadAction - -> Int -- i think this is the inventory position? - -> Creature -> Creature -startLoadingStep la j cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la j - -rotateActionProgress :: ReloadStatus -> ReloadStatus -rotateActionProgress ic = case ic ^. iaProgress of - Just (_ : la : las) -> ic & iaProgress . _Just .~ (la : las) - _ | _iaLoaded ic < _iaMax ic -> ic & iaProgress ?~ _iaCycle ic - _ -> ic & iaProgress .~ Nothing - -doLoadAction :: LoadAction -> ReloadStatus -> ReloadStatus -doLoadAction la ic = case la of - LoadEject{} -> ic & iaLoaded .~ 0 & iaPrimed .~ False - LoadInsert{} -> ic & iaLoaded .~ _iaMax ic - LoadAdd{_insertMax = x} -> - ic & iaLoaded +~ min x (_iaMax ic - _iaLoaded ic) - LoadPrime{} -> ic & iaPrimed .~ True - ---{- | Start reloading if clip is empty. -} ---crAutoReload :: Creature -> Creature ---crAutoReload cr = case cr ^? ptrItConsumption' . ammoLoaded of --- Just 0 | _posture (_crStance cr) /= Aiming --- -> cr & ptrItConsumption . reloadState .~ strictify reloadT --- & ptrItConsumption . ammoLoaded %~ (`fromMaybe` maxA) --- _ -> cr +----crCancelReloading :: Creature -> Creature +--crCancelReloading cr = +-- cr +-- & updateProgress +-- & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction -- where --- ptrItConsumption = crInv . ix (_crInvSel cr) . itConsumption --- ptrItConsumption' = crInv . ix (_crInvSel cr) . itConsumption --- reloadT = cr ^? ptrItConsumption' . reloadTime --- maxA = fmap itMaxAmmo $ cr ^? crInv . ix (_crInvSel cr) +-- updateProgress = fromMaybe id $ do +-- InInventory (SelItem i _) <- cr ^? crManipulation . manObject +-- return $ +-- crInv . ix (i + 1) . itUse . amagLoadStatus . iaProgress +-- %~ const Nothing +-- +--stepReloading :: Creature -> Creature +--stepReloading cr = case cr ^? crManipulation . manObject . inInventory of +-- Just (SelItem _ (ReloadAction x la j)) +-- | x > 0 -> +-- cr & crManipulation . manObject . inInventory . iselAction . actionProgress -~ 1 +-- | otherwise -> +-- cr +-- & crInv . ix j . itUse . amagLoadStatus %~ doLoadAction la +-- & crInv . ix j . itUse . amagLoadStatus %~ rotateActionProgress +-- & tryNextLoadAction +-- _ -> cr +-- +--tryNextLoadAction :: Creature -> Creature +--tryNextLoadAction cr = case cr ^? crManipulation . manObject . inInventory of +-- Just (SelItem i _) -> case cr ^? crInv . ix (i + 1) . itUse . amagLoadStatus . iaProgress . _Just . ix 0 of +-- Nothing -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction +-- Just la -> +-- cr & crManipulation . manObject . inInventory . iselAction . actionProgress .~ _actionTime la +-- & crManipulation . manObject . inInventory . iselAction . reloadAction .~ la +-- _ -> cr +-- +--crReloadToggle :: Creature -> Creature +--crReloadToggle cr = case cr ^? crManipulation . manObject . inInventory . iselAction of +-- Just NoInvSelAction -> cr & tryStartLoading +-- _ -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction +-- +--tryStartLoading :: Creature -> Creature +--tryStartLoading cr = fromMaybe cr $ do +-- i <- cr ^? crManipulation . manObject . inInventory . ispItem +-- magtypes <- cr ^? crInv . ix i . itUse . heldConsumption +-- --let mags = cr ^.. crInv . dropping (i + 1) traverse -- note this gets all items below the manipulated +-- let mags = cr ^.. crInv . dropping i traverse +-- iaj <- listToMaybe . catMaybes $ zipWith tryStartLoadMagazine mags magtypes +-- return $ startLoading iaj cr +-- +--tryStartLoadMagazine :: Item -> AmmoType -> Maybe (ReloadStatus, Int) +--tryStartLoadMagazine mag atype = do +-- magat <- mag ^? itUse . amagType +-- guard $ magat == atype +-- ia <- mag ^? itUse . amagLoadStatus +-- maxammo <- ia ^? iaMax +-- loadedammo <- ia ^? iaLoaded +-- guard $ loadedammo < maxammo +-- j <- mag ^? itLocation . ipInvID +-- return (ia, j) +-- +---- case as of +---- InternalSource ia -> return $ startLoading ia cr +---- AboveSource -> return cr +-- +--startLoading :: (ReloadStatus,Int) -> Creature -> Creature +--startLoading (ic,j) cr = case ic ^? iaProgress . _Just . ix 0 of +-- Just la -> cr & startLoadingStep la j +-- Nothing -> case ic ^. iaCycle of +-- [] -> error "item has empty load cycle" +-- _ | _iaLoaded ic >= _iaMax ic -> cr -- THIS SHOULD TRY PUSHING TO THE NEXT MAGAZINE +-- (la : las) -> fromMaybe (error "item loading error") $ do +-- i <- cr ^? crManipulation . manObject . inInventory . ispItem +-- return $ +-- cr & startLoadingStep la i +-- & crInv . ix i . itUse . amagLoadStatus . iaProgress ?~ (la : las) +-- +--startLoadingStep :: LoadAction +-- -> Int -- i think this is the inventory position? +-- -> Creature -> Creature +--startLoadingStep la j cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la j +-- +--rotateActionProgress :: ReloadStatus -> ReloadStatus +--rotateActionProgress ic = case ic ^. iaProgress of +-- Just (_ : la : las) -> ic & iaProgress . _Just .~ (la : las) +-- _ | _iaLoaded ic < _iaMax ic -> ic & iaProgress ?~ _iaCycle ic +-- _ -> ic & iaProgress .~ Nothing +-- +--doLoadAction :: LoadAction -> ReloadStatus -> ReloadStatus +--doLoadAction la ic = case la of +-- LoadEject{} -> ic & iaLoaded .~ 0 & iaPrimed .~ False +-- LoadInsert{} -> ic & iaLoaded .~ _iaMax ic +-- LoadAdd{_insertMax = x} -> +-- ic & iaLoaded +~ min x (_iaMax ic - _iaLoaded ic) +-- LoadPrime{} -> ic & iaPrimed .~ True +-- +----{- | Start reloading if clip is empty. -} +----crAutoReload :: Creature -> Creature +----crAutoReload cr = case cr ^? ptrItConsumption' . ammoLoaded of +---- Just 0 | _posture (_crStance cr) /= Aiming +---- -> cr & ptrItConsumption . reloadState .~ strictify reloadT +---- & ptrItConsumption . ammoLoaded %~ (`fromMaybe` maxA) +---- _ -> cr +---- where +---- ptrItConsumption = crInv . ix (_crInvSel cr) . itConsumption +---- ptrItConsumption' = crInv . ix (_crInvSel cr) . itConsumption +---- reloadT = cr ^? ptrItConsumption' . reloadTime +---- maxA = fmap itMaxAmmo $ cr ^? crInv . ix (_crInvSel cr) diff --git a/src/Dodge/Reloading/Action.hs b/src/Dodge/Reloading/Action.hs index 55ea91141..9a5f9e76f 100644 --- a/src/Dodge/Reloading/Action.hs +++ b/src/Dodge/Reloading/Action.hs @@ -3,14 +3,14 @@ module Dodge.Reloading.Action where import Dodge.Data.Item.Use.Consumption.LoadAction import Dodge.SoundLogic.ExternallyGeneratedSounds -loadInsert :: Int -> LoadAction -loadInsert x = LoadInsert x insertS - -loadPartialInsert :: Int -> Int -> LoadAction -loadPartialInsert x = LoadAdd x insertOneS - -loadEject :: Int -> LoadAction -loadEject x = LoadEject x ejectS - -loadPrime :: Int -> LoadAction -loadPrime x = LoadPrime x primeS +--loadInsert :: Int -> LoadAction +--loadInsert x = LoadInsert x insertS +-- +--loadPartialInsert :: Int -> Int -> LoadAction +--loadPartialInsert x = LoadAdd x insertOneS +-- +--loadEject :: Int -> LoadAction +--loadEject x = LoadEject x ejectS +-- +--loadPrime :: Int -> LoadAction +--loadPrime x = LoadPrime x primeS diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index d331f02da..2c65c5c40 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -19,7 +19,6 @@ import Dodge.InputFocus import Dodge.Inventory import Dodge.Inventory.Add import Dodge.Menu -import Dodge.Reloading import Dodge.Save import Dodge.SelectionSections import Dodge.Terminal.LeftButton @@ -116,7 +115,7 @@ updateInitialPressInGame uv sc = case sc of ScancodeP -> pauseGame uv ScancodeF -> over uvWorld youDropItem uv ScancodeM -> toggleMap uv - ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crReloadToggle uv +-- ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crReloadToggle uv ScancodeT -> over uvWorld testEvent uv ScancodeX -> uv & uvWorld %~ toggleTweakInv ScancodeC -> toggleCombineInv uv