Implement combining of items
This commit is contained in:
+33
-3
@@ -1,18 +1,21 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
module Dodge.Combine where
|
||||
import Dodge.Base.You
|
||||
import Dodge.Data
|
||||
--import Dodge.Combine.Data
|
||||
import Dodge.Combine.Combinations
|
||||
import Dodge.Item.Weapon.BulletGuns
|
||||
import Dodge.Item.Craftable
|
||||
|
||||
import Control.Lens
|
||||
import Data.Bifunctor
|
||||
--import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
--import qualified Data.IntSet as IS
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
|
||||
pureCombine :: [ (M.Map CombineType Int, Item) ]
|
||||
pureCombine = map (first toMultiset)
|
||||
itemCombinations :: [ (M.Map CombineType Int, Item) ]
|
||||
itemCombinations = map (first toMultiset)
|
||||
[ p [PIPE,HARDWARE] bangStick
|
||||
, p [LONGPIPE,HARDWARE] bangCane
|
||||
, p [VERYLONGPIPE,HARDWARE] bangRod
|
||||
@@ -21,3 +24,30 @@ pureCombine = map (first toMultiset)
|
||||
]
|
||||
where
|
||||
p = (,)
|
||||
|
||||
combineToItem :: M.Map CombineType Int -> Maybe Item
|
||||
combineToItem m = lookup m itemCombinations
|
||||
|
||||
combineItemList :: IM.IntMap CombineType -> [([Int],Item)]
|
||||
combineItemList m = mapMaybe (pushoutmaybe . second (combineToItem . toMultiset) . unzip)
|
||||
. powlistN 4
|
||||
$ IM.toList m
|
||||
where
|
||||
pushoutmaybe (_,Nothing) = Nothing
|
||||
pushoutmaybe (x,Just y) = Just (x,y)
|
||||
|
||||
combineItemListYou :: World -> [([Int],Item)]
|
||||
combineItemListYou = combineItemList . fmap _itCombineType . yourInv
|
||||
|
||||
combineListYou :: World -> [([Int],CombineType)]
|
||||
combineListYou = combineList . fmap _itCombineType . yourInv
|
||||
|
||||
toggleCombineInv :: World -> World
|
||||
toggleCombineInv w = case _inventoryMode w of
|
||||
CombineInventory _ -> w & inventoryMode .~ TopInventory
|
||||
_ -> w & enterCombineInv
|
||||
|
||||
enterCombineInv :: World -> World
|
||||
enterCombineInv w = w & inventoryMode .~ CombineInventory mi
|
||||
where
|
||||
mi = const 0 <$> listToMaybe (combineListYou w)
|
||||
|
||||
Reference in New Issue
Block a user