Add key card item lock/key system
This commit is contained in:
@@ -15,9 +15,7 @@ useItem cr' w = fromMaybe (f w) $ do
|
||||
it <- cr ^? crInv . ix (_crInvSel cr)
|
||||
return $ itemEffect cr it w
|
||||
where
|
||||
f = case _crID cr' of
|
||||
0 -> youHammerPosition .~ HammerDown
|
||||
_ -> id
|
||||
f = creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
|
||||
itemEffect :: Creature -> Item -> World -> World
|
||||
itemEffect cr it w = case it ^? itUse of
|
||||
@@ -30,19 +28,17 @@ itemEffect cr it w = case it ^? itUse of
|
||||
Just NoUse -> setuhamdown w
|
||||
Nothing -> setuhamdown w
|
||||
where
|
||||
hammerTest f = case _youHammerPosition w of
|
||||
hammerTest f = case _crHammerPosition cr of
|
||||
HammerUp -> f w
|
||||
_ -> w & youHammerPosition .~ HammerDown
|
||||
lhammer f' = w & case _youHammerPosition w of
|
||||
_ -> w & setuhamdown
|
||||
lhammer f' = w & case _crHammerPosition cr of
|
||||
HammerUp -> creatures . ix (_crID cr) %~ f'
|
||||
_ -> id
|
||||
setEquipLeftItem cr' = case _crLeftInvSel cr' of
|
||||
Just i | i == _crInvSel cr' -> cr' & crLeftInvSel .~ Nothing
|
||||
_ -> cr' & crLeftInvSel ?~ _crInvSel cr'
|
||||
setEquipment = toggleEquipmentAt (_crInvSel cr)
|
||||
setuhamdown = case _crID cr of
|
||||
0 -> youHammerPosition .~ HammerDown
|
||||
_ -> id
|
||||
setuhamdown = creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||
|
||||
toggleEquipmentAt :: Int -> Creature -> Creature
|
||||
toggleEquipmentAt invid cr = cr & crInvEquipped . at invid %~ f
|
||||
|
||||
@@ -17,6 +17,7 @@ import Dodge.RandomHelp
|
||||
import Dodge.WorldEvent
|
||||
--import Dodge.WallCreatureCollisions
|
||||
import Dodge.Creature.Action
|
||||
--import Dodge.Hammer
|
||||
import Geometry
|
||||
import Picture
|
||||
import qualified IntMapHelp as IM
|
||||
@@ -51,9 +52,10 @@ stateUpdateDamage :: (Creature -> Creature)
|
||||
-- -> CRUpdate
|
||||
-> Creature -> World -> World
|
||||
stateUpdateDamage damageupdate u cr w = case u (updateMovement cr) w of
|
||||
(f, upcr) -> invSideEff upcr . movementSideEff cr . deathEff . f $ w
|
||||
(f, upcr) -> mvcrhammerup . invSideEff upcr . movementSideEff cr . deathEff . f $ w
|
||||
& creatures . at (_crID cr) .~ (stepReloading . damageupdate <$> crOrCorpse upcr)
|
||||
where
|
||||
where
|
||||
mvcrhammerup = creatures . ix (_crID cr) . crHammerPosition %~ moveHammerUp
|
||||
crOrCorpse cr'
|
||||
| cr' ^. crHP > 0 = Just cr'
|
||||
| otherwise = Nothing
|
||||
|
||||
Reference in New Issue
Block a user