Commit before door refactor

This commit is contained in:
2022-06-23 09:30:46 +01:00
parent ee47ee8e95
commit 8e3f03637d
11 changed files with 76 additions and 17 deletions
+9
View File
@@ -40,10 +40,18 @@ itemDisplay it = itemDisplayWithNumber (showConsumption (_itConsumption it)) it
showSelectedConsumption :: Creature -> ItemConsumption -> String
showSelectedConsumption cr ic = case ic of
LoadableAmmo{} -> showReloadProgress cr ic
AutoRecharging {} -> showAutoRechargeProgress ic
ChargeableAmmo{} -> show $ _wpCharge ic
ItemItselfConsumable{} -> show (_icAmount ic)
NoConsumption -> ""
showAutoRechargeProgress :: ItemConsumption -> String
showAutoRechargeProgress ic
| l < _arMax ic = show (_arProgress ic) ++ "C" ++ show l
| otherwise = show l
where
l = _arLoaded ic
showReloadProgress :: Creature -> ItemConsumption -> String
showReloadProgress cr ic = case cr ^?! crInvSel . iselAction of
ReloadAction i la _ -> show i ++ showLoadActionType la (_laLoaded ic)
@@ -59,6 +67,7 @@ showLoadProgress x mlas = case mlas ^? _Just . ix 0 of
showConsumption :: ItemConsumption -> String
showConsumption ic = case ic of
LoadableAmmo{} -> showLoadProgress (_laLoaded ic) (_laProgress ic)
AutoRecharging {} -> showAutoRechargeProgress ic
ChargeableAmmo{} -> show $ _wpCharge ic
ItemItselfConsumable{} -> show (_icAmount ic)
NoConsumption -> ""
+5 -4
View File
@@ -145,6 +145,8 @@ ammoHammerCheck eff it cr w
setHammerDown = creatures . ix cid . crInv . ix (crSel cr) . itUse
. useHammer . hammerPosition .~ HammerDown
itUseCharge :: Int -> Item -> Item
itUseCharge x = itConsumption . arLoaded %~ (max 0 . subtract x)
itUseAmmo :: Int -> Item -> Item
itUseAmmo x = itConsumption . laLoaded %~ (max 0 . subtract x)
@@ -353,7 +355,7 @@ shootL
-> World
shootL f item cr w
| fireCondition = f item cr w & pointerToItem %~
( itUseAmmo 1
( itUseCharge 1
. (itUse . useDelay . rateTime .~ _rateMax (_useDelay (_itUse item))) )
-- | reloadCondition = fromMaybe w $ startReloadingWeapon cr w
| otherwise = w
@@ -361,9 +363,8 @@ shootL f item cr w
cid = _crID cr
invid = fromJust $ _itInvPos item
pointerToItem = creatures . ix cid . crInv . ix invid
fireCondition = crWeaponReady cr
&& _rateTime (_useDelay (_itUse item)) == 0
&& _laLoaded (_itConsumption item) > 0
fireCondition = _rateTime (_useDelay (_itUse item)) == 0
&& _arLoaded (_itConsumption item) > 0
-- reloadCondition = _laLoaded (_itConsumption item) == 0
withItem :: (Item -> ChainEffect) -> ChainEffect
withItem g f it = g it f it