Cleanup menu code, fix reloading crash for nonweapons
This commit is contained in:
@@ -15,13 +15,15 @@ startReloadingWeapon cr = (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr)
|
||||
icTryStartReloading
|
||||
|
||||
icTryStartReloading :: Item -> Maybe Item
|
||||
icTryStartReloading it
|
||||
| _ammoLoaded am < _ammoBaseMax (_itConsumption it) && _reloadState am == Nothing'
|
||||
= Just $ it & itConsumption . reloadState .~ Just' (_reloadTime am)
|
||||
icTryStartReloading it = do
|
||||
am <- it ^? itConsumption
|
||||
amloaded <- am ^? ammoLoaded
|
||||
ammax <- am ^? ammoBaseMax
|
||||
rstate <- am ^? reloadState
|
||||
if amloaded < ammax && rstate == Nothing'
|
||||
then Just $ it & itConsumption . reloadState .~ Just' (_reloadTime am)
|
||||
& if _reloadType am == ActiveClear then itConsumption . ammoLoaded .~ 0 else id
|
||||
| otherwise = Nothing
|
||||
where
|
||||
am = _itConsumption it
|
||||
else Nothing
|
||||
|
||||
crStopReloading :: Creature -> Creature
|
||||
crStopReloading cr = cr & crInv . ix (_crInvSel cr) . itConsumption . reloadState .~ Nothing'
|
||||
|
||||
Reference in New Issue
Block a user