Start work on crafting/combinations
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
module Dodge.Combine.Combinations
|
||||
where
|
||||
--import Dodge.Data
|
||||
import Dodge.Combine.Data
|
||||
|
||||
import Data.Bifunctor
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
--import qualified Data.IntSet as IS
|
||||
import qualified Data.Map.Strict as M
|
||||
import Control.Monad
|
||||
import Data.Maybe
|
||||
|
||||
combineList :: IM.IntMap ItemCombineType -> [([Int],ItemCombineType)]
|
||||
combineList m = mapMaybe (pushoutmaybe . second (combine . toMultiset) . unzip)
|
||||
. powlist
|
||||
$ IM.toList m
|
||||
where
|
||||
pushoutmaybe (_,Nothing) = Nothing
|
||||
pushoutmaybe (x,Just y) = Just (x,y)
|
||||
|
||||
powlist :: [a] -> [[a]]
|
||||
powlist = filterM (const [True,False])
|
||||
|
||||
combine :: M.Map ItemCombineType Int -> Maybe ItemCombineType
|
||||
combine m = lookup m combinations
|
||||
|
||||
toMultiset :: Ord a => [a] -> M.Map a Int
|
||||
toMultiset = foldr (uncurry $ M.insertWith (+)) M.empty . map (,1)
|
||||
|
||||
combinations :: [(M.Map ItemCombineType Int, ItemCombineType)]
|
||||
combinations = map (first toMultiset)
|
||||
[ ( [ TPistol, TPipe, THardware ] , TRifle )
|
||||
, ( [ NoCombineType ] , TPistol )
|
||||
, ( [ TRifle, THardware ] , TPistol )
|
||||
, ( [ TPistol, TPistol, THardware ] , TSpreadGun 2 )
|
||||
, ( [ TSpreadGun 2, TPistol, THardware ] , TSpreadGun 3 )
|
||||
, ( [ TSpreadGun 3, TPistol, THardware ] , TSpreadGun 4 )
|
||||
, ( [ TSpreadGun 4, TPistol, THardware ] , TSpreadGun 5 )
|
||||
, ( [ TPistol, TAutoGun, THardware ] , TLtAutoGun )
|
||||
, ( [ TLtAutoGun, TPipe, THardware ] , TAutoGun )
|
||||
, ( [ TRifle, TRifle, THardware ] , TMultGun 2 )
|
||||
, ( [ TMultGun 2, TRifle, THardware ] , TMultGun 3 )
|
||||
, ( [ TMultGun 3, TRifle, THardware ] , TMultGun 4 )
|
||||
, ( [ TMultGun 4, TRifle, THardware ] , TMultGun 5 )
|
||||
, ( [ TLtAutoGun, TPipe, THardware ] , TAutoGun )
|
||||
, ( [ TPistol, TTube, THardware] , TLauncher 1 )
|
||||
, ( [ TLauncher 1, TTube, TPistol, THardware] , TLauncher 2)
|
||||
, ( [ TLauncher 2, TTube, TPistol, THardware] , TLauncher 3)
|
||||
]
|
||||
Reference in New Issue
Block a user