Start work on crafting/combinations

This commit is contained in:
2021-12-02 00:50:29 +00:00
parent ce06845278
commit 85ededc158
28 changed files with 189 additions and 112 deletions
+14
View File
@@ -3,6 +3,7 @@ import Dodge.Data
import Dodge.Base
--import qualified Data.IntMap.Strict as IM
import Data.Maybe
import Control.Lens
startReloadingWeapon :: Creature -> World -> Maybe World
@@ -34,3 +35,16 @@ stepReloading cr = case cr ^? crInv . ix isel . itConsumption . reloadState . _J
& reloadState .~ Nothing'
_ -> itcon & ammoLoaded .~ _ammoMax itcon
& reloadState .~ Nothing'
{- | Start reloading if clip is empty. -}
crAutoReload :: Creature -> Creature
crAutoReload cr = case cr ^? ptrItConsumption' . ammoLoaded of
Just 0 | _posture (_crStance cr) /= Aiming
-> cr & ptrItConsumption . reloadState .~ strictify reloadT
& ptrItConsumption . ammoLoaded %~ (`fromMaybe` maxA)
_ -> cr
where
ptrItConsumption = crInv . ix (_crInvSel cr) . itConsumption
ptrItConsumption' = crInv . ix (_crInvSel cr) . itConsumption
reloadT = cr ^? ptrItConsumption' . reloadTime
maxA = cr ^? ptrItConsumption' . ammoMax