diff --git a/src/Dodge/Combine/Combinations.hs b/src/Dodge/Combine/Combinations.hs index e09b7dea8..88950a4d7 100644 --- a/src/Dodge/Combine/Combinations.hs +++ b/src/Dodge/Combine/Combinations.hs @@ -1,6 +1,9 @@ {-# LANGUAGE TupleSections #-} -module Dodge.Combine.Combinations where +module Dodge.Combine.Combinations + ( itemCombinations + , bulletWeapons + ) where import Dodge.Data.Item import Dodge.Item @@ -8,7 +11,10 @@ import LensHelp watchCombinations :: [([(ItAmount, ItemBaseType)], Item)] watchCombinations = - [ po [LEFT STOPWATCH, LEFT REWINDWATCH] scrollWatch] + [ po [LEFT STOPWATCH, LEFT REWINDWATCH] scrollWatch + , po [CRAFT TIMEMODULE, CRAFT MICROCHIP, CRAFT HARDDRIVE] scrollWatch + , po [CRAFT TIMEMODULE, CRAFT MICROCHIP, CRAFT RAM] scrollWatch + ] where po xs it = (map o xs, it) o = (1,) diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index 50572f762..7e4822407 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -190,7 +190,10 @@ inventoryX c = case c of 'H' -> [shatterGun] 'I' -> [ makeTypeCraft TELEPORTMODULE + , makeTypeCraftNum 2 TIMEMODULE , makeTypeCraftNum 2 MICROCHIP + , makeTypeCraft HARDDRIVE + , makeTypeCraft RAM ] 'J' -> [ lasGun diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index dcc7fd9e9..70b56a719 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -30,7 +30,7 @@ useItem cr' w = fromMaybe (f w) $ do itemEffect :: Creature -> Item -> World -> World itemEffect cr it w = case it ^. itUse of HeldUse{_heldUse = eff, _heldMods = usemods} -> - hammerTest $ tryReload cr it w $ foldl' (&) (useHeld eff) (useMod usemods) it cr + hammerTest $ tryReload cr it (_input w) $ foldl' (&) (useHeld eff) (useMod usemods) it cr --hammerTest $ tryReload cr it w $ foldl' (&) (useHeld eff) (reverse $ useMod usemods) it cr LeftUse{} -> doequipmentchange EquipUse{} -> doequipmentchange @@ -49,13 +49,15 @@ itemEffect cr it w = case it ^. itUse of . activateEquipmentAt (_rbOptions w) cr ) -tryReload :: Creature -> Item -> World -> (World -> World) -> World -> World -tryReload cr it w f - | _crID cr == 0 && itNeedsLoading it && _mouseButtons (_input w) M.!? SDL.ButtonLeft == Just False = - crToggleReloading cr +tryReload :: Creature -> Item -> Input -> (World -> World) -> World -> World +tryReload cr it theinput f + | cid == 0 && itNeedsLoading it && _mouseButtons theinput M.!? SDL.ButtonLeft == Just False = + cWorld . lWorld . creatures . ix cid %~ crToggleReloading | otherwise = (runIdentity . pointerToItemLocation (_itLocation it) (return . (itUse . heldHammer .~ HammerDown))) . f + where + cid = _crID cr itNeedsLoading :: Item -> Bool itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic) diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index 89b36dbe8..54b11c785 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -3,6 +3,7 @@ module Dodge.Creature.State ( doDamage, ) where +import Data.Maybe import Dodge.Creature.Test import Data.Foldable import Dodge.Base @@ -64,13 +65,12 @@ stateUpdate f = ] heldAimEffects :: Creature -> World -> World -heldAimEffects cr - | crIsAiming cr = case cr ^? crInv . ix (cr ^. crInvSel . iselPos) of - Just itm -> case itm ^? itEffect . ieWhileAiming of - Just f -> doInvEffect f itm cr - _ -> id - _ -> id - | otherwise = id +heldAimEffects cr = fromMaybe id $ do + guard (crIsAiming cr) + ipos <- cr ^? crInvSel . iselPos + itm <- cr ^? crInv . ix ipos + f <- itm ^? itEffect . ieWhileAiming + return $ doInvEffect f itm cr checkDeath :: Creature -> World -> World checkDeath cr w diff --git a/src/Dodge/Data/Item/Combine.hs b/src/Dodge/Data/Item/Combine.hs index 259f2e1e4..989315ef0 100644 --- a/src/Dodge/Data/Item/Combine.hs +++ b/src/Dodge/Data/Item/Combine.hs @@ -46,6 +46,8 @@ data CraftType | PLATE | TRANSMITTER | MICROCHIP + | HARDDRIVE + | RAM | AIUNIT | CAMERA | MINIDISPLAY -- visual display unit @@ -102,7 +104,9 @@ data EquipItemType | POWERLEGS | SPEEDLEGS | JUMPLEGS + | JETPACK + | AUTODETECTOR Detector deriving (Eq,Ord,Show,Read) --deriving (Eq, Ord, 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 1885806c2..be0b6e38d 100644 --- a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs +++ b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs @@ -18,7 +18,9 @@ data LoadAction | LoadPrime {_actionTime :: Int, _actionSound :: SoundID} deriving (Eq, Ord, Show, Read) --Generic, Flat) -data InvSel = InvSel {_iselPos :: Int, _iselAction :: InvSelAction} +data InvSel + = InvSel {_iselPos :: Int, _iselAction :: InvSelAction} + | Brute deriving (Eq, Ord, Show, Read) --Generic, Flat) data InvSelAction diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index 0e61e8b0b..77ecebc80 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -25,6 +25,7 @@ module Dodge.Inventory ( invDimColor, ) where +import Dodge.Reloading import Color import Dodge.Inventory.Color import qualified Data.Map.Strict as M @@ -52,11 +53,11 @@ rmInvItem :: World -> World rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount of - Just x | x > 1 -> w & pointcid . crInv . ix invid . itUse . useAmount %~ subtract 1 + Just x | x > 1 -> w & pointcid . crInv . ix invid . itUse . useAmount -~ 1 _ -> w & pointcid . crInv %~ f - & pointcid . crInvSel %~ stopCrInvSelAction + & pointcid %~ crCancelReloading & pointcid . crInvSel . iselPos %~ g & pointcid . crLeftInvSel . lisMPos %~ g' & removeAnySlotEquipment @@ -70,9 +71,6 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount getcid = cWorld . lWorld . creatures . ix cid pointcid = cWorld . lWorld . creatures . ix cid - stopCrInvSelAction (InvSel i a) - | i == invid = InvSel i NoInvSelAction - | otherwise = InvSel i a cr = w ^?! cWorld . lWorld . creatures . ix cid itm = _crInv cr IM.! invid dounequipfunction = fromMaybe id $ do diff --git a/src/Dodge/Item/Display.hs b/src/Dodge/Item/Display.hs index 5643413df..78482b80d 100644 --- a/src/Dodge/Item/Display.hs +++ b/src/Dodge/Item/Display.hs @@ -65,8 +65,8 @@ showAutoRechargeProgress lc = case lc of ChargeableAmmo{} -> show (_wpCharge lc) showReloadProgress :: Creature -> HeldConsumption -> String -showReloadProgress cr ic = case cr ^?! crInvSel . iselAction of - ReloadAction i la _ -> show i ++ showLoadActionType la (_laLoaded ic) +showReloadProgress cr ic = case cr ^? crInvSel . iselAction of + Just (ReloadAction i la _) -> show i ++ showLoadActionType la (_laLoaded ic) _ -> case ic ^? laProgress . _Just . ix 0 of Nothing -> show $ _laLoaded ic Just la -> show (_actionTime la) ++ showLoadActionType la (_laLoaded ic) diff --git a/src/Dodge/Reloading.hs b/src/Dodge/Reloading.hs index 64b796c8d..c0a8ff67f 100644 --- a/src/Dodge/Reloading.hs +++ b/src/Dodge/Reloading.hs @@ -1,13 +1,12 @@ module Dodge.Reloading ( crCancelReloading, crToggleReloading, - crHoldReloading, stepReloading, tryStartLoading, ) where import Control.Lens -import Dodge.Data.World +import Dodge.Data.Creature import Dodge.Hammer crCancelReloading :: Creature -> Creature @@ -38,15 +37,10 @@ tryNextLoadAction cr = case cr ^? crInv . ix (crSel cr) . itUse . heldConsumptio cr & crInvSel . iselAction . actionProgress .~ _actionTime la & crInvSel . iselAction . reloadAction .~ la -crToggleReloading :: Creature -> World -> World -crToggleReloading cr w = case cr ^. crInvSel . iselAction of - ReloadAction{} -> w & cWorld . lWorld . creatures . ix (_crID cr) . crInvSel . iselAction .~ NoInvSelAction - _ -> w & cWorld . lWorld . creatures . ix (_crID cr) %~ tryStartLoading - -crHoldReloading :: Creature -> World -> World -crHoldReloading cr w = - w - & cWorld . lWorld . creatures . ix (_crID cr) . crInvSel . iselAction . actionHammer .~ HasHammer HammerDown +crToggleReloading :: Creature -> Creature +crToggleReloading cr = case cr ^? crInvSel . iselAction of + Just ReloadAction{} -> cr & crInvSel . iselAction .~ NoInvSelAction + _ -> cr & tryStartLoading tryStartLoading :: Creature -> Creature tryStartLoading cr = case cr ^? crInv . ix (crSel cr) . itUse . heldConsumption of diff --git a/src/Dodge/Update/Input.hs b/src/Dodge/Update/Input.hs index f8dc129b3..2ec47e1ee 100644 --- a/src/Dodge/Update/Input.hs +++ b/src/Dodge/Update/Input.hs @@ -75,13 +75,11 @@ updateKeyInGame uv sc InitialPress = case sc of ScancodeP -> pauseGame uv ScancodeF -> over uvWorld youDropItem uv ScancodeM -> over uvWorld toggleMap uv - ScancodeR -> over uvWorld (crToggleReloading (you w)) uv + ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crToggleReloading uv ScancodeT -> over uvWorld testEvent uv ScancodeX -> uv & uvWorld %~ toggleTweakInv ScancodeC -> over uvWorld toggleCombineInv uv _ -> uv - where - w = _uvWorld uv updateKeyInGame uv _ _ = uv pauseGame :: Universe -> Universe diff --git a/src/Dodge/Update/Scroll.hs b/src/Dodge/Update/Scroll.hs index 50e545f6f..9bfaf37d9 100644 --- a/src/Dodge/Update/Scroll.hs +++ b/src/Dodge/Update/Scroll.hs @@ -94,7 +94,7 @@ terminalWheelEvent yi tmid w scrollRBOption :: Int -> World -> World scrollRBOption y w - | y < 0 = w & rbOptions . opSel %~ (min (length (_opEquip (_rbOptions w)) -1) . (+ y)) + | y < 0 = w & rbOptions . opSel %~ (min (length (_opEquip (_rbOptions w)) -1) . subtract y) | y > 0 = w & rbOptions . opSel %~ (max 0 . subtract y) | otherwise = w