Cleanup
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
All good (604 modules, at 10:01:12)
|
All good (604 modules, at 10:33:02)
|
||||||
|
|||||||
+22
-24
@@ -3,39 +3,18 @@ module Dodge.Combine (
|
|||||||
combineList,
|
combineList,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.Combine.Combinations
|
|
||||||
import Data.Bifunctor
|
import Data.Bifunctor
|
||||||
import Data.List (sortOn)
|
import Data.Foldable
|
||||||
|
import Data.List (sort, sortOn)
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import Dodge.Base.You
|
import Dodge.Base.You
|
||||||
|
import Dodge.Combine.Combinations
|
||||||
import Dodge.Data.Combine
|
import Dodge.Data.Combine
|
||||||
import Dodge.Data.Universe
|
import Dodge.Data.Universe
|
||||||
import Dodge.Item.Display
|
import Dodge.Item.Display
|
||||||
import Dodge.Item.InventoryColor
|
import Dodge.Item.InventoryColor
|
||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
import SimpleTrie
|
import SimpleTrie
|
||||||
import Data.Foldable
|
|
||||||
import Data.List (sort)
|
|
||||||
|
|
||||||
invertInventoryToMap :: IM.IntMap Item -> M.Map ItemType [Int]
|
|
||||||
invertInventoryToMap =
|
|
||||||
IM.foldrWithKey
|
|
||||||
(\k it -> M.insertWith (++) (_itType it) [k])
|
|
||||||
mempty
|
|
||||||
|
|
||||||
groupSplitItemAmounts :: M.Map ItemType [Int] -> [((ItAmount, ItemType), [Int])]
|
|
||||||
--groupSplitItemAmounts = M.foldrWithKey f []
|
|
||||||
groupSplitItemAmounts = M.foldrWithKey f []
|
|
||||||
where
|
|
||||||
f ibt is = (++) [((fromIntegral i, ibt), take i is) | i <- [1 .. length is]]
|
|
||||||
|
|
||||||
flatLookupItems :: IM.IntMap Item -> [([[Int]], Item)]
|
|
||||||
flatLookupItems =
|
|
||||||
flip multiLookupTrieI combinationsTrie . sortOn fst . groupSplitItemAmounts
|
|
||||||
. invertInventoryToMap
|
|
||||||
|
|
||||||
combineItemListYouX :: World -> [([Int], Item)]
|
|
||||||
combineItemListYouX = map (first concat) . flatLookupItems . yourInv
|
|
||||||
|
|
||||||
combineList :: World -> [SelectionItem CombinableItem]
|
combineList :: World -> [SelectionItem CombinableItem]
|
||||||
combineList = map f . combineItemListYouX
|
combineList = map f . combineItemListYouX
|
||||||
@@ -50,6 +29,14 @@ combineList = map f . combineItemListYouX
|
|||||||
, _siPayload = CombinableItem is itm []
|
, _siPayload = CombinableItem is itm []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
combineItemListYouX :: World -> [([Int], Item)]
|
||||||
|
combineItemListYouX = map (first concat) . flatLookupItems . yourInv
|
||||||
|
|
||||||
|
flatLookupItems :: IM.IntMap Item -> [([[Int]], Item)]
|
||||||
|
flatLookupItems =
|
||||||
|
flip multiLookupTrieI combinationsTrie . sortOn fst . groupSplitItemAmounts
|
||||||
|
. invertInventoryToMap
|
||||||
|
|
||||||
combinationsTrie :: Trie (ItAmount, ItemType) Item
|
combinationsTrie :: Trie (ItAmount, ItemType) Item
|
||||||
{-# INLINE combinationsTrie #-}
|
{-# INLINE combinationsTrie #-}
|
||||||
combinationsTrie =
|
combinationsTrie =
|
||||||
@@ -57,3 +44,14 @@ combinationsTrie =
|
|||||||
(flip $ uncurry insertInTrie . first sort)
|
(flip $ uncurry insertInTrie . first sort)
|
||||||
emptyTrie
|
emptyTrie
|
||||||
itemCombinations
|
itemCombinations
|
||||||
|
|
||||||
|
groupSplitItemAmounts :: M.Map ItemType [Int] -> [((ItAmount, ItemType), [Int])]
|
||||||
|
groupSplitItemAmounts = M.foldMapWithKey f
|
||||||
|
where
|
||||||
|
f ibt is = [((fromIntegral i, ibt), take i is) | i <- [1 .. length is]]
|
||||||
|
|
||||||
|
invertInventoryToMap :: IM.IntMap Item -> M.Map ItemType [Int]
|
||||||
|
invertInventoryToMap =
|
||||||
|
IM.foldrWithKey
|
||||||
|
(\k it -> M.insertWith (++) (_itType it) [k])
|
||||||
|
mempty
|
||||||
|
|||||||
@@ -18,11 +18,14 @@ module IntMapHelp
|
|||||||
|
|
||||||
cycleGT,
|
cycleGT,
|
||||||
cycleLT,
|
cycleLT,
|
||||||
|
|
||||||
|
invertIntMap,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import Data.IntMap.Strict
|
import Data.IntMap.Strict
|
||||||
|
import qualified Data.Map.Strict as M
|
||||||
import GHC.Generics
|
import GHC.Generics
|
||||||
import LensHelp
|
import LensHelp
|
||||||
|
|
||||||
@@ -94,3 +97,9 @@ cycleGT i m = lookupGT i m <|> lookupMin m
|
|||||||
|
|
||||||
cycleLT :: Int -> IntMap a -> Maybe (Int, a)
|
cycleLT :: Int -> IntMap a -> Maybe (Int, a)
|
||||||
cycleLT i m = lookupLT i m <|> lookupMax m
|
cycleLT i m = lookupLT i m <|> lookupMax m
|
||||||
|
|
||||||
|
invertIntMap :: Ord a => IntMap a -> M.Map a [Int]
|
||||||
|
invertIntMap = foldrWithKey
|
||||||
|
(\k xs -> M.insertWith (++) xs [k])
|
||||||
|
mempty
|
||||||
|
|
||||||
|
|||||||
@@ -4705,13 +4705,14 @@ colorSH src/Shape.hs 233;" f
|
|||||||
combinationsDotGraph src/Dodge/Combine/Graph.hs 85;" f
|
combinationsDotGraph src/Dodge/Combine/Graph.hs 85;" f
|
||||||
combinationsGraph src/Dodge/Combine/Graph.hs 66;" f
|
combinationsGraph src/Dodge/Combine/Graph.hs 66;" f
|
||||||
combinationsOf src/Multiset.hs 40;" f
|
combinationsOf src/Multiset.hs 40;" f
|
||||||
|
combinationsTrie src/Dodge/Combine.hs 51;" f
|
||||||
combinationsTrie src/Dodge/Combine/Trie.hs 19;" f
|
combinationsTrie src/Dodge/Combine/Trie.hs 19;" f
|
||||||
combineAwareness src/Dodge/Creature/AlertLevel.hs 33;" f
|
combineAwareness src/Dodge/Creature/AlertLevel.hs 33;" f
|
||||||
combineAwareness src/Dodge/Creature/Perception.hs 109;" f
|
combineAwareness src/Dodge/Creature/Perception.hs 109;" f
|
||||||
combineFloors src/Dodge/Room/Procedural.hs 171;" f
|
combineFloors src/Dodge/Room/Procedural.hs 171;" f
|
||||||
combineInventoryExtra src/Dodge/Render/HUD.hs 203;" f
|
combineInventoryExtra src/Dodge/Render/HUD.hs 203;" f
|
||||||
combineItemListYouX src/Dodge/Combine.hs 34;" f
|
combineItemListYouX src/Dodge/Combine.hs 35;" f
|
||||||
combineList src/Dodge/Combine.hs 37;" f
|
combineList src/Dodge/Combine.hs 38;" f
|
||||||
combineRooms src/Dodge/Room/Procedural.hs 151;" f
|
combineRooms src/Dodge/Room/Procedural.hs 151;" f
|
||||||
combineS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 344;" f
|
combineS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 344;" f
|
||||||
combineTree src/Dodge/Tree/Compose.hs 66;" f
|
combineTree src/Dodge/Tree/Compose.hs 66;" f
|
||||||
@@ -4856,9 +4857,9 @@ cutWallsWithPoints src/Dodge/LevelGen/StaticWalls.hs 112;" f
|
|||||||
cyan src/Color.hs 18;" f
|
cyan src/Color.hs 18;" f
|
||||||
cycleDownEnum src/Dodge/Menu/OptionType.hs 27;" f
|
cycleDownEnum src/Dodge/Menu/OptionType.hs 27;" f
|
||||||
cycleEnum src/Dodge/Menu/OptionType.hs 22;" f
|
cycleEnum src/Dodge/Menu/OptionType.hs 22;" f
|
||||||
cycleGT src/IntMapHelp.hs 92;" f
|
cycleGT src/IntMapHelp.hs 95;" f
|
||||||
cycleL src/DoubleStack.hs 28;" f
|
cycleL src/DoubleStack.hs 28;" f
|
||||||
cycleLT src/IntMapHelp.hs 95;" f
|
cycleLT src/IntMapHelp.hs 98;" f
|
||||||
cycleOptions src/Dodge/Menu/Option.hs 84;" f
|
cycleOptions src/Dodge/Menu/Option.hs 84;" f
|
||||||
cycleR src/DoubleStack.hs 32;" f
|
cycleR src/DoubleStack.hs 32;" f
|
||||||
cylinderIndices src/Shader/Poke.hs 374;" f
|
cylinderIndices src/Shader/Poke.hs 374;" f
|
||||||
@@ -5392,7 +5393,7 @@ findBlips src/Dodge/RadarSweep.hs 44;" f
|
|||||||
findBoundDists src/Dodge/Update/Camera.hs 239;" f
|
findBoundDists src/Dodge/Update/Camera.hs 239;" f
|
||||||
findClosePoint src/Dodge/LevelGen/StaticWalls.hs 155;" f
|
findClosePoint src/Dodge/LevelGen/StaticWalls.hs 155;" f
|
||||||
findClosePoint src/Dodge/LevelGen/StaticWalls/Deprecated.hs 74;" f
|
findClosePoint src/Dodge/LevelGen/StaticWalls/Deprecated.hs 74;" f
|
||||||
findIndex src/IntMapHelp.hs 84;" f
|
findIndex src/IntMapHelp.hs 87;" f
|
||||||
findItemSlot src/Dodge/Inventory/CheckSlots.hs 26;" f
|
findItemSlot src/Dodge/Inventory/CheckSlots.hs 26;" f
|
||||||
findReverseEdge src/Polyhedra.hs 49;" f
|
findReverseEdge src/Polyhedra.hs 49;" f
|
||||||
findReverseEdgeList src/Polyhedra.hs 56;" f
|
findReverseEdgeList src/Polyhedra.hs 56;" f
|
||||||
@@ -5420,7 +5421,7 @@ flameWall src/Dodge/Item/Weapon/SprayGuns.hs 54;" f
|
|||||||
flamerPic src/Dodge/Item/Draw/SPic.hs 331;" f
|
flamerPic src/Dodge/Item/Draw/SPic.hs 331;" f
|
||||||
flareCircleAt src/Dodge/WorldEvent/Flash.hs 46;" f
|
flareCircleAt src/Dodge/WorldEvent/Flash.hs 46;" f
|
||||||
flatItemCombinations src/Dodge/Combine/Combinations.hs 49;" f
|
flatItemCombinations src/Dodge/Combine/Combinations.hs 49;" f
|
||||||
flatLookupItems src/Dodge/Combine.hs 29;" f
|
flatLookupItems src/Dodge/Combine.hs 30;" f
|
||||||
flatShield src/Dodge/Item/Held/Utility.hs 9;" f
|
flatShield src/Dodge/Item/Held/Utility.hs 9;" f
|
||||||
flatShieldEquipSPic src/Dodge/Item/Draw/SPic.hs 392;" f
|
flatShieldEquipSPic src/Dodge/Item/Draw/SPic.hs 392;" f
|
||||||
flattenIMIMIM src/Dodge/Base/Zone.hs 246;" f
|
flattenIMIMIM src/Dodge/Base/Zone.hs 246;" f
|
||||||
@@ -5577,7 +5578,7 @@ gridPoints src/Grid.hs 67;" f
|
|||||||
gridPoints' src/Grid.hs 79;" f
|
gridPoints' src/Grid.hs 79;" f
|
||||||
gridPoints'' src/Grid.hs 74;" f
|
gridPoints'' src/Grid.hs 74;" f
|
||||||
gridPointsOff src/Grid.hs 62;" f
|
gridPointsOff src/Grid.hs 62;" f
|
||||||
groupSplitItemAmounts src/Dodge/Combine.hs 24;" f
|
groupSplitItemAmounts src/Dodge/Combine.hs 25;" f
|
||||||
gruntS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 484;" f
|
gruntS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 484;" f
|
||||||
guardDisconnectedID src/Dodge/Update/Scroll.hs 71;" f
|
guardDisconnectedID src/Dodge/Update/Scroll.hs 71;" f
|
||||||
gut1S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 516;" f
|
gut1S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 516;" f
|
||||||
@@ -5706,14 +5707,14 @@ insertAt src/Padding.hs 60;" f
|
|||||||
insertIMInZone src/Dodge/Base.hs 59;" f
|
insertIMInZone src/Dodge/Base.hs 59;" f
|
||||||
insertInTrie src/SimpleTrie.hs 18;" f
|
insertInTrie src/SimpleTrie.hs 18;" f
|
||||||
insertInZoneWith src/Dodge/Zone/Update.hs 17;" f
|
insertInZoneWith src/Dodge/Zone/Update.hs 17;" f
|
||||||
insertNewKey src/IntMapHelp.hs 63;" f
|
insertNewKey src/IntMapHelp.hs 66;" f
|
||||||
insertOneS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 368;" f
|
insertOneS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 368;" f
|
||||||
insertOver src/ListHelp.hs 47;" f
|
insertOver src/ListHelp.hs 47;" f
|
||||||
insertS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 318;" f
|
insertS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 318;" f
|
||||||
insertWall src/Dodge/Placement/PlaceSpot/Block.hs 122;" f
|
insertWall src/Dodge/Placement/PlaceSpot/Block.hs 122;" f
|
||||||
insertWallInZones src/Dodge/Wall/Zone.hs 20;" f
|
insertWallInZones src/Dodge/Wall/Zone.hs 20;" f
|
||||||
insertWalls src/Dodge/Placement/PlaceSpot/Block.hs 117;" f
|
insertWalls src/Dodge/Placement/PlaceSpot/Block.hs 117;" f
|
||||||
insertWithNewKeys src/IntMapHelp.hs 69;" f
|
insertWithNewKeys src/IntMapHelp.hs 72;" f
|
||||||
intToBulAmmo src/Dodge/TweakBullet.hs 23;" f
|
intToBulAmmo src/Dodge/TweakBullet.hs 23;" f
|
||||||
internalHammerUpdate src/Dodge/Creature/State.hs 147;" f
|
internalHammerUpdate src/Dodge/Creature/State.hs 147;" f
|
||||||
interpWith src/Dodge/Creature/Boid.hs 10;" f
|
interpWith src/Dodge/Creature/Boid.hs 10;" f
|
||||||
@@ -5755,8 +5756,9 @@ inventoryExtraH src/Dodge/Render/HUD.hs 195;" f
|
|||||||
inventoryX src/Dodge/Creature.hs 115;" f
|
inventoryX src/Dodge/Creature.hs 115;" f
|
||||||
inverseShockwaveAt src/Dodge/WorldEvent/Shockwave.hs 43;" f
|
inverseShockwaveAt src/Dodge/WorldEvent/Shockwave.hs 43;" f
|
||||||
invertEncircleDistP src/Dodge/Creature/Boid.hs 13;" f
|
invertEncircleDistP src/Dodge/Creature/Boid.hs 13;" f
|
||||||
|
invertIntMap src/IntMapHelp.hs 101;" f
|
||||||
invertIntMap src/Multiset.hs 61;" f
|
invertIntMap src/Multiset.hs 61;" f
|
||||||
invertInventoryToMap src/Dodge/Combine.hs 18;" f
|
invertInventoryToMap src/Dodge/Combine.hs 19;" f
|
||||||
invisibleChaseCrit src/Dodge/Creature/ChaseCrit.hs 25;" f
|
invisibleChaseCrit src/Dodge/Creature/ChaseCrit.hs 25;" f
|
||||||
invisibleWall src/Dodge/Placement/Instance/Wall.hs 16;" f
|
invisibleWall src/Dodge/Placement/Instance/Wall.hs 16;" f
|
||||||
isAmmoIntLink src/Dodge/HeldUse.hs 188;" f
|
isAmmoIntLink src/Dodge/HeldUse.hs 188;" f
|
||||||
@@ -6265,7 +6267,7 @@ nearSeg src/Dodge/Zone.hs 89;" f
|
|||||||
nearSeg src/Dodge/Zoning/Common.hs 12;" f
|
nearSeg src/Dodge/Zoning/Common.hs 12;" f
|
||||||
newExtraAwareness src/Dodge/Creature/Perception.hs 137;" f
|
newExtraAwareness src/Dodge/Creature/Perception.hs 137;" f
|
||||||
newHotkey src/Dodge/Hotkey.hs 18;" f
|
newHotkey src/Dodge/Hotkey.hs 18;" f
|
||||||
newKey src/IntMapHelp.hs 59;" f
|
newKey src/IntMapHelp.hs 62;" f
|
||||||
newMapKey src/Dodge/Config/KeyConfig.hs 33;" f
|
newMapKey src/Dodge/Config/KeyConfig.hs 33;" f
|
||||||
newSounds src/Dodge/Creature/Perception.hs 170;" f
|
newSounds src/Dodge/Creature/Perception.hs 170;" f
|
||||||
newTextureFramebuffer src/Framebuffer/Setup.hs 16;" f
|
newTextureFramebuffer src/Framebuffer/Setup.hs 16;" f
|
||||||
@@ -6868,7 +6870,7 @@ safeMinimumOnMaybe src/FoldableHelp.hs 67;" f
|
|||||||
safeMinimumOnMaybeF src/FoldableHelp.hs 39;" f
|
safeMinimumOnMaybeF src/FoldableHelp.hs 39;" f
|
||||||
safeMinimumOnMaybeL src/FoldableHelp.hs 57;" f
|
safeMinimumOnMaybeL src/FoldableHelp.hs 57;" f
|
||||||
safeNormalizeV src/Geometry/Vector.hs 153;" f
|
safeNormalizeV src/Geometry/Vector.hs 153;" f
|
||||||
safeSwapKeys src/IntMapHelp.hs 76;" f
|
safeSwapKeys src/IntMapHelp.hs 79;" f
|
||||||
safeUncons src/ListHelp.hs 72;" f
|
safeUncons src/ListHelp.hs 72;" f
|
||||||
safeUpdateSingleNode src/Dodge/Tree/Polymorphic.hs 92;" f
|
safeUpdateSingleNode src/Dodge/Tree/Polymorphic.hs 92;" f
|
||||||
safeUpdateSingleNode src/TreeHelp.hs 115;" f
|
safeUpdateSingleNode src/TreeHelp.hs 115;" f
|
||||||
@@ -7516,7 +7518,7 @@ unlockInv src/Dodge/Inventory/Lock.hs 9;" f
|
|||||||
unpause src/Dodge/Menu.hs 192;" f
|
unpause src/Dodge/Menu.hs 192;" f
|
||||||
unsafeBlinkAction src/Dodge/Creature/Action/Blink.hs 52;" f
|
unsafeBlinkAction src/Dodge/Creature/Action/Blink.hs 52;" f
|
||||||
unsafeBlinkGun src/Dodge/Item/Weapon/Utility.hs 62;" f
|
unsafeBlinkGun src/Dodge/Item/Weapon/Utility.hs 62;" f
|
||||||
unsafeSwapKeys src/IntMapHelp.hs 73;" f
|
unsafeSwapKeys src/IntMapHelp.hs 76;" f
|
||||||
unshadowBlock src/Dodge/Block.hs 38;" f
|
unshadowBlock src/Dodge/Block.hs 38;" f
|
||||||
untilJust src/MonadHelp.hs 7;" f
|
untilJust src/MonadHelp.hs 7;" f
|
||||||
untilJustCount src/MonadHelp.hs 14;" f
|
untilJustCount src/MonadHelp.hs 14;" f
|
||||||
|
|||||||
Reference in New Issue
Block a user