Remove yourID -- you are simply at 0
This commit is contained in:
@@ -5,8 +5,7 @@ import qualified IntMapHelp as IM
|
||||
import Control.Lens
|
||||
|
||||
you :: World -> Creature
|
||||
--you w = _creatures (_cWorld w) IM.! _yourID (_cWorld w)
|
||||
you w = w ^?! cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID)
|
||||
you w = w ^?! cWorld . lWorld . creatures . ix 0
|
||||
|
||||
yourItem :: World -> Maybe Item
|
||||
yourItem w = _crInv (you w) IM.!? crSel (you w)
|
||||
|
||||
@@ -51,7 +51,7 @@ itemEffect cr it w = case it ^. itUse of
|
||||
|
||||
tryReload :: Creature -> Item -> World -> (World -> World) -> World -> World
|
||||
tryReload cr it w f
|
||||
| _crID cr == (w ^. cWorld . lWorld . yourID) && itNeedsLoading it && _mouseButtons w M.!? SDL.ButtonLeft == Just False =
|
||||
| _crID cr == 0 && itNeedsLoading it && _mouseButtons w M.!? SDL.ButtonLeft == Just False =
|
||||
crToggleReloading cr
|
||||
| otherwise =
|
||||
(runIdentity . pointerToItemLocation (_itLocation it) (return . (itUse . heldHammer .~ HammerDown)))
|
||||
|
||||
@@ -141,7 +141,6 @@ data LWorld = LWorld
|
||||
, _floorItems :: IM.IntMap FloorItem
|
||||
, _floorTiles :: [(Point3, Point3)]
|
||||
, _modifications :: IM.IntMap Modification
|
||||
, _yourID :: Int
|
||||
, _worldEvents :: [WdWd]
|
||||
, _delayedEvents :: [(Int, WdWd)]
|
||||
, _pressPlates :: IM.IntMap PressPlate
|
||||
|
||||
@@ -111,7 +111,6 @@ defaultLWorld =
|
||||
, _wlZoning = IM.empty --Zoning IM.empty wlZoneSize zoneOfWall
|
||||
, _floorItems = IM.empty
|
||||
, _floorTiles = []
|
||||
, _yourID = 0
|
||||
, _worldEvents = []
|
||||
, _delayedEvents = []
|
||||
, _pressPlates = IM.empty
|
||||
|
||||
+10
-12
@@ -169,7 +169,7 @@ updateCloseObjects :: World -> World
|
||||
updateCloseObjects w =
|
||||
w
|
||||
& cWorld . lWorld . closeObjects .~ unionBy closeObjEq oldCloseFiltered currentClose
|
||||
& cWorld . lWorld . creatures . ix (_yourID (_lWorld (_cWorld w))) . crInvSel . iselPos %~ updateinvsel
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ updateinvsel
|
||||
where
|
||||
updateinvsel curinvsel
|
||||
| length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) - 1
|
||||
@@ -319,16 +319,16 @@ changeInvSel i w
|
||||
| n == 0 = w
|
||||
| yourInvSel w < n =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselAction .~ NoInvSelAction
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselPos %~ ((+ n) . (`mod` numCO) . subtract (i + n))
|
||||
& cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselAction .~ NoInvSelAction
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ ((+ n) . (`mod` numCO) . subtract (i + n))
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
|
||||
where
|
||||
-- arguably this should jump the invpos into the inventory proper
|
||||
|
||||
n = length $ _crInv $ _creatures (_lWorld (_cWorld w)) IM.! _yourID (_lWorld (_cWorld w))
|
||||
n = length $ w ^?! cWorld . lWorld . creatures . ix 0 . crInv
|
||||
numCO = length $ w ^. cWorld . lWorld . closeObjects
|
||||
|
||||
changeSwapInvSel :: Int -> World -> World
|
||||
@@ -336,13 +336,12 @@ changeSwapInvSel k w
|
||||
| n == 0 = w
|
||||
| yourInvSel w < n =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix yid %~ updatecreature
|
||||
& cWorld . lWorld . creatures . ix 0 %~ updatecreature
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix yid . crInvSel . iselPos .~ ico'
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos .~ ico'
|
||||
& cWorld . lWorld . closeObjects %~ swapIndices (i - n) (ico' - n)
|
||||
where
|
||||
yid = w ^. cWorld . lWorld . yourID
|
||||
updatecreature =
|
||||
(crInv %~ IM.safeSwapKeys (i `mod` n) swapi)
|
||||
. (crLeftInvSel . _Just %~ updateLeftInvSel)
|
||||
@@ -369,10 +368,9 @@ changeAugInvSel i w
|
||||
| n == 0 = w
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix yid . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix yid . crInvSel . iselAction .~ NoInvSelAction
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
|
||||
where
|
||||
yid = w ^. cWorld . lWorld . yourID
|
||||
n = length (yourInv w) + length (w ^. cWorld . lWorld . closeObjects)
|
||||
|
||||
bestCloseObjectIndex :: World -> Maybe Int
|
||||
|
||||
@@ -51,5 +51,5 @@ tryPutItemInInv cid flit w = case maybeInvSlot of
|
||||
-- Just j -> w' & itemPositions . ix j .~ InInv cid invid
|
||||
createPutItem :: Item -> World -> (Maybe Int, World)
|
||||
createPutItem it w =
|
||||
uncurry (putItemInInvID (_yourID (_lWorld (_cWorld w)))) $
|
||||
uncurry (putItemInInvID 0) $
|
||||
copyItemToFloorID (_crPos $ you w) (applyModules it) w
|
||||
|
||||
@@ -26,7 +26,7 @@ updateWheelEvent yi w = case w ^. cWorld . lWorld . hud . hudElement of
|
||||
DisplayInventory NoSubInventory
|
||||
-- functions that modify the inventory should be centralised so that
|
||||
-- this lock can be sensibly applied, perhaps
|
||||
| w ^?! cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvLock -> w
|
||||
| w ^?! cWorld . lWorld . creatures . ix 0 . crInvLock -> w
|
||||
| rbDown -> case (yourItem w ^? _Just . itUse . heldScroll, _rbOptions w) of
|
||||
(_, EquipOptions{}) -> scrollRBOption y w
|
||||
(Nothing, _) -> closeObjScrollDir y w
|
||||
@@ -93,7 +93,7 @@ changeTweakParam mi i w = fromMaybe w $ do
|
||||
params <- yourItem w ^? _Just . itTweaks . tweakParams . ix paramid
|
||||
let x = (_tweakVal params + i) `mod` _tweakMax params
|
||||
return $
|
||||
w & cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInv . ix (crSel (you w))
|
||||
w & cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel (you w))
|
||||
%~ ( (itTweaks . tweakParams . ix paramid . tweakVal .~ x)
|
||||
. doTweak (_tweakType params) x
|
||||
)
|
||||
|
||||
@@ -55,7 +55,7 @@ pressedMBEffectsNoInventory pkeys w
|
||||
useItem (you w) w & hammers . ix DoubleMouseHam .~ HammerDown
|
||||
| justPressedDown ButtonLeft && inTopInv
|
||||
&& w ^?! hammers . ix DoubleMouseHam == HammerUp =
|
||||
useLeftItem (w ^. cWorld . lWorld . yourID) w
|
||||
useLeftItem 0 w
|
||||
| isDown ButtonLeft && inTopInv =
|
||||
w & hammers . ix DoubleMouseHam .~ HammerDown
|
||||
| isDown ButtonRight && inTopInv = w
|
||||
@@ -81,10 +81,9 @@ doCombine i w = case combineItemListYou w ^? ix i of
|
||||
-- set (hud . hudElement) (DisplayInventory NoSubInventory)
|
||||
selectinv --enterCombineInv
|
||||
. createPutItem it
|
||||
$ foldr (rmInvItem yid) w (sort is)
|
||||
$ foldr (rmInvItem 0) w (sort is)
|
||||
where
|
||||
yid = w ^. cWorld . lWorld . yourID
|
||||
selectinv (Just i', w') = w' & cWorld . lWorld . creatures . ix yid . crInvSel .~ InvSel i' NoInvSelAction
|
||||
selectinv (Just i', w') = w' & cWorld . lWorld . creatures . ix 0 . crInvSel .~ InvSel i' NoInvSelAction
|
||||
selectinv (Nothing, w') = w'
|
||||
|
||||
updatePressedButtonsCarte :: M.Map MouseButton Bool -> World -> World
|
||||
|
||||
Reference in New Issue
Block a user