Only display combinations for first items in list
This commit is contained in:
+58
-13
@@ -1,18 +1,18 @@
|
|||||||
/home/justin/Haskell/loop/src/Dodge/Combine.hs:37:1-20: warning: [-Wunused-top-binds]
|
/home/justin/Haskell/loop/src/Dodge/Combine.hs:31:1-15: warning: [-Wunused-top-binds]
|
||||||
Defined but not used: ‘invertInventoryToMap’
|
Defined but not used: ‘invertInventory’
|
||||||
|
|
|
|
||||||
37 | invertInventoryToMap =
|
31 | invertInventory =
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
/home/justin/Haskell/loop/src/Dodge/Combine.hs:43:1-14: warning: [-Wunused-top-binds]
|
/home/justin/Haskell/loop/src/Dodge/Combine.hs:43:1-14: warning: [-Wunused-top-binds]
|
||||||
Defined but not used: ‘splitItAmounts’
|
Defined but not used: ‘splitItAmounts’
|
||||||
|
|
|
|
||||||
43 | splitItAmounts = concatMap f
|
43 | splitItAmounts = concatMap f
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
/home/justin/Haskell/loop/src/Dodge/Combine.hs:48:1-21: warning: [-Wunused-top-binds]
|
/home/justin/Haskell/loop/src/Dodge/Combine.hs:53:1-18: warning: [-Wunused-top-binds]
|
||||||
Defined but not used: ‘groupSplitItemAmounts’
|
Defined but not used: ‘flatSplitItAmounts’
|
||||||
|
|
|
|
||||||
48 | groupSplitItemAmounts = M.foldrWithKey f []
|
53 | flatSplitItAmounts = concatMap f
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
/home/justin/Haskell/loop/src/Dodge/Combine.hs:58:1-11: warning: [-Wunused-top-binds]
|
/home/justin/Haskell/loop/src/Dodge/Combine.hs:58:1-11: warning: [-Wunused-top-binds]
|
||||||
Defined but not used: ‘lookupItems’
|
Defined but not used: ‘lookupItems’
|
||||||
|
|
|
|
||||||
@@ -23,27 +23,72 @@
|
|||||||
|
|
|
|
||||||
9 | import Data.Bifunctor
|
9 | import Data.Bifunctor
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
/home/justin/Haskell/loop/src/Dodge/Item/Grammar.hs:3:1: warning: [-Wunused-imports]
|
/home/justin/Haskell/loop/src/Dodge/Render/HUD.hs:237:15-18: warning: [-Wunused-matches]
|
||||||
|
Defined but not used: ‘cfig’
|
||||||
|
|
|
||||||
|
237 | combineCounts cfig w = foldMap f . group
|
||||||
|
| ^^^^
|
||||||
|
/home/justin/Haskell/loop/src/Dodge/Render/HUD.hs:237:20: warning: [-Wunused-matches]
|
||||||
|
Defined but not used: ‘w’
|
||||||
|
|
|
||||||
|
237 | combineCounts cfig w = foldMap f . group
|
||||||
|
| ^
|
||||||
|
/home/justin/Haskell/loop/src/Dodge/Item/Amount.hs:3:1-19: warning: [-Wunused-imports]
|
||||||
|
The import of ‘Control.Lens’ is redundant
|
||||||
|
|
|
||||||
|
3 | import Control.Lens
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
/home/justin/Haskell/loop/src/Dodge/Item/Amount.hs:4:1-17: warning: [-Wunused-imports]
|
||||||
|
The import of ‘Data.Maybe’ is redundant
|
||||||
|
|
|
||||||
|
4 | import Data.Maybe
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
/home/justin/Haskell/loop/src/Dodge/Item/Amount.hs:8:15-16: warning: [-Wunused-matches]
|
||||||
|
Defined but not used: ‘it’
|
||||||
|
|
|
||||||
|
8 | itStackAmount it = 1 -- fromMaybe 1 $ it ^? itUse . useAmount
|
||||||
|
| ^^
|
||||||
|
/home/justin/Haskell/loop/src/Dodge/Inventory/CheckSlots.hs:7:1-19: warning: [-Wunused-imports]
|
||||||
|
The import of ‘Control.Lens’ is redundant
|
||||||
|
|
|
||||||
|
7 | import Control.Lens
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
/home/justin/Haskell/loop/src/Dodge/Inventory/CheckSlots.hs:8:1-17: warning: [-Wunused-imports]
|
||||||
|
The import of ‘Data.Maybe’ is redundant
|
||||||
|
|
|
||||||
|
8 | import Data.Maybe
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
/home/justin/Haskell/loop/src/Dodge/Inventory/CheckSlots.hs:28:14-15: warning: [-Wunused-matches]
|
||||||
|
Defined but not used: ‘it’
|
||||||
|
|
|
||||||
|
28 | findItemSlot it inv = maybe 0 ((+ 1) . fst) $ IM.lookupMax inv
|
||||||
|
| ^^
|
||||||
|
/home/justin/Haskell/loop/src/Dodge/Item/SlotsTaken.hs:5:1-19: warning: [-Wunused-imports]
|
||||||
|
The import of ‘Control.Lens’ is redundant
|
||||||
|
|
|
||||||
|
5 | import Control.Lens
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
/home/justin/Haskell/loop/src/Dodge/Item/Grammar.hs:3:1-22: warning: [-Wunused-imports]
|
||||||
The import of ‘Dodge.Data.Item’ is redundant
|
The import of ‘Dodge.Data.Item’ is redundant
|
||||||
|
|
|
|
||||||
3 | import Dodge.Data.Item
|
3 | import Dodge.Data.Item
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
/home/justin/Haskell/loop/src/Dodge/Item/Draw/SPic.hs:20:1: warning: [-Wunused-top-binds]
|
/home/justin/Haskell/loop/src/Dodge/Item/Draw/SPic.hs:20:1-15: warning: [-Wunused-top-binds]
|
||||||
Defined but not used: ‘itemHeldAmmoPic’
|
Defined but not used: ‘itemHeldAmmoPic’
|
||||||
|
|
|
|
||||||
20 | itemHeldAmmoPic itm amit = itemSPic itm <> addAmmoClip itm amit
|
20 | itemHeldAmmoPic itm amit = itemSPic itm <> addAmmoClip itm amit
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
/home/justin/Haskell/loop/src/Dodge/Item/Draw/SPic.hs:23:1: warning: [-Wunused-top-binds]
|
/home/justin/Haskell/loop/src/Dodge/Item/Draw/SPic.hs:23:1-11: warning: [-Wunused-top-binds]
|
||||||
Defined but not used: ‘addAmmoClip’
|
Defined but not used: ‘addAmmoClip’
|
||||||
|
|
|
|
||||||
23 | addAmmoClip itm amit = fromMaybe mempty $ do
|
23 | addAmmoClip itm amit = fromMaybe mempty $ do
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
/home/justin/Haskell/loop/src/Dodge/Item/Draw/SPic.hs:23:17: warning: [-Wunused-matches]
|
/home/justin/Haskell/loop/src/Dodge/Item/Draw/SPic.hs:23:17-20: warning: [-Wunused-matches]
|
||||||
Defined but not used: ‘amit’
|
Defined but not used: ‘amit’
|
||||||
|
|
|
|
||||||
23 | addAmmoClip itm amit = fromMaybe mempty $ do
|
23 | addAmmoClip itm amit = fromMaybe mempty $ do
|
||||||
| ^^^^
|
| ^^^^
|
||||||
/home/justin/Haskell/loop/src/Dodge/Item/Draw/SPic.hs:24:5: warning: [-Wunused-matches]
|
/home/justin/Haskell/loop/src/Dodge/Item/Draw/SPic.hs:24:5-7: warning: [-Wunused-matches]
|
||||||
Defined but not used: ‘hit’
|
Defined but not used: ‘hit’
|
||||||
|
|
|
|
||||||
24 | hit <- itm ^? itType . iyBase . ibtHeld
|
24 | hit <- itm ^? itType . iyBase . ibtHeld
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -57,12 +57,12 @@ flatSplitItAmounts = concatMap f
|
|||||||
lookupItems :: IM.IntMap Item -> [([(ItAmount, Int)], Item)]
|
lookupItems :: IM.IntMap Item -> [([(ItAmount, Int)], Item)]
|
||||||
lookupItems = flip multiLookupTrieI combinationsTrie . sortOn fst . splitItAmounts . invertInventory
|
lookupItems = flip multiLookupTrieI combinationsTrie . sortOn fst . splitItAmounts . invertInventory
|
||||||
|
|
||||||
--flatLookupItems :: IM.IntMap Item -> [([[Int]],Item)]
|
|
||||||
--flatLookupItems = flip multiLookupTrieI combinationsTrie . sortOn fst . groupSplitItemAmounts
|
|
||||||
-- . invertInventoryToMap
|
|
||||||
flatLookupItems :: IM.IntMap Item -> [([[Int]],Item)]
|
flatLookupItems :: IM.IntMap Item -> [([[Int]],Item)]
|
||||||
flatLookupItems = flip multiLookupTrieI combinationsTrie . sortOn fst . flatSplitItAmounts
|
flatLookupItems = flip multiLookupTrieI combinationsTrie . sortOn fst . groupSplitItemAmounts
|
||||||
. invertInventory
|
. invertInventoryToMap
|
||||||
|
--flatLookupItems :: IM.IntMap Item -> [([[Int]],Item)]
|
||||||
|
--flatLookupItems = flip multiLookupTrieI combinationsTrie . sortOn fst . flatSplitItAmounts
|
||||||
|
-- . invertInventory
|
||||||
|
|
||||||
combineItemListYouX :: World -> [([Int], Item)]
|
combineItemListYouX :: World -> [([Int], Item)]
|
||||||
combineItemListYouX = map (first $ concat) . flatLookupItems . yourInv
|
combineItemListYouX = map (first $ concat) . flatLookupItems . yourInv
|
||||||
|
|||||||
+18
-13
@@ -116,7 +116,8 @@ inventoryX :: Char -> [Item]
|
|||||||
inventoryX c = case c of
|
inventoryX c = case c of
|
||||||
'A' ->
|
'A' ->
|
||||||
[ clickDetector ITEMDETECTOR
|
[ clickDetector ITEMDETECTOR
|
||||||
, makeTypeCraftNum 1 TRANSFORMER
|
] <> fold
|
||||||
|
[ makeTypeCraftNum 1 TRANSFORMER
|
||||||
, makeTypeCraftNum 2 CAN
|
, makeTypeCraftNum 2 CAN
|
||||||
, makeTypeCraftNum 2 PIPE
|
, makeTypeCraftNum 2 PIPE
|
||||||
]
|
]
|
||||||
@@ -130,7 +131,8 @@ inventoryX c = case c of
|
|||||||
, tinMag
|
, tinMag
|
||||||
, machinePistol
|
, machinePistol
|
||||||
, tinMag
|
, tinMag
|
||||||
, makeTypeCraftNum 4 MICROCHIP
|
] <> fold
|
||||||
|
[ makeTypeCraftNum 4 MICROCHIP
|
||||||
, makeTypeCraftNum 2 TIN
|
, makeTypeCraftNum 2 TIN
|
||||||
, makeTypeCraftNum 2 HARDWARE
|
, makeTypeCraftNum 2 HARDWARE
|
||||||
, makeTypeCraftNum 2 CAN
|
, makeTypeCraftNum 2 CAN
|
||||||
@@ -148,7 +150,7 @@ inventoryX c = case c of
|
|||||||
, unsafeBlinkGun
|
, unsafeBlinkGun
|
||||||
, autoDetector WALLDETECTOR
|
, autoDetector WALLDETECTOR
|
||||||
]
|
]
|
||||||
'E' ->
|
'E' -> fold
|
||||||
[ makeTypeCraftNum 3 PIPE
|
[ makeTypeCraftNum 3 PIPE
|
||||||
, makeTypeCraftNum 5 HARDWARE
|
, makeTypeCraftNum 5 HARDWARE
|
||||||
, makeTypeCraftNum 1 TIN
|
, makeTypeCraftNum 1 TIN
|
||||||
@@ -158,7 +160,7 @@ inventoryX c = case c of
|
|||||||
, makeTypeCraftNum 1 STEELDRUM
|
, makeTypeCraftNum 1 STEELDRUM
|
||||||
, makeTypeCraftNum 1 MOTOR
|
, makeTypeCraftNum 1 MOTOR
|
||||||
]
|
]
|
||||||
'F' ->
|
'F' -> fold
|
||||||
[ makeTypeCraftNum 5 PIPE
|
[ makeTypeCraftNum 5 PIPE
|
||||||
, makeTypeCraftNum 5 TUBE
|
, makeTypeCraftNum 5 TUBE
|
||||||
, makeTypeCraftNum 5 HARDWARE
|
, makeTypeCraftNum 5 HARDWARE
|
||||||
@@ -181,7 +183,8 @@ inventoryX c = case c of
|
|||||||
, tinMag
|
, tinMag
|
||||||
, pistol
|
, pistol
|
||||||
, tinMag
|
, tinMag
|
||||||
, makeTypeCraftNum 2 HARDWARE
|
] <> fold
|
||||||
|
[ makeTypeCraftNum 2 HARDWARE
|
||||||
, makeTypeCraftNum 2 MAGNET
|
, makeTypeCraftNum 2 MAGNET
|
||||||
, makeTypeCraftNum 5 (ENERGYBALLCRAFT IncBall)
|
, makeTypeCraftNum 5 (ENERGYBALLCRAFT IncBall)
|
||||||
, makeTypeCraftNum 5 (ENERGYBALLCRAFT TeslaBall)
|
, makeTypeCraftNum 5 (ENERGYBALLCRAFT TeslaBall)
|
||||||
@@ -192,22 +195,23 @@ inventoryX c = case c of
|
|||||||
'H' -> [shatterGun]
|
'H' -> [shatterGun]
|
||||||
'I' ->
|
'I' ->
|
||||||
[ makeTypeCraft TELEPORTMODULE
|
[ makeTypeCraft TELEPORTMODULE
|
||||||
, makeTypeCraftNum 2 TIMEMODULE
|
|
||||||
, makeTypeCraftNum 2 MICROCHIP
|
|
||||||
, makeTypeCraft HARDDRIVE
|
, makeTypeCraft HARDDRIVE
|
||||||
, makeTypeCraft RAM
|
, makeTypeCraft RAM
|
||||||
|
] <> fold
|
||||||
|
[ makeTypeCraftNum 2 TIMEMODULE
|
||||||
|
, makeTypeCraftNum 2 MICROCHIP
|
||||||
]
|
]
|
||||||
'J' ->
|
'J' ->
|
||||||
[ lasGun
|
[ lasGun
|
||||||
, lasGun
|
, lasGun
|
||||||
, dualBeam
|
, dualBeam
|
||||||
, makeTypeCraftNum 10 TRANSFORMER
|
] <> makeTypeCraftNum 10 TRANSFORMER
|
||||||
]
|
|
||||||
'K' ->
|
'K' ->
|
||||||
[ autoRifle
|
[ autoRifle
|
||||||
, tinMag
|
, tinMag
|
||||||
, targetingHat TargetRBPress
|
, targetingHat TargetRBPress
|
||||||
, makeTypeCraftNum 7 MICROCHIP
|
] <> fold
|
||||||
|
[ makeTypeCraftNum 7 MICROCHIP
|
||||||
, makeTypeCraftNum 4 HARDWARE
|
, makeTypeCraftNum 4 HARDWARE
|
||||||
, makeTypeCraftNum 2 MAGNET
|
, makeTypeCraftNum 2 MAGNET
|
||||||
, makeTypeCraftNum 1 MOTOR
|
, makeTypeCraftNum 1 MOTOR
|
||||||
@@ -239,8 +243,7 @@ inventoryX c = case c of
|
|||||||
|
|
||||||
testInventory :: [Item]
|
testInventory :: [Item]
|
||||||
testInventory =
|
testInventory =
|
||||||
[ makeTypeCraftNum 9 PIPE
|
[ autoAmr
|
||||||
, autoAmr
|
|
||||||
, brainHat
|
, brainHat
|
||||||
, headLamp
|
, headLamp
|
||||||
, autoDetector WALLDETECTOR
|
, autoDetector WALLDETECTOR
|
||||||
@@ -249,11 +252,13 @@ testInventory =
|
|||||||
, wristArmour
|
, wristArmour
|
||||||
, flatShield
|
, flatShield
|
||||||
, sniperRifle
|
, sniperRifle
|
||||||
, makeTypeCraftNum 1 MOTOR
|
|
||||||
, makeTypeCraft (ENERGYBALLCRAFT IncBall)
|
, makeTypeCraft (ENERGYBALLCRAFT IncBall)
|
||||||
, makeTypeCraft (ENERGYBALLCRAFT TeslaBall)
|
, makeTypeCraft (ENERGYBALLCRAFT TeslaBall)
|
||||||
, makeTypeCraft (ENERGYBALLCRAFT ConcBall)
|
, makeTypeCraft (ENERGYBALLCRAFT ConcBall)
|
||||||
, teleportModule
|
, teleportModule
|
||||||
|
] <> fold
|
||||||
|
[ makeTypeCraftNum 1 MOTOR
|
||||||
|
, makeTypeCraftNum 9 PIPE
|
||||||
, makeTypeCraftNum 10 HARDWARE
|
, makeTypeCraftNum 10 HARDWARE
|
||||||
, makeTypeCraftNum 3 SPRING
|
, makeTypeCraftNum 3 SPRING
|
||||||
, makeTypeCraftNum 10 CAN
|
, makeTypeCraftNum 10 CAN
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ itemEffect cr it w = case it ^. itUse of
|
|||||||
LeftUse{} -> doequipmentchange
|
LeftUse{} -> doequipmentchange
|
||||||
EquipUse{} -> doequipmentchange
|
EquipUse{} -> doequipmentchange
|
||||||
-- ConsumeUse will cause problems if the item is not selected
|
-- ConsumeUse will cause problems if the item is not selected
|
||||||
(ConsumeUse eff _) -> useC eff it cr $ rmInvItem (_crID cr) itRef w
|
(ConsumeUse eff) -> useC eff it cr $ rmInvItem (_crID cr) itRef w
|
||||||
CraftUse{} -> w
|
CraftUse{} -> w
|
||||||
AttachUse{} -> w
|
AttachUse{} -> w
|
||||||
AmmoMagUse{} -> w
|
AmmoMagUse{} -> w
|
||||||
|
|||||||
@@ -45,14 +45,14 @@ data ItemUse
|
|||||||
}
|
}
|
||||||
| ConsumeUse
|
| ConsumeUse
|
||||||
{ _cUse :: Cuse
|
{ _cUse :: Cuse
|
||||||
, _useAmount :: ItAmount
|
-- , _useAmount :: ItAmount
|
||||||
}
|
}
|
||||||
| EquipUse
|
| EquipUse
|
||||||
{ _equipEffect :: EquipEffect
|
{ _equipEffect :: EquipEffect
|
||||||
, _equipTargeting :: Maybe TargetType
|
, _equipTargeting :: Maybe TargetType
|
||||||
}
|
}
|
||||||
| CraftUse
|
| CraftUse
|
||||||
{_useAmount :: ItAmount}
|
-- {_useAmount :: ItAmount}
|
||||||
| AttachUse
|
| AttachUse
|
||||||
{_attachParams :: AttachParams}
|
{_attachParams :: AttachParams}
|
||||||
| AmmoMagUse
|
| AmmoMagUse
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ defaultLeftItem :: Item
|
|||||||
defaultLeftItem = defaultHeldItem & itUse .~ defaultLeftUse
|
defaultLeftItem = defaultHeldItem & itUse .~ defaultLeftUse
|
||||||
|
|
||||||
defaultCraftItem :: Item
|
defaultCraftItem :: Item
|
||||||
defaultCraftItem = defaultHeldItem & itUse .~ CraftUse 1
|
defaultCraftItem = defaultHeldItem & itUse .~ CraftUse
|
||||||
|
|
||||||
defaultBulletWeapon :: Item
|
defaultBulletWeapon :: Item
|
||||||
defaultBulletWeapon =
|
defaultBulletWeapon =
|
||||||
@@ -61,5 +61,5 @@ defaultWeapon =
|
|||||||
]
|
]
|
||||||
|
|
||||||
defaultConsumable :: Item
|
defaultConsumable :: Item
|
||||||
defaultConsumable = defaultHeldItem & itUse .~ ConsumeUse CDoNothing 1
|
defaultConsumable = defaultHeldItem & itUse .~ ConsumeUse CDoNothing
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ copyItemToFloorID pos it w =
|
|||||||
flid = IM.newKey $ _floorItems (_lWorld (_cWorld w))
|
flid = IM.newKey $ _floorItems (_lWorld (_cWorld w))
|
||||||
theflit =
|
theflit =
|
||||||
FlIt
|
FlIt
|
||||||
{ _flIt = it & itUse . useAmount %~ const 1
|
-- { _flIt = it & itUse . useAmount %~ const 1
|
||||||
|
{ _flIt = it
|
||||||
, _flItPos = p'
|
, _flItPos = p'
|
||||||
, _flItRot = rot
|
, _flItRot = rot
|
||||||
, _flItID = flid
|
, _flItID = flid
|
||||||
|
|||||||
+66
-8
@@ -42,13 +42,7 @@ rmInvItem ::
|
|||||||
Int ->
|
Int ->
|
||||||
World ->
|
World ->
|
||||||
World
|
World
|
||||||
rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount of
|
rmInvItem cid invid w = w
|
||||||
Just x
|
|
||||||
| x > 1 ->
|
|
||||||
w & pointcid . crInv . ix invid . itUse . useAmount -~ 1
|
|
||||||
& worldEventFlags . at InventoryChange ?~ ()
|
|
||||||
_ ->
|
|
||||||
w
|
|
||||||
-- & pointcid %~ crCancelReloading
|
-- & pointcid %~ crCancelReloading
|
||||||
& doanyitemeffect
|
& doanyitemeffect
|
||||||
& dounequipfunction --the ordering of these is
|
& dounequipfunction --the ordering of these is
|
||||||
@@ -67,7 +61,6 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
|
|||||||
& updateselection
|
& updateselection
|
||||||
& worldEventFlags . at InventoryChange ?~ ()
|
& worldEventFlags . at InventoryChange ?~ ()
|
||||||
where
|
where
|
||||||
getcid = cWorld . lWorld . creatures . ix cid
|
|
||||||
pointcid = cWorld . lWorld . creatures . ix cid
|
pointcid = cWorld . lWorld . creatures . ix cid
|
||||||
|
|
||||||
updateselection
|
updateselection
|
||||||
@@ -99,6 +92,71 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
|
|||||||
| x > invid || Just x == maxk = max 0 $ x - 1
|
| x > invid || Just x == maxk = max 0 $ x - 1
|
||||||
| otherwise = x
|
| otherwise = x
|
||||||
|
|
||||||
|
---- | after this the item at the inventory position will no longer exist
|
||||||
|
--rmInvItem ::
|
||||||
|
-- -- | Creature id
|
||||||
|
-- Int ->
|
||||||
|
-- -- | Inventory position
|
||||||
|
-- Int ->
|
||||||
|
-- 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 -~ 1
|
||||||
|
-- & worldEventFlags . at InventoryChange ?~ ()
|
||||||
|
-- _ ->
|
||||||
|
-- w
|
||||||
|
---- & pointcid %~ crCancelReloading
|
||||||
|
-- & doanyitemeffect
|
||||||
|
-- & dounequipfunction --the ordering of these is
|
||||||
|
-- & pointcid . crInv %~ f -- important
|
||||||
|
--
|
||||||
|
-- & removeAnySlotEquipment
|
||||||
|
-- & pointcid . crEquipment . each %~ g
|
||||||
|
-- & pointcid . crInvEquipped %~ IM.delete invid
|
||||||
|
-- & pointcid . crInvEquipped %~ IM.mapKeys g
|
||||||
|
--
|
||||||
|
-- & removeanyactivation
|
||||||
|
-- & pointcid . crHotkeys . each %~ g
|
||||||
|
-- & pointcid . crInvHotkeys %~ IM.delete invid
|
||||||
|
-- & pointcid . crInvHotkeys %~ IM.mapKeys g
|
||||||
|
--
|
||||||
|
-- & updateselection
|
||||||
|
-- & worldEventFlags . at InventoryChange ?~ ()
|
||||||
|
-- where
|
||||||
|
-- getcid = cWorld . lWorld . creatures . ix cid
|
||||||
|
-- pointcid = cWorld . lWorld . creatures . ix cid
|
||||||
|
--
|
||||||
|
-- updateselection
|
||||||
|
-- | cid == 0 && cr ^? crManipulation . manObject . inInventory . ispItem == Just invid =
|
||||||
|
-- scrollAugInvSel (-1) . scrollAugInvSel 1 . updateInventorySectionItems
|
||||||
|
-- | otherwise =
|
||||||
|
-- pointcid . crManipulation . manObject . inInventory . ispItem %~ g
|
||||||
|
--
|
||||||
|
-- cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||||
|
-- itm = _crInv cr IM.! invid
|
||||||
|
-- dounequipfunction = fromMaybe id $ do
|
||||||
|
-- rmf <- itm ^? itUse . equipEffect . eeOnRemove
|
||||||
|
-- return $ useE rmf itm cr
|
||||||
|
-- doanyitemeffect = fromMaybe id $ do
|
||||||
|
-- rmf <- itm ^? itEffect . ieOnDrop
|
||||||
|
-- return $ doInvEffect rmf itm cr
|
||||||
|
-- removeAnySlotEquipment = fromMaybe id $ do
|
||||||
|
-- epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvEquipped . ix invid
|
||||||
|
-- return $ pointcid . crEquipment . at epos .~ Nothing
|
||||||
|
-- removeanyactivation = fromMaybe id $ do
|
||||||
|
-- epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvHotkeys . ix invid
|
||||||
|
-- return $ pointcid . crHotkeys . at epos .~ Nothing
|
||||||
|
-- maxk = fmap fst $ IM.lookupMax $ cr ^. crInv
|
||||||
|
-- f inv =
|
||||||
|
-- let (xs, ys) = IM.split invid inv
|
||||||
|
-- in xs `IM.union` IM.mapKeysMonotonic (subtract 1) ys
|
||||||
|
-- -- the following might not work if a non-player creature drops their last item
|
||||||
|
-- g x
|
||||||
|
-- | x > invid || Just x == maxk = max 0 $ x - 1
|
||||||
|
-- | otherwise = x
|
||||||
|
|
||||||
rmSelectedInvItem :: Int -> World -> World
|
rmSelectedInvItem :: Int -> World -> World
|
||||||
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . inInventory . ispItem of
|
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . inInventory . ispItem of
|
||||||
Just i -> rmInvItem cid i w
|
Just i -> rmInvItem cid i w
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ putItemInInvID cid flid w = fromMaybe (Nothing, w) $ do
|
|||||||
return (Just i, w')
|
return (Just i, w')
|
||||||
|
|
||||||
putItemInInvSlot :: Int -> Item -> IM.IntMap Item -> IM.IntMap Item
|
putItemInInvSlot :: Int -> Item -> IM.IntMap Item -> IM.IntMap Item
|
||||||
putItemInInvSlot = IM.insertWith (const $ itUse . useAmount +~ 1)
|
putItemInInvSlot = IM.insert
|
||||||
|
--putItemInInvSlot = IM.insertWith (const $ itUse . useAmount +~ 1)
|
||||||
|
|
||||||
-- | Pick up a specific item.
|
-- | Pick up a specific item.
|
||||||
tryPutItemInInv :: Int -> FloorItem -> World -> Maybe (Int, World)
|
tryPutItemInInv :: Int -> FloorItem -> World -> Maybe (Int, World)
|
||||||
|
|||||||
@@ -25,12 +25,13 @@ checkInvSlotsYou it w
|
|||||||
-- Assumes that the item is singular.
|
-- Assumes that the item is singular.
|
||||||
-- Do not want to stack floor items for now
|
-- Do not want to stack floor items for now
|
||||||
findItemSlot :: Item -> IM.IntMap Item -> Int
|
findItemSlot :: Item -> IM.IntMap Item -> Int
|
||||||
findItemSlot it inv = case it ^? itUse . useAmount of
|
findItemSlot it inv = maybe 0 ((+ 1) . fst) $ IM.lookupMax inv
|
||||||
Just _ ->
|
--findItemSlot it inv = case it ^? itUse . useAmount of
|
||||||
fromMaybe newslot $ IM.findIndex (\it' -> _itType it == _itType it') inv
|
-- Just _ ->
|
||||||
_ -> newslot
|
-- fromMaybe newslot $ IM.findIndex (\it' -> _itType it == _itType it') inv
|
||||||
where
|
-- _ -> newslot
|
||||||
newslot = maybe 0 ((+ 1) . fst) $ IM.lookupMax inv
|
-- where
|
||||||
|
-- newslot = maybe 0 ((+ 1) . fst) $ IM.lookupMax inv
|
||||||
|
|
||||||
crNumFreeSlots :: Creature -> Int
|
crNumFreeSlots :: Creature -> Int
|
||||||
crNumFreeSlots cr = _crInvCapacity cr - invSize (_crInv cr)
|
crNumFreeSlots cr = _crInvCapacity cr - invSize (_crInv cr)
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ import Data.Maybe
|
|||||||
import Dodge.Data.Item
|
import Dodge.Data.Item
|
||||||
|
|
||||||
itStackAmount :: Item -> ItAmount
|
itStackAmount :: Item -> ItAmount
|
||||||
itStackAmount it = fromMaybe 1 $ it ^? itUse . useAmount
|
itStackAmount it = 1 -- fromMaybe 1 $ it ^? itUse . useAmount
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ import Dodge.Default.Item
|
|||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Data.Item
|
import Dodge.Data.Item
|
||||||
|
|
||||||
makeTypeCraftNum :: Int -> CraftType -> Item
|
makeTypeCraftNum :: Int -> CraftType -> [Item]
|
||||||
makeTypeCraftNum i ct =
|
makeTypeCraftNum i ct = replicate i $
|
||||||
defaultCraftItem
|
defaultCraftItem
|
||||||
& itInvSize .~ 0.5
|
& itInvSize .~ 0.5
|
||||||
& itCurseStatus .~ Uncursed
|
& itCurseStatus .~ Uncursed
|
||||||
& itUse . useAmount .~ fromIntegral i
|
-- & itUse . useAmount .~ fromIntegral i
|
||||||
& itType . iyBase .~ CRAFT ct
|
& itType . iyBase .~ CRAFT ct
|
||||||
|
|
||||||
makeTypeCraft :: CraftType -> Item
|
makeTypeCraft :: CraftType -> Item
|
||||||
makeTypeCraft = makeTypeCraftNum 1
|
makeTypeCraft = head . makeTypeCraftNum 1
|
||||||
|
|
||||||
energyBallCraft :: EnergyBallType -> Item
|
energyBallCraft :: EnergyBallType -> Item
|
||||||
energyBallCraft ebt = makeTypeCraft (ENERGYBALLCRAFT ebt) & itInvSize .~ 1
|
energyBallCraft ebt = makeTypeCraft (ENERGYBALLCRAFT ebt) & itInvSize .~ 1
|
||||||
|
|||||||
@@ -121,8 +121,10 @@ itemNumberDisplay cr itm = case iu of
|
|||||||
HeldUse{} -> []
|
HeldUse{} -> []
|
||||||
LeftUse{} -> [showAutoRechargeProgress (_leftConsumption iu)]
|
LeftUse{} -> [showAutoRechargeProgress (_leftConsumption iu)]
|
||||||
EquipUse{} -> showEquipmentNumber cr itm
|
EquipUse{} -> showEquipmentNumber cr itm
|
||||||
CraftUse x -> [show $ x ^. getItAmount]
|
--CraftUse x -> [show $ x ^. getItAmount]
|
||||||
ConsumeUse {_useAmount = x} -> [show $ x ^. getItAmount]
|
CraftUse -> []
|
||||||
|
--ConsumeUse {_useAmount = x} -> [show $ x ^. getItAmount]
|
||||||
|
ConsumeUse {} -> []
|
||||||
AttachUse {} -> [] --[showReloadProgress cr itm]
|
AttachUse {} -> [] --[showReloadProgress cr itm]
|
||||||
AmmoMagUse {} -> [showLoadedAmount itm]
|
AmmoMagUse {} -> [showLoadedAmount itm]
|
||||||
-- this could be cleaner here...
|
-- this could be cleaner here...
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import Dodge.Data.Item
|
|||||||
import Dodge.Module
|
import Dodge.Module
|
||||||
|
|
||||||
itSlotsTaken :: Item -> Int
|
itSlotsTaken :: Item -> Int
|
||||||
itSlotsTaken it = case it ^? itUse . useAmount of
|
itSlotsTaken it = moduleSizes it + ceiling (_itInvSize it)
|
||||||
Nothing -> moduleSizes it + ceiling (_itInvSize it)
|
|
||||||
Just i -> moduleSizes it + ceiling (_itInvSize it * fromIntegral i)
|
--itSlotsTaken :: Item -> Int
|
||||||
|
--itSlotsTaken it = case it ^? itUse . useAmount of
|
||||||
|
-- Nothing -> moduleSizes it + ceiling (_itInvSize it)
|
||||||
|
-- Just i -> moduleSizes it + ceiling (_itInvSize it * fromIntegral i)
|
||||||
|
|||||||
+13
-13
@@ -236,19 +236,19 @@ displayTerminal tid cfig w = fromMaybe mempty $ do
|
|||||||
combineCounts :: Configuration -> World -> [Int] -> Picture
|
combineCounts :: Configuration -> World -> [Int] -> Picture
|
||||||
combineCounts cfig w = foldMap f . group
|
combineCounts cfig w = foldMap f . group
|
||||||
where
|
where
|
||||||
f (i : is) = fromMaybe mempty $ do
|
-- f (i : is) = fromMaybe mempty $ do
|
||||||
_ <- yourInv w ^? ix i . itUse . useAmount
|
-- _ <- yourInv w ^? ix i . itUse . useAmount
|
||||||
sss <- w ^? hud . hudElement . diSections
|
-- sss <- w ^? hud . hudElement . diSections
|
||||||
--p <- selNumTextEndPos cfig (invDisplayParams w) sss 0 i
|
-- --p <- selNumTextEndPos cfig (invDisplayParams w) sss 0 i
|
||||||
col <- selSecSelCol 0 i sss
|
-- col <- selSecSelCol 0 i sss
|
||||||
yint <- selSecYint 0 i sss
|
-- yint <- selSecYint 0 i sss
|
||||||
--return $ color col $ uncurryV translate p . scale 0.1 0.1 . text $ ('-' : show (length is + 1))
|
-- --return $ color col $ uncurryV translate p . scale 0.1 0.1 . text $ ('-' : show (length is + 1))
|
||||||
return
|
-- return
|
||||||
. translateScreenPos cfig (invDisplayParams w ^. ldpPos)
|
-- . translateScreenPos cfig (invDisplayParams w ^. ldpPos)
|
||||||
. color col
|
-- . color col
|
||||||
. drawListElement 0 1 15 yint
|
-- . drawListElement 0 1 15 yint
|
||||||
. text
|
-- . text
|
||||||
$ ('-' : show (length is + 1))
|
-- $ ('-' : show (length is + 1))
|
||||||
f _ = mempty
|
f _ = mempty
|
||||||
|
|
||||||
lnkMidPosInvSelsCol :: Configuration -> World -> Int -> Color -> [Int] -> Picture
|
lnkMidPosInvSelsCol :: Configuration -> World -> Int -> Color -> [Int] -> Picture
|
||||||
|
|||||||
Reference in New Issue
Block a user