Allow equipment on both wrists
This commit is contained in:
@@ -174,6 +174,9 @@ inventoryA = IM.fromList $ zip [0..]
|
|||||||
testInventory :: IM.IntMap Item
|
testInventory :: IM.IntMap Item
|
||||||
testInventory = IM.fromList $ zip [0..]
|
testInventory = IM.fromList $ zip [0..]
|
||||||
[ makeTypeCraftNum 9 PIPE
|
[ makeTypeCraftNum 9 PIPE
|
||||||
|
, autoSonar
|
||||||
|
, autoRadar
|
||||||
|
, autoRadar
|
||||||
, frontArmour
|
, frontArmour
|
||||||
, flameShield
|
, flameShield
|
||||||
, powerLegs
|
, powerLegs
|
||||||
|
|||||||
@@ -41,49 +41,54 @@ itemEffect cr it w = case it ^? itUse of
|
|||||||
setuhamdown = creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
setuhamdown = creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||||
|
|
||||||
toggleEquipmentAt :: Int -> Item -> Creature -> Creature
|
toggleEquipmentAt :: Int -> Item -> Creature -> Creature
|
||||||
toggleEquipmentAt invid itm cr
|
toggleEquipmentAt invid itm cr = case cr ^? crInvEquipped . ix invid of
|
||||||
| invid `IM.member` _crInvEquipped cr = cr & crInvEquipped . at invid .~ Nothing
|
Just epos -> cr & crInvEquipped . at invid .~ Nothing
|
||||||
& removeEquipmentUsingSite esite
|
& crEquipment . at epos .~ Nothing
|
||||||
& setEquipmentSite esite Nothing'
|
Nothing -> equipUsingSite invid itm cr
|
||||||
| otherwise = cr & crInvEquipped . at invid .~ Just epos
|
|
||||||
& removeEquipmentUsingSite esite
|
equipUsingSite :: Int -> Item -> Creature -> Creature
|
||||||
& setEquipmentSite esite (Just' invid)
|
equipUsingSite invid itm cr = cr
|
||||||
|
& crInvEquipped . at invid .~ Just epos
|
||||||
|
& crEquipment . at epos .~ Just invid
|
||||||
|
& removeOtherEquipment
|
||||||
where
|
where
|
||||||
esite = _eqSite (_itUse itm)
|
epos = eqSiteToPos cr (_eqSite $ _itUse itm)
|
||||||
epos = eqSiteToPos cr esite
|
removeOtherEquipment = case cr ^? crEquipment . ix epos of
|
||||||
f Nothing = Just ()
|
Nothing -> id
|
||||||
f (Just ()) = Nothing
|
Just oid -> crInvEquipped . at oid .~ Nothing
|
||||||
|
|
||||||
eqSiteToPos :: Creature -> EquipSite -> EquipPosition
|
eqSiteToPos :: Creature -> EquipSite -> EquipPosition
|
||||||
eqSiteToPos cr es = case es of
|
eqSiteToPos cr es = case es of
|
||||||
GoesOnHead -> OnHead
|
GoesOnHead -> OnHead
|
||||||
GoesOnChest -> OnChest
|
GoesOnChest -> OnChest
|
||||||
GoesOnBack -> OnBack
|
GoesOnBack -> OnBack
|
||||||
GoesOnWrist -> OnLeftWrist
|
|
||||||
GoesOnLegs -> OnLegs
|
GoesOnLegs -> OnLegs
|
||||||
GoesOnSpecial -> OnSpecial
|
GoesOnSpecial -> OnSpecial
|
||||||
|
GoesOnWrist -> case cr ^? crEquipment . ix OnLeftWrist of
|
||||||
|
Nothing -> OnLeftWrist
|
||||||
|
_ -> OnRightWrist
|
||||||
|
|
||||||
removeEquipmentUsingSite :: EquipSite -> Creature -> Creature
|
removeEquipmentUsingSite :: EquipSite -> Creature -> Creature
|
||||||
removeEquipmentUsingSite esite cr = case esite of
|
removeEquipmentUsingSite esite cr = case esite of
|
||||||
GoesOnSpecial -> cr
|
GoesOnSpecial -> cr
|
||||||
_ -> case cr ^? crEquipment . esiteToPoint . _Just' of
|
_ -> case cr ^? crEquipment . esiteToPoint of
|
||||||
Just invid -> cr & crInvEquipped . at invid .~ Nothing
|
Just invid -> cr & crInvEquipped . at invid .~ Nothing
|
||||||
_ -> cr
|
_ -> cr
|
||||||
where
|
where
|
||||||
esiteToPoint = case esite of
|
esiteToPoint = case esite of
|
||||||
GoesOnHead -> onHead
|
GoesOnHead -> ix OnHead
|
||||||
GoesOnChest -> onChest
|
GoesOnChest -> ix OnChest
|
||||||
GoesOnBack -> onBack
|
GoesOnBack -> ix OnBack
|
||||||
GoesOnWrist -> onWristL
|
GoesOnWrist -> ix OnLeftWrist
|
||||||
GoesOnLegs -> onLegs
|
GoesOnLegs -> ix OnLegs
|
||||||
|
|
||||||
setEquipmentSite :: EquipSite -> Maybe' Int -> Creature -> Creature
|
setEquipmentSite :: EquipSite -> Maybe Int -> Creature -> Creature
|
||||||
setEquipmentSite esite = case esite of
|
setEquipmentSite esite = case esite of
|
||||||
GoesOnHead -> set (crEquipment . onHead)
|
GoesOnHead -> set (crEquipment . at OnHead)
|
||||||
GoesOnChest -> set (crEquipment . onChest)
|
GoesOnChest -> set (crEquipment . at OnChest)
|
||||||
GoesOnBack -> set (crEquipment . onBack)
|
GoesOnBack -> set (crEquipment . at OnBack)
|
||||||
GoesOnWrist -> set (crEquipment . onWristL)
|
GoesOnWrist -> set (crEquipment . at OnLeftWrist)
|
||||||
GoesOnLegs -> set (crEquipment . onLegs)
|
GoesOnLegs -> set (crEquipment . at OnLegs)
|
||||||
GoesOnSpecial -> const id
|
GoesOnSpecial -> const id
|
||||||
|
|
||||||
useLeftItem :: Int -> World -> World
|
useLeftItem :: Int -> World -> World
|
||||||
|
|||||||
+1
-10
@@ -278,7 +278,7 @@ data Creature = Creature
|
|||||||
, _crInvCapacity :: Int
|
, _crInvCapacity :: Int
|
||||||
, _crInvLock :: Bool
|
, _crInvLock :: Bool
|
||||||
, _crInvEquipped :: IM.IntMap EquipPosition
|
, _crInvEquipped :: IM.IntMap EquipPosition
|
||||||
, _crEquipment :: CreatureEquipment
|
, _crEquipment :: M.Map EquipPosition Int
|
||||||
, _crLeftInvSel :: Maybe Int
|
, _crLeftInvSel :: Maybe Int
|
||||||
, _crState :: CreatureState
|
, _crState :: CreatureState
|
||||||
, _crCorpse :: Picture
|
, _crCorpse :: Picture
|
||||||
@@ -297,14 +297,6 @@ data Creature = Creature
|
|||||||
, _crHammerPosition :: HammerPosition
|
, _crHammerPosition :: HammerPosition
|
||||||
, _crName :: String
|
, _crName :: String
|
||||||
}
|
}
|
||||||
data CreatureEquipment = CreatureEquipment
|
|
||||||
{_onHead :: Maybe' Int
|
|
||||||
,_onChest :: Maybe' Int
|
|
||||||
,_onBack :: Maybe' Int
|
|
||||||
,_onWristL :: Maybe' Int
|
|
||||||
,_onWristR :: Maybe' Int
|
|
||||||
,_onLegs :: Maybe' Int
|
|
||||||
}
|
|
||||||
data Vocalization
|
data Vocalization
|
||||||
= Mute
|
= Mute
|
||||||
| Vocalization
|
| Vocalization
|
||||||
@@ -1315,4 +1307,3 @@ makeLenses ''Beam
|
|||||||
makeLenses ''BeamType
|
makeLenses ''BeamType
|
||||||
makeLenses ''WorldBeams
|
makeLenses ''WorldBeams
|
||||||
makeLenses ''ArcStep
|
makeLenses ''ArcStep
|
||||||
makeLenses ''CreatureEquipment
|
|
||||||
|
|||||||
@@ -46,14 +46,7 @@ defaultCreature = Creature
|
|||||||
, _crCorpse = setLayer BottomLayer $ setDepth 5 $ color (greyN 0.5) $ circleSolid 10
|
, _crCorpse = setLayer BottomLayer $ setDepth 5 $ color (greyN 0.5) $ circleSolid 10
|
||||||
, _crApplyDamage = defaultApplyDamage
|
, _crApplyDamage = defaultApplyDamage
|
||||||
, _crPastDamage = 0
|
, _crPastDamage = 0
|
||||||
, _crEquipment = CreatureEquipment
|
, _crEquipment = M.empty
|
||||||
{_onHead = Nothing'
|
|
||||||
,_onChest = Nothing'
|
|
||||||
,_onBack = Nothing'
|
|
||||||
,_onWristL = Nothing'
|
|
||||||
,_onWristR = Nothing'
|
|
||||||
,_onLegs = Nothing'
|
|
||||||
}
|
|
||||||
, _crStance = Stance
|
, _crStance = Stance
|
||||||
{_carriage=Walking 0 WasLeftForward
|
{_carriage=Walking 0 WasLeftForward
|
||||||
,_posture=AtEase
|
,_posture=AtEase
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ autoSonar = defaultEquipment
|
|||||||
, _itEquipPict = \_ _ -> (,) emptySH blank
|
, _itEquipPict = \_ _ -> (,) emptySH blank
|
||||||
, _itEffect = autoSonarEffect
|
, _itEffect = autoSonarEffect
|
||||||
, _itID = Nothing
|
, _itID = Nothing
|
||||||
}
|
} & itUse . eqSite .~ GoesOnWrist
|
||||||
{- |
|
{- |
|
||||||
Automatically sends out pulses that display walls. -}
|
Automatically sends out pulses that display walls. -}
|
||||||
autoRadar :: Item
|
autoRadar :: Item
|
||||||
@@ -71,4 +71,4 @@ autoRadar = defaultEquipment
|
|||||||
, _itEquipPict = \_ _ -> (,) emptySH blank
|
, _itEquipPict = \_ _ -> (,) emptySH blank
|
||||||
, _itEffect = autoRadarEffect
|
, _itEffect = autoRadarEffect
|
||||||
, _itID = Nothing
|
, _itID = Nothing
|
||||||
}
|
} & itUse . eqSite .~ GoesOnWrist
|
||||||
|
|||||||
@@ -134,12 +134,12 @@ subInventoryDisplay subinv cfig w = case subinv of
|
|||||||
|
|
||||||
eqPosText :: EquipPosition -> String
|
eqPosText :: EquipPosition -> String
|
||||||
eqPosText ep = case ep of
|
eqPosText ep = case ep of
|
||||||
OnHead -> "HEAD"
|
OnHead -> "ON HEAD"
|
||||||
OnChest -> "CHEST"
|
OnChest -> "ON CHEST"
|
||||||
OnBack -> "BACK"
|
OnBack -> "ON BACK"
|
||||||
OnLeftWrist -> "L-WRIST"
|
OnLeftWrist -> "ON LEFT WRIST"
|
||||||
OnRightWrist -> "R-WRIST"
|
OnRightWrist -> "ON RIGHT WRIST"
|
||||||
OnLegs -> "LEGS"
|
OnLegs -> "ON LEGS"
|
||||||
OnSpecial -> "EQUIPPED"
|
OnSpecial -> "EQUIPPED"
|
||||||
|
|
||||||
topInvW :: Int
|
topInvW :: Int
|
||||||
|
|||||||
Reference in New Issue
Block a user