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
|
||||
|
||||
Reference in New Issue
Block a user