Allow to equip left click items
This commit is contained in:
+20
-1
@@ -5,6 +5,8 @@ module Dodge.Inventory
|
||||
, rmInvItem
|
||||
, updateCloseObjects
|
||||
, closeObjScrollDir
|
||||
, swapInvDir
|
||||
, dirInvPos
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
@@ -13,10 +15,10 @@ import Dodge.Base.Collide
|
||||
import Geometry
|
||||
import FoldableHelp
|
||||
import Padding
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
--import Data.Maybe
|
||||
import Data.List
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
--import System.Random
|
||||
import Control.Lens
|
||||
|
||||
@@ -91,3 +93,20 @@ closeObjScrollDir x
|
||||
| x < 0 = over closeActiveObjects rotD
|
||||
| otherwise = id
|
||||
|
||||
swapInvDir :: Int -> World -> World
|
||||
swapInvDir k w = w & creatures . ix (_yourID w) %~ updatecreature
|
||||
where
|
||||
updatecreature = ( crInv %~ IM.swapKeys (i `mod` n) swapi )
|
||||
. (crLeftInvSel . _Just %~ updateLeftInvSel)
|
||||
swapi = (i + k) `mod` n
|
||||
updateLeftInvSel li | i == li = swapi
|
||||
| swapi == li = i
|
||||
| otherwise = li
|
||||
i = _crInvSel $ you w
|
||||
n = length $ IM.keys $ _crInv $ _creatures w IM.! _yourID w
|
||||
|
||||
dirInvPos :: Int -> World -> World
|
||||
dirInvPos i w = w
|
||||
& creatures . ix (_yourID w) . crInvSel %~ (`mod` n) . subtract i
|
||||
where
|
||||
n = length $ IM.keys $ _crInv $ _creatures w IM.! _yourID w
|
||||
|
||||
Reference in New Issue
Block a user