Allow for separate equipment positions on body

This commit is contained in:
2022-05-21 14:41:49 +01:00
parent 398ed6d982
commit 8ad332aced
8 changed files with 69 additions and 10 deletions
+12 -2
View File
@@ -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
+1 -1
View File
@@ -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