Allow for separate equipment positions on body
This commit is contained in:
@@ -42,17 +42,27 @@ itemEffect cr it w = case it ^? itUse of
|
||||
|
||||
toggleEquipmentAt :: Int -> Item -> Creature -> Creature
|
||||
toggleEquipmentAt invid itm cr
|
||||
| invid `IS.member` _crInvEquipped cr = cr & crInvEquipped . at invid .~ Nothing
|
||||
| invid `IM.member` _crInvEquipped cr = cr & crInvEquipped . at invid .~ Nothing
|
||||
& removeEquipmentUsingSite esite
|
||||
& setEquipmentSite esite Nothing'
|
||||
| otherwise = cr & crInvEquipped . at invid .~ Just ()
|
||||
| otherwise = cr & crInvEquipped . at invid .~ Just epos
|
||||
& removeEquipmentUsingSite esite
|
||||
& setEquipmentSite esite (Just' invid)
|
||||
where
|
||||
esite = _eqSite (_itUse itm)
|
||||
epos = eqSiteToPos cr esite
|
||||
f Nothing = Just ()
|
||||
f (Just ()) = Nothing
|
||||
|
||||
eqSiteToPos :: Creature -> EquipSite -> EquipPosition
|
||||
eqSiteToPos cr es = case es of
|
||||
GoesOnHead -> OnHead
|
||||
GoesOnChest -> OnChest
|
||||
GoesOnBack -> OnBack
|
||||
GoesOnWrist -> OnLeftWrist
|
||||
GoesOnLegs -> OnLegs
|
||||
GoesOnSpecial -> OnSpecial
|
||||
|
||||
removeEquipmentUsingSite :: EquipSite -> Creature -> Creature
|
||||
removeEquipmentUsingSite esite cr = case esite of
|
||||
GoesOnSpecial -> cr
|
||||
|
||||
@@ -153,7 +153,7 @@ useEquipment cr i = _eqUse (_itUse $ _crInv cr IM.! i) cr i
|
||||
|
||||
invSideEff :: Creature -> World -> World
|
||||
invSideEff cr w = weaponReloadSounds cr
|
||||
. flip (IS.foldr $ useEquipment cr) (_crInvEquipped cr)
|
||||
. flip (foldr $ useEquipment cr) (IM.keys $ _crInvEquipped cr)
|
||||
$ IM.foldrWithKey f w (_crInv cr)
|
||||
where
|
||||
f i it w' = doitemupdate w' & case it ^? itEffect . itInvEffect of
|
||||
|
||||
Reference in New Issue
Block a user