Commit before implementing positional inventory
This commit is contained in:
@@ -262,4 +262,6 @@ stackedInventory =
|
|||||||
, flameThrower
|
, flameThrower
|
||||||
, poisonSprayer
|
, poisonSprayer
|
||||||
, launcher
|
, launcher
|
||||||
|
, bulletBeltPack
|
||||||
|
, bulletBeltBracer
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,18 +10,15 @@ import Dodge.Hotkey
|
|||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
import qualified Data.Map.Strict as M
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Cuse
|
import Dodge.Cuse
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
import Dodge.Euse
|
import Dodge.Euse
|
||||||
import Dodge.HeldUse
|
import Dodge.HeldUse
|
||||||
import Dodge.Inventory
|
import Dodge.Inventory
|
||||||
import Dodge.Item.Location
|
|
||||||
import Dodge.Luse
|
import Dodge.Luse
|
||||||
import Dodge.Reloading
|
import Dodge.Reloading
|
||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
import qualified SDL
|
|
||||||
|
|
||||||
useItemRightClick :: Creature -> World -> World
|
useItemRightClick :: Creature -> World -> World
|
||||||
useItemRightClick cr' w = fromMaybe (f w) $ do
|
useItemRightClick cr' w = fromMaybe (f w) $ do
|
||||||
@@ -37,7 +34,6 @@ useItemRightClick cr' w = fromMaybe (f w) $ do
|
|||||||
itemEffect :: Creature -> Item -> World -> World
|
itemEffect :: Creature -> Item -> World -> World
|
||||||
itemEffect cr it w = case it ^. itUse of
|
itemEffect cr it w = case it ^. itUse of
|
||||||
HeldUse{_heldUse = eff, _heldMods = usemods} ->
|
HeldUse{_heldUse = eff, _heldMods = usemods} ->
|
||||||
--hammerTest $ tryReload cr it (_input w) $ foldl' (&) (useHeld eff) (useMod usemods) it cr
|
|
||||||
hammerTest $ foldl' (&) (useHeld eff) (useMod usemods) it cr
|
hammerTest $ foldl' (&) (useHeld eff) (useMod usemods) it cr
|
||||||
LeftUse{} -> doequipmentchange
|
LeftUse{} -> doequipmentchange
|
||||||
EquipUse{} -> doequipmentchange
|
EquipUse{} -> doequipmentchange
|
||||||
@@ -56,21 +52,6 @@ itemEffect cr it w = case it ^. itUse of
|
|||||||
( toggleEquipmentAt itRef cr
|
( toggleEquipmentAt itRef cr
|
||||||
)
|
)
|
||||||
|
|
||||||
tryReload :: Creature -> Item -> Input -> (World -> World) -> World -> World
|
|
||||||
tryReload cr it theinput f
|
|
||||||
| cid == 0 && itNeedsLoading it && _mouseButtons theinput M.!? SDL.ButtonLeft == Just 0 =
|
|
||||||
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 = fromMaybe False $ do
|
|
||||||
internalammo <- it ^? itUse . heldConsumption . laSource . _InternalSource
|
|
||||||
return $ _iaLoaded internalammo == 0 || not (_iaPrimed internalammo)
|
|
||||||
|
|
||||||
toggleEquipmentAt :: Int -> Creature -> World -> World
|
toggleEquipmentAt :: Int -> Creature -> World -> World
|
||||||
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||||
DoNotMoveEquipment -> w
|
DoNotMoveEquipment -> w
|
||||||
@@ -120,14 +101,14 @@ useItemLeftClick cr w = fromMaybe w $ do
|
|||||||
invid <- cr ^? crManipulation . manObject . inInventory . ispItem
|
invid <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
ituse <- cr ^? crInv . ix invid . itUse
|
ituse <- cr ^? crInv . ix invid . itUse
|
||||||
case ituse of
|
case ituse of
|
||||||
HeldUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crToggleReloading)
|
HeldUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crUpdateLoadSource)
|
||||||
ConsumeUse{} -> return $ useItemRightClick cr w
|
ConsumeUse{} -> return $ useItemRightClick cr w
|
||||||
EquipUse{} -> return $ useItemRightClick cr w
|
EquipUse{} -> return $ useItemRightClick cr w
|
||||||
LeftUse{} -> return $ useItemRightClick cr w
|
LeftUse{} -> return $ useItemRightClick cr w
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
where
|
where
|
||||||
hammerTest f = case _crHammerPosition cr of
|
hammerTest f = case _crHammerPosition cr of
|
||||||
HammerUp -> f w
|
HammerUp -> f w & setuhamdown
|
||||||
_ -> w & setuhamdown
|
_ -> w & setuhamdown
|
||||||
setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ data EquipItemType
|
|||||||
| JETPACK
|
| JETPACK
|
||||||
| FUELPACK
|
| FUELPACK
|
||||||
| BULLETBELTPACK
|
| BULLETBELTPACK
|
||||||
|
| BULLETBELTBRACER
|
||||||
| BATTERYPACK
|
| BATTERYPACK
|
||||||
|
|
||||||
| AUTODETECTOR Detector
|
| AUTODETECTOR Detector
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ data InventoryManipulation
|
|||||||
|
|
||||||
data InvSelAction
|
data InvSelAction
|
||||||
= NoInvSelAction
|
= NoInvSelAction
|
||||||
|
| AttachLoadSourceAction {_actionProgress :: Int}
|
||||||
| ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction}
|
| ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction}
|
||||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ itemFromEquipType et = case et of
|
|||||||
BATTERYPACK -> batteryPack
|
BATTERYPACK -> batteryPack
|
||||||
FUELPACK -> fuelPack
|
FUELPACK -> fuelPack
|
||||||
BULLETBELTPACK -> bulletBeltPack
|
BULLETBELTPACK -> bulletBeltPack
|
||||||
|
BULLETBELTBRACER -> bulletBeltBracer
|
||||||
AUTODETECTOR d -> autoDetector d
|
AUTODETECTOR d -> autoDetector d
|
||||||
|
|
||||||
itemFromLeftType :: LeftItemType -> Item
|
itemFromLeftType :: LeftItemType -> Item
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ module Dodge.Item.Display (
|
|||||||
itemBaseName,
|
itemBaseName,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Dodge.Item.Info
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Sequence
|
import Data.Sequence
|
||||||
import Dodge.Data.Creature
|
import Dodge.Data.Creature
|
||||||
@@ -55,7 +56,7 @@ showSelectedConsumption :: Creature -> ItemUse -> String
|
|||||||
showSelectedConsumption cr iu = case iu of
|
showSelectedConsumption cr iu = case iu of
|
||||||
HeldUse{} -> showReloadProgress cr (iu ^?! heldConsumption . laSource)
|
HeldUse{} -> showReloadProgress cr (iu ^?! heldConsumption . laSource)
|
||||||
LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu)
|
LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu)
|
||||||
EquipUse{} -> ""
|
EquipUse{_equipEffect = ee} -> showEquipmentNumber ee
|
||||||
_ -> show $ iu ^?! useAmount . getItAmount -- partial, be careful if adding new data constructors
|
_ -> show $ iu ^?! useAmount . getItAmount -- partial, be careful if adding new data constructors
|
||||||
|
|
||||||
showAutoRechargeProgress :: LeftConsumption -> String
|
showAutoRechargeProgress :: LeftConsumption -> String
|
||||||
@@ -72,26 +73,36 @@ showReloadProgress cr ic = case cr ^? crManipulation . manObject . inInventory .
|
|||||||
InternalSource ia -> case ia ^? iaProgress . _Just . ix 0 of
|
InternalSource ia -> case ia ^? iaProgress . _Just . ix 0 of
|
||||||
Nothing -> show $ ia ^. iaLoaded
|
Nothing -> show $ ia ^. iaLoaded
|
||||||
Just la -> show (_actionTime la) ++ showLoadActionType la ic
|
Just la -> show (_actionTime la) ++ showLoadActionType la ic
|
||||||
_ -> "X"
|
ExternalSource ea -> fromMaybe "X" $ do
|
||||||
|
i <- ea ^? _Just
|
||||||
|
itm <- cr ^? crInv . ix i
|
||||||
|
return $ show $ itemBaseName itm
|
||||||
|
|
||||||
showConsumption :: ItemUse -> String
|
showConsumption :: ItemUse -> String
|
||||||
showConsumption iu = case iu of
|
showConsumption iu = case iu of
|
||||||
HeldUse{} -> showReloadProgress' (_heldConsumption iu)
|
HeldUse{} -> showReloadProgress' (_heldConsumption iu)
|
||||||
LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu)
|
LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu)
|
||||||
EquipUse {_equipEffect = ee} -> showEUseNumber ee
|
EquipUse{_equipEffect = ee} -> showEquipmentNumber ee
|
||||||
_ -> show $ iu ^?! useAmount . getItAmount
|
_ -> show $ iu ^?! useAmount . getItAmount
|
||||||
|
|
||||||
showEUseNumber :: EquipEffect -> String
|
showEquipmentNumber :: EquipEffect -> String
|
||||||
showEUseNumber ee = case _eeUse ee of
|
showEquipmentNumber ee = case _eeUse ee of
|
||||||
EFuelSource x _ -> show x
|
EFuelSource x _ -> show x
|
||||||
|
EAmmoSource {_euseAmmoAmount = x} -> showIntKMG' x
|
||||||
|
EBatterySource {_euseBatteryAmount = x} -> show x
|
||||||
_ -> ""
|
_ -> ""
|
||||||
|
|
||||||
showReloadProgress' :: HeldConsumption -> String
|
showReloadProgress' :: HeldConsumption -> String
|
||||||
showReloadProgress' ic = case ic ^? laSource . _InternalSource . iaProgress . _Just . ix 0 of
|
showReloadProgress' ic = case ic ^? laSource of
|
||||||
Nothing -> fromMaybe "X" $ do
|
Just (InternalSource ia) -> case ia ^? iaProgress . _Just . ix 0 of
|
||||||
|
Nothing -> fromMaybe "" $ do
|
||||||
x <- ic ^? laSource . _InternalSource . iaLoaded
|
x <- ic ^? laSource . _InternalSource . iaLoaded
|
||||||
return $ show x
|
return $ show x
|
||||||
Just la -> show (_actionTime la) ++ showLoadActionType la (_laSource ic)
|
Just la -> show (_actionTime la) ++ showLoadActionType la (_laSource ic)
|
||||||
|
Just (ExternalSource ea) -> fromMaybe "X" $ do
|
||||||
|
i <- ea ^? _Just
|
||||||
|
return $ show i
|
||||||
|
_ -> ""
|
||||||
|
|
||||||
showLoadActionType :: LoadAction -> AmmoSource -> String
|
showLoadActionType :: LoadAction -> AmmoSource -> String
|
||||||
showLoadActionType la as = case la of
|
showLoadActionType la as = case la of
|
||||||
@@ -102,7 +113,6 @@ showLoadActionType la as = case la of
|
|||||||
where
|
where
|
||||||
x = maybe "" show $ as ^? _InternalSource . iaLoaded
|
x = maybe "" show $ as ^? _InternalSource . iaLoaded
|
||||||
|
|
||||||
|
|
||||||
maybeWarmupStatus :: Item -> Maybe String
|
maybeWarmupStatus :: Item -> Maybe String
|
||||||
maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of
|
maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of
|
||||||
Nothing -> Nothing
|
Nothing -> Nothing
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ equipItemSPic et _ = case et of
|
|||||||
noPic $ colorSH yellow $ upperPrismPolyMT 10 $ polyCirc 3 5
|
noPic $ colorSH yellow $ upperPrismPolyMT 10 $ polyCirc 3 5
|
||||||
BULLETBELTPACK ->
|
BULLETBELTPACK ->
|
||||||
noPic $ colorSH green backpackShape
|
noPic $ colorSH green backpackShape
|
||||||
|
BULLETBELTBRACER
|
||||||
|
-> noPic (colorSH green $ upperPrismPolySU 3 $ rectWH 2 2)
|
||||||
AUTODETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPolySU 3 $ rectWH 2 2)
|
AUTODETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPolySU 3 $ rectWH 2 2)
|
||||||
|
|
||||||
backpackShape :: Shape
|
backpackShape :: Shape
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ module Dodge.Item.Equipment (
|
|||||||
fuelPack,
|
fuelPack,
|
||||||
batteryPack,
|
batteryPack,
|
||||||
bulletBeltPack,
|
bulletBeltPack,
|
||||||
|
bulletBeltBracer,
|
||||||
speedLegs,
|
speedLegs,
|
||||||
jumpLegs,
|
jumpLegs,
|
||||||
flameShield,
|
flameShield,
|
||||||
@@ -76,7 +77,15 @@ bulletBeltPack =
|
|||||||
& itUse . equipEffect . eeSite .~ GoesOnBack
|
& itUse . equipEffect . eeSite .~ GoesOnBack
|
||||||
& itType . iyBase .~ EQUIP BULLETBELTPACK
|
& itType . iyBase .~ EQUIP BULLETBELTPACK
|
||||||
& itUse . equipEffect . eeAttachPos .~ V3 (-9) 0 10
|
& itUse . equipEffect . eeAttachPos .~ V3 (-9) 0 10
|
||||||
& itUse . equipEffect . eeUse .~ EAmmoSource 10000 10000 BulletSource Nothing
|
& itUse . equipEffect . eeUse .~ EAmmoSource 2000 2000 BulletSource Nothing
|
||||||
|
|
||||||
|
bulletBeltBracer :: Item
|
||||||
|
bulletBeltBracer =
|
||||||
|
defaultEquipment
|
||||||
|
& itUse . equipEffect . eeSite .~ GoesOnWrist
|
||||||
|
& itType . iyBase .~ EQUIP BULLETBELTBRACER
|
||||||
|
& itUse . equipEffect . eeAttachPos .~ V3 (-9) 0 10
|
||||||
|
& itUse . equipEffect . eeUse .~ EAmmoSource 100 100 BulletSource Nothing
|
||||||
|
|
||||||
jetPack :: Item
|
jetPack :: Item
|
||||||
jetPack =
|
jetPack =
|
||||||
|
|||||||
+31
-16
@@ -1,14 +1,15 @@
|
|||||||
module Dodge.Item.Info where
|
module Dodge.Item.Info where
|
||||||
|
|
||||||
import StringHelp
|
|
||||||
import Dodge.Module.Info
|
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import Dodge.Data.Item
|
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
|
import Dodge.Data.Item
|
||||||
|
import Dodge.Module.Info
|
||||||
import LensHelp
|
import LensHelp
|
||||||
|
import StringHelp
|
||||||
|
|
||||||
itemInfo :: Item -> String
|
itemInfo :: Item -> String
|
||||||
itemInfo itm = itmBaseInfo itm ++ " " ++ itmUsageInfo itm
|
itemInfo itm =
|
||||||
|
itmBaseInfo itm ++ " " ++ itmUsageInfo itm
|
||||||
++ itmSpaceInfo itm
|
++ itmSpaceInfo itm
|
||||||
++ itmModuleInfo (itm ^. itType . iyModules)
|
++ itmModuleInfo (itm ^. itType . iyModules)
|
||||||
|
|
||||||
@@ -43,6 +44,20 @@ showInt i = case i of
|
|||||||
12 -> "a dozen"
|
12 -> "a dozen"
|
||||||
_ -> "more than a dozen"
|
_ -> "more than a dozen"
|
||||||
|
|
||||||
|
showIntKMG :: Int -> String
|
||||||
|
showIntKMG x
|
||||||
|
| x < 1000 = show x
|
||||||
|
| x < 1000000 = show (x `div` 1000) ++ "K"
|
||||||
|
| x < 1000000000 = show (x `div` 1000000) ++ "M"
|
||||||
|
| otherwise = show (x `div` 1000000000) ++ "G"
|
||||||
|
|
||||||
|
showIntKMG' :: Int -> String
|
||||||
|
showIntKMG' x
|
||||||
|
| x < 1000 = show x
|
||||||
|
| x < 1000000 = take 3 (show ((fromIntegral x :: Float) / 1000)) ++ "K"
|
||||||
|
| x < 1000000000 = take 3 (show ((fromIntegral x :: Float) / 1000000)) ++ "M"
|
||||||
|
| otherwise = take 3 (show ((fromIntegral x :: Float) / 1000000000)) ++ "G"
|
||||||
|
|
||||||
heldInfo :: HeldItemType -> String
|
heldInfo :: HeldItemType -> String
|
||||||
heldInfo hit = case hit of
|
heldInfo hit = case hit of
|
||||||
BANGSTICK 1 -> "A firearm with a short barrel that requires reloading after each shot."
|
BANGSTICK 1 -> "A firearm with a short barrel that requires reloading after each shot."
|
||||||
@@ -119,12 +134,11 @@ equipInfo eit = case eit of
|
|||||||
POWERLEGS -> "Strength enhancing legs."
|
POWERLEGS -> "Strength enhancing legs."
|
||||||
SPEEDLEGS -> "Speed enhancing legs."
|
SPEEDLEGS -> "Speed enhancing legs."
|
||||||
JUMPLEGS -> "Jump enhancing legs."
|
JUMPLEGS -> "Jump enhancing legs."
|
||||||
|
|
||||||
JETPACK -> "A device enabling flight."
|
JETPACK -> "A device enabling flight."
|
||||||
FUELPACK -> "A liquid container with attached hose."
|
FUELPACK -> "A liquid container with attached hose."
|
||||||
BULLETBELTPACK -> "A container holding a long belt of bullets."
|
BULLETBELTPACK -> "A container holding a long belt of bullets."
|
||||||
|
BULLETBELTBRACER -> "A container holding a long belt of bullets."
|
||||||
BATTERYPACK -> "A collection of batteries with a universal adapter."
|
BATTERYPACK -> "A collection of batteries with a universal adapter."
|
||||||
|
|
||||||
AUTODETECTOR d -> "A device that detects " ++ detectorInfo d ++ " in an expanding radius. Pulses automatically. "
|
AUTODETECTOR d -> "A device that detects " ++ detectorInfo d ++ " in an expanding radius. Pulses automatically. "
|
||||||
|
|
||||||
targetingInfo :: TargetType -> String
|
targetingInfo :: TargetType -> String
|
||||||
@@ -146,10 +160,8 @@ craftInfo fit = case fit of
|
|||||||
TUBE -> "A wide rigid cylinder."
|
TUBE -> "A wide rigid cylinder."
|
||||||
HARDWARE -> "A collection of equipment and devices useful for general construction."
|
HARDWARE -> "A collection of equipment and devices useful for general construction."
|
||||||
SPRING -> "An object that exerts an opposing force when compressed or stretched."
|
SPRING -> "An object that exerts an opposing force when compressed or stretched."
|
||||||
|
|
||||||
HOSE -> "A flexible cylinder."
|
HOSE -> "A flexible cylinder."
|
||||||
TAPE -> "A strip of material with an adhesive side."
|
TAPE -> "A strip of material with an adhesive side."
|
||||||
|
|
||||||
CAN -> "A small metal cylindrical container."
|
CAN -> "A small metal cylindrical container."
|
||||||
TIN -> "A small metal continer."
|
TIN -> "A small metal continer."
|
||||||
STEELDRUM -> "A metal cylindrical container."
|
STEELDRUM -> "A metal cylindrical container."
|
||||||
@@ -193,13 +205,10 @@ craftInfo fit = case fit of
|
|||||||
TIMEMODULE -> "A device that can affect temporality."
|
TIMEMODULE -> "A device that can affect temporality."
|
||||||
SIZEMODULE -> "A device that can affect physical size."
|
SIZEMODULE -> "A device that can affect physical size."
|
||||||
GRAVITYMODULE -> "A device that can affect gravitational fields."
|
GRAVITYMODULE -> "A device that can affect gravitational fields."
|
||||||
|
|
||||||
TARGETMODULE _ -> "A targeting module."
|
TARGETMODULE _ -> "A targeting module."
|
||||||
|
|
||||||
FLAKCRAFT -> "Creates flak bullets."
|
FLAKCRAFT -> "Creates flak bullets."
|
||||||
FRAGCRAFT -> "Creates fragmentation bullets."
|
FRAGCRAFT -> "Creates fragmentation bullets."
|
||||||
|
|
||||||
|
|
||||||
detectorInfo :: Detector -> String
|
detectorInfo :: Detector -> String
|
||||||
detectorInfo d = case d of
|
detectorInfo d = case d of
|
||||||
ITEMDETECTOR -> "items"
|
ITEMDETECTOR -> "items"
|
||||||
@@ -209,7 +218,8 @@ detectorInfo d = case d of
|
|||||||
itmUsageInfo :: Item -> String
|
itmUsageInfo :: Item -> String
|
||||||
itmUsageInfo itm = case itm ^. itType . iyBase of
|
itmUsageInfo itm = case itm ^. itType . iyBase of
|
||||||
HELD _ -> heldPositionInfo itm
|
HELD _ -> heldPositionInfo itm
|
||||||
LEFT _ -> "This item can be equipped" ++ itmEquipSiteInfo itm
|
LEFT _ ->
|
||||||
|
"This item can be equipped" ++ itmEquipSiteInfo itm
|
||||||
++ ". When equipped, it can be activated."
|
++ ". When equipped, it can be activated."
|
||||||
EQUIP _ -> "This item can be equipped " ++ itmEquipSiteInfo itm ++ "."
|
EQUIP _ -> "This item can be equipped " ++ itmEquipSiteInfo itm ++ "."
|
||||||
Consumable _ -> "This item can be consumed."
|
Consumable _ -> "This item can be consumed."
|
||||||
@@ -224,6 +234,7 @@ aimStanceInfo as = case as of
|
|||||||
TwoHandTwist -> "It is held in two hands along its length."
|
TwoHandTwist -> "It is held in two hands along its length."
|
||||||
TwoHandFlat -> "It is held in two hands at its sides."
|
TwoHandFlat -> "It is held in two hands at its sides."
|
||||||
OneHand -> "It is held in one hand."
|
OneHand -> "It is held in one hand."
|
||||||
|
|
||||||
-- LeaveHolstered -> "It is to be left holstered."
|
-- LeaveHolstered -> "It is to be left holstered."
|
||||||
|
|
||||||
itmEquipSiteInfo :: Item -> String
|
itmEquipSiteInfo :: Item -> String
|
||||||
@@ -243,11 +254,15 @@ itmModuleInfo m
|
|||||||
| otherwise = mms ++ ems
|
| otherwise = mms ++ ems
|
||||||
where
|
where
|
||||||
(mademods, emptymods) = M.partition (/= EMPTYMODULE) m
|
(mademods, emptymods) = M.partition (/= EMPTYMODULE) m
|
||||||
mms | mademods == mempty = ""
|
mms
|
||||||
| otherwise = " Modifications have been made "
|
| mademods == mempty = ""
|
||||||
|
| otherwise =
|
||||||
|
" Modifications have been made "
|
||||||
++ makeCommaList (map moduleInfo $ M.keys mademods)
|
++ makeCommaList (map moduleInfo $ M.keys mademods)
|
||||||
ems | emptymods == mempty = ""
|
ems
|
||||||
| otherwise = " Modifications can be made "
|
| emptymods == mempty = ""
|
||||||
|
| otherwise =
|
||||||
|
" Modifications can be made "
|
||||||
++ makeCommaList (map moduleInfo $ M.keys emptymods)
|
++ makeCommaList (map moduleInfo $ M.keys emptymods)
|
||||||
|
|
||||||
makeCommaList :: [String] -> String
|
makeCommaList :: [String] -> String
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ import Geometry
|
|||||||
import LensHelp
|
import LensHelp
|
||||||
import RandomHelp
|
import RandomHelp
|
||||||
import Sound.Data
|
import Sound.Data
|
||||||
|
import qualified IntMapHelp as IM
|
||||||
|
|
||||||
type ChainEffect =
|
type ChainEffect =
|
||||||
(Item -> Creature -> World -> World) ->
|
(Item -> Creature -> World -> World) ->
|
||||||
@@ -361,9 +362,18 @@ useAmmoUpTo amAmount eff item cr =
|
|||||||
useAmmoAmount :: Int -> ChainEffect
|
useAmmoAmount :: Int -> ChainEffect
|
||||||
useAmmoAmount amAmount eff item cr =
|
useAmmoAmount amAmount eff item cr =
|
||||||
eff item cr
|
eff item cr
|
||||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laSource . _InternalSource . iaLoaded -~ amAmount)
|
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv %~ useAmmoAmount' itref amAmount) -- . _InternalSource . iaLoaded -~ amAmount)
|
||||||
where
|
where
|
||||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
itref = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
|
|
||||||
|
useAmmoAmount' :: Int -> Int -> IM.IntMap Item -> IM.IntMap Item
|
||||||
|
useAmmoAmount' itref x inv = case inv ^? ix itref . itUse . heldConsumption . laSource of
|
||||||
|
Just InternalSource{}
|
||||||
|
-> inv & ix itref . itUse . heldConsumption . laSource . _InternalSource . iaLoaded -~ x
|
||||||
|
Just (ExternalSource (Just eqid))
|
||||||
|
-> inv & ix eqid . itUse . equipEffect . eeUse . euseAmmoAmount -~ x
|
||||||
|
_ -> inv
|
||||||
|
-- . crInv . ix itRef . itUse . heldConsumption . laSource
|
||||||
|
|
||||||
{- |
|
{- |
|
||||||
Applies a world effect after an item use cooldown check.
|
Applies a world effect after an item use cooldown check.
|
||||||
|
|||||||
+29
-7
@@ -1,6 +1,6 @@
|
|||||||
module Dodge.Reloading (
|
module Dodge.Reloading (
|
||||||
crCancelReloading,
|
crCancelReloading,
|
||||||
crToggleReloading,
|
crUpdateLoadSource,
|
||||||
stepReloading,
|
stepReloading,
|
||||||
tryStartLoading,
|
tryStartLoading,
|
||||||
) where
|
) where
|
||||||
@@ -9,6 +9,7 @@ import Dodge.Data.Item.Use.Consumption.LoadAction
|
|||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Data.Creature
|
import Dodge.Data.Creature
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
import qualified IntMapHelp as IM
|
||||||
|
|
||||||
crCancelReloading :: Creature -> Creature
|
crCancelReloading :: Creature -> Creature
|
||||||
crCancelReloading cr =
|
crCancelReloading cr =
|
||||||
@@ -41,16 +42,37 @@ tryNextLoadAction cr = case cr ^? crManipulation . manObject . inInventory of
|
|||||||
& crManipulation . manObject . inInventory . iselAction . reloadAction .~ la
|
& crManipulation . manObject . inInventory . iselAction . reloadAction .~ la
|
||||||
_ -> cr
|
_ -> cr
|
||||||
|
|
||||||
crToggleReloading :: Creature -> Creature
|
crUpdateLoadSource :: Creature -> Creature
|
||||||
crToggleReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
crUpdateLoadSource cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
||||||
Just ReloadAction{} -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
|
Just NoInvSelAction -> cr & tryStartLoading
|
||||||
_ -> cr & tryStartLoading
|
_ -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
|
||||||
|
|
||||||
tryStartLoading :: Creature -> Creature
|
tryStartLoading :: Creature -> Creature
|
||||||
tryStartLoading cr = fromMaybe cr $ do
|
tryStartLoading cr = fromMaybe cr $ do
|
||||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
hc <- cr ^? crInv . ix i . itUse . heldConsumption . laSource . _InternalSource
|
as <- cr ^? crInv . ix i . itUse . heldConsumption . laSource
|
||||||
return $ startLoading hc cr
|
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
|
||||||
|
|
||||||
startLoading :: InternalAmmo -> Creature -> Creature
|
startLoading :: InternalAmmo -> Creature -> Creature
|
||||||
startLoading ic cr = case ic ^? iaProgress . _Just . ix 0 of
|
startLoading ic cr = case ic ^? iaProgress . _Just . ix 0 of
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ updateInitialPressInGame uv sc = case sc of
|
|||||||
ScancodeP -> pauseGame uv
|
ScancodeP -> pauseGame uv
|
||||||
ScancodeF -> over uvWorld youDropItem uv
|
ScancodeF -> over uvWorld youDropItem uv
|
||||||
ScancodeM -> toggleMap uv
|
ScancodeM -> toggleMap uv
|
||||||
ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crToggleReloading uv
|
ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crUpdateLoadSource uv
|
||||||
ScancodeT -> over uvWorld testEvent uv
|
ScancodeT -> over uvWorld testEvent uv
|
||||||
ScancodeX -> uv & uvWorld %~ toggleTweakInv
|
ScancodeX -> uv & uvWorld %~ toggleTweakInv
|
||||||
ScancodeC -> toggleCombineInv uv
|
ScancodeC -> toggleCombineInv uv
|
||||||
|
|||||||
Reference in New Issue
Block a user