Fix aiming with no weapon crash
This commit is contained in:
@@ -31,15 +31,15 @@ combinationsTrie = foldr (uncurry insertInTrie . first (sortOn snd))
|
||||
-- trie going through each combine type in your inventory in order, rather than
|
||||
-- creating all multisets of combine types.
|
||||
|
||||
lookupItems' :: [(CombineType,Int,Int)] -> [ ([Int],Item) ]
|
||||
lookupItems' xs = lookupItems (sortOn (\(ct,_,_) -> ct) xs) combinationsTrie
|
||||
lookupItems :: [(CombineType,Int,Int)] -> [ ([Int],Item) ]
|
||||
lookupItems xs = lookupItemsUsingTrie (sortOn (\(ct,_,_) -> ct) xs) combinationsTrie
|
||||
|
||||
lookupItems :: [(CombineType,Int,Int)] -> Trie (Int,CombineType) Item -> [ ([Int],Item) ]
|
||||
lookupItems [] t = maybeToList $ ([],) <$> _trieMVal t
|
||||
lookupItems ((ct,i,n):xs) t = do
|
||||
lookupItemsUsingTrie :: [(CombineType,Int,Int)] -> Trie (Int,CombineType) Item -> [ ([Int],Item) ]
|
||||
lookupItemsUsingTrie [] t = maybeToList $ ([],) <$> _trieMVal t
|
||||
lookupItemsUsingTrie ((ct,i,n):xs) t = do
|
||||
n' <- [1..min n 4]
|
||||
let is = replicate n' i
|
||||
concatMap (map (first (is ++)) . lookupItems xs) $ maybeToList (_trieChildren t M.!? (n',ct))
|
||||
concatMap (map (first (is ++)) . lookupItemsUsingTrie xs) $ maybeToList (_trieChildren t M.!? (n',ct))
|
||||
|
||||
invertListInvMult :: IM.IntMap Item -> [[(CombineType,Int,Int)]]
|
||||
invertListInvMult = powlistUpToN 4 . invertListInv
|
||||
@@ -50,7 +50,7 @@ invertListInv = IM.foldrWithKey
|
||||
[]
|
||||
|
||||
combineItemListYou :: World -> [([Int],Item)]
|
||||
combineItemListYou = concatMap lookupItems' . invertListInvMult . yourInv
|
||||
combineItemListYou = concatMap lookupItems . invertListInvMult . yourInv
|
||||
|
||||
toggleCombineInv :: World -> World
|
||||
toggleCombineInv w = case _inventoryMode w of
|
||||
|
||||
Reference in New Issue
Block a user