Allow equipment on both wrists
This commit is contained in:
@@ -41,49 +41,54 @@ itemEffect cr it w = case it ^? itUse of
|
||||
setuhamdown = creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||
|
||||
toggleEquipmentAt :: Int -> Item -> Creature -> Creature
|
||||
toggleEquipmentAt invid itm cr
|
||||
| invid `IM.member` _crInvEquipped cr = cr & crInvEquipped . at invid .~ Nothing
|
||||
& removeEquipmentUsingSite esite
|
||||
& setEquipmentSite esite Nothing'
|
||||
| otherwise = cr & crInvEquipped . at invid .~ Just epos
|
||||
& removeEquipmentUsingSite esite
|
||||
& setEquipmentSite esite (Just' invid)
|
||||
toggleEquipmentAt invid itm cr = case cr ^? crInvEquipped . ix invid of
|
||||
Just epos -> cr & crInvEquipped . at invid .~ Nothing
|
||||
& crEquipment . at epos .~ Nothing
|
||||
Nothing -> equipUsingSite invid itm cr
|
||||
|
||||
equipUsingSite :: Int -> Item -> Creature -> Creature
|
||||
equipUsingSite invid itm cr = cr
|
||||
& crInvEquipped . at invid .~ Just epos
|
||||
& crEquipment . at epos .~ Just invid
|
||||
& removeOtherEquipment
|
||||
where
|
||||
esite = _eqSite (_itUse itm)
|
||||
epos = eqSiteToPos cr esite
|
||||
f Nothing = Just ()
|
||||
f (Just ()) = Nothing
|
||||
epos = eqSiteToPos cr (_eqSite $ _itUse itm)
|
||||
removeOtherEquipment = case cr ^? crEquipment . ix epos of
|
||||
Nothing -> id
|
||||
Just oid -> crInvEquipped . at oid .~ Nothing
|
||||
|
||||
eqSiteToPos :: Creature -> EquipSite -> EquipPosition
|
||||
eqSiteToPos cr es = case es of
|
||||
GoesOnHead -> OnHead
|
||||
GoesOnChest -> OnChest
|
||||
GoesOnBack -> OnBack
|
||||
GoesOnWrist -> OnLeftWrist
|
||||
GoesOnLegs -> OnLegs
|
||||
GoesOnSpecial -> OnSpecial
|
||||
GoesOnWrist -> case cr ^? crEquipment . ix OnLeftWrist of
|
||||
Nothing -> OnLeftWrist
|
||||
_ -> OnRightWrist
|
||||
|
||||
removeEquipmentUsingSite :: EquipSite -> Creature -> Creature
|
||||
removeEquipmentUsingSite esite cr = case esite of
|
||||
GoesOnSpecial -> cr
|
||||
_ -> case cr ^? crEquipment . esiteToPoint . _Just' of
|
||||
_ -> case cr ^? crEquipment . esiteToPoint of
|
||||
Just invid -> cr & crInvEquipped . at invid .~ Nothing
|
||||
_ -> cr
|
||||
where
|
||||
esiteToPoint = case esite of
|
||||
GoesOnHead -> onHead
|
||||
GoesOnChest -> onChest
|
||||
GoesOnBack -> onBack
|
||||
GoesOnWrist -> onWristL
|
||||
GoesOnLegs -> onLegs
|
||||
GoesOnHead -> ix OnHead
|
||||
GoesOnChest -> ix OnChest
|
||||
GoesOnBack -> ix OnBack
|
||||
GoesOnWrist -> ix OnLeftWrist
|
||||
GoesOnLegs -> ix OnLegs
|
||||
|
||||
setEquipmentSite :: EquipSite -> Maybe' Int -> Creature -> Creature
|
||||
setEquipmentSite :: EquipSite -> Maybe Int -> Creature -> Creature
|
||||
setEquipmentSite esite = case esite of
|
||||
GoesOnHead -> set (crEquipment . onHead)
|
||||
GoesOnChest -> set (crEquipment . onChest)
|
||||
GoesOnBack -> set (crEquipment . onBack)
|
||||
GoesOnWrist -> set (crEquipment . onWristL)
|
||||
GoesOnLegs -> set (crEquipment . onLegs)
|
||||
GoesOnHead -> set (crEquipment . at OnHead)
|
||||
GoesOnChest -> set (crEquipment . at OnChest)
|
||||
GoesOnBack -> set (crEquipment . at OnBack)
|
||||
GoesOnWrist -> set (crEquipment . at OnLeftWrist)
|
||||
GoesOnLegs -> set (crEquipment . at OnLegs)
|
||||
GoesOnSpecial -> const id
|
||||
|
||||
useLeftItem :: Int -> World -> World
|
||||
|
||||
Reference in New Issue
Block a user