From 14de40e0bff9e65a912d9cb837069951fbeccf1b Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 21 May 2022 22:14:50 +0100 Subject: [PATCH] Bugfix and cleanup --- src/Dodge/Item/Consumable.hs | 2 +- src/Dodge/Item/Draw.hs | 31 ++++++++++--------------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/Dodge/Item/Consumable.hs b/src/Dodge/Item/Consumable.hs index ccf3a7d06..e99557461 100644 --- a/src/Dodge/Item/Consumable.hs +++ b/src/Dodge/Item/Consumable.hs @@ -18,7 +18,7 @@ medkit i = defaultConsumable , _itUse = ConsumeUse {_cUse = \_ cr w -> w & creatures . ix (_crID cr) . crHP +~ i } - , _itEquipPict = pictureItem $ (,) emptySH $ color blue $ circleSolid 3 + , _itEquipPict = pictureWeaponAim $ const $ (,) emptySH $ color blue $ circleSolid 3 , _itID = Nothing } diff --git a/src/Dodge/Item/Draw.hs b/src/Dodge/Item/Draw.hs index 280583e3c..fe37a9433 100644 --- a/src/Dodge/Item/Draw.hs +++ b/src/Dodge/Item/Draw.hs @@ -23,14 +23,13 @@ itSPic it = _dimSPic (_itDimension it) it pictureWeaponAim :: (Item -> SPic) -> Creature - -> Item -- ^ Position of item in inventory + -> Item -> SPic -pictureWeaponAim = const ---pictureWeaponAim f cr itm = pictureWeaponOnAimItem pic cr i --- where --- pic = f itm --- i = fromJust $ _itInvPos itm - --pic = f (_crInv cr IM.! i) +pictureWeaponAim f cr itm = case _itInvPos itm of + Just i -> pictureWeaponOnAimItem pic cr i + Nothing -> mempty + where + pic = f itm {- | Places an item picture onto a creature when the item is selected. -} pictureWeaponOnAimItem @@ -66,6 +65,7 @@ pictureWeaponOnAimItem p' cr posInInv x <- theIt ^? itDimension . dimPortage . handlePos return $translateSPf (-x) 0 p' isOneHand = theIt ^? itUseAimStance == Just OneHand + || isNothing (theIt ^? itUseAimStance) isTwoHandFlat = theIt ^? itUseAimStance == Just TwoHandFlat itUseAimStance = itUse . useAim . aimStance f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen @@ -74,23 +74,12 @@ pictureWeaponOnAimItem p' cr posInInv strideRot :: Creature -> Float strideRot cr = case cr ^? crStance . carriage of - Just (Walking x LeftForward) -> f x - Just (Walking x RightForward) -> - f x - _ -> 0 + Just (Walking x LeftForward) -> f x + Just (Walking x RightForward) -> - f x + _ -> 0 where f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen sLen = _strideLength $ _crStance cr twoFlatHRot :: Creature -> Float twoFlatHRot cr = 2*strideRot cr - -pictureItem - :: SPic - -> Creature - -> Item -- ^ Position of item in inventory - -> SPic -pictureItem p cr itm = case _itInvPos itm of - Just posInInv | _crInvSel cr == posInInv -> drawnWep - _ -> emptyBlank - where - drawnWep = translateSPf (_crRad cr) 0 p