Cleanup
This commit is contained in:
@@ -29,23 +29,23 @@ import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import Data.List (scanl',sortOn)
|
||||
|
||||
invertInventory :: IM.IntMap Item -> [(ItemBaseType,IcAmount,Int)]
|
||||
invertInventory :: IM.IntMap Item -> [(ItemBaseType,ItAmount,Int)]
|
||||
invertInventory = IM.foldrWithKey
|
||||
(\k it -> ((_iyBase $ _itType it, itStackAmount it,k) :) )
|
||||
[]
|
||||
|
||||
splitIcAmounts :: [(ItemBaseType,IcAmount,Int)] -> [((IcAmount,ItemBaseType),(IcAmount,Int))]
|
||||
splitIcAmounts = concatMap f
|
||||
splitItAmounts :: [(ItemBaseType,ItAmount,Int)] -> [((ItAmount,ItemBaseType),(ItAmount,Int))]
|
||||
splitItAmounts = concatMap f
|
||||
where
|
||||
f (x,n,y) = [((i,x),(i,y)) | i <- [1..n]]
|
||||
|
||||
lookupItems :: IM.IntMap Item -> [([(IcAmount,Int)],Item)]
|
||||
lookupItems = flip multiLookupTrieI combinationsTrie . sortOn fst . splitIcAmounts . invertInventory
|
||||
lookupItems :: IM.IntMap Item -> [([(ItAmount,Int)],Item)]
|
||||
lookupItems = flip multiLookupTrieI combinationsTrie . sortOn fst . splitItAmounts . invertInventory
|
||||
|
||||
combineItemListYouX :: World -> [([Int],Item)]
|
||||
combineItemListYouX = map (first $ concatMap g) . lookupItems . yourInv
|
||||
where
|
||||
g (amount,i) = replicate (_toInt amount) i
|
||||
g (amount,i) = replicate (_getItAmount amount) i
|
||||
|
||||
combineListInfo :: World -> [([Int],([String],Item))]
|
||||
combineListInfo w = filter (f . snd . snd) . map (cmm inv) $ combineItemListYouX w
|
||||
|
||||
Reference in New Issue
Block a user