Refactor inventory management, add tweak, combine and inspect modes

This commit is contained in:
jgk
2021-05-26 17:25:46 +02:00
parent f05381be47
commit 0187ae6001
13 changed files with 323 additions and 233 deletions
+6 -10
View File
@@ -10,16 +10,6 @@ import qualified Data.IntMap.Strict as IM
--import System.Random
import Control.Lens
checkInvSlotsYou' :: Maybe Item -> World -> Maybe Int
checkInvSlotsYou' it w = fst <$> find cond invListSelFirst
where
cond (_,NoItem) = True
cond (_,it' ) = itNotFull it' && fmap _itName it == Just (_itName it')
youCr = you w
youSel = _crInvSel youCr
invList = _crInv youCr
invListSelFirst = (youSel , invList IM.! youSel) : IM.toList invList
checkInvSlotsYou :: Item -> World -> Maybe Int
checkInvSlotsYou it w = fst <$> find cond invListSelFirst
where
@@ -93,6 +83,12 @@ updateCloseObjects w = w & closeActiveObjects .~ unionBy eTest oldCloseFiltered
oldClose = filt $ _closeActiveObjects w
oldCloseFiltered = intersectBy eTest oldClose currentClose
closeObjScrollDir :: Float -> World -> World
closeObjScrollDir x
| x > 0 = closeObjScrollUp
| x < 0 = closeObjScrollDown
| otherwise = id
closeObjScrollUp :: World -> World
closeObjScrollUp = over closeActiveObjects rotU
where rotU [] = []