Implement copier, an item that copies the value displayed by other items

This commit is contained in:
2025-01-08 14:29:25 +00:00
parent 47aa8655b1
commit 21b7b863c7
12 changed files with 184 additions and 142 deletions
+19 -4
View File
@@ -1,13 +1,17 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.ItEffect (
doInvEffect,
) where
import Dodge.BlBl
import Dodge.Item.Location
import Control.Lens
import Data.Maybe
import Dodge.BlBl
import Dodge.Data.World
import Dodge.Euse
import Dodge.Inventory.Path
import Dodge.Inventory.SelectionList
import Dodge.Item.Location
doInvEffect :: ItInvEffect -> Item -> Creature -> World -> World
doInvEffect = \case
@@ -17,9 +21,20 @@ doInvEffect = \case
RemoveShieldWall -> removeShieldWall
EffectWhileRoot f -> rootNotrootEff f NoInvEffect
EffectWhileAttached f -> effectWhileAttached f
ItemUseToggle f -> \itm _
-> pointerToItemID (itm ^. itID) . itUse . useToggle %~ doBlBl f
ItemUseToggle f -> \itm _ ->
pointerToItemID (itm ^. itID) . itUse . useToggle %~ doBlBl f
ItemCancelExamineInventory -> \_ _ -> cancelExamineInventory
ItemCopierUpdate -> copierItemUpdate
copierItemUpdate :: Item -> Creature -> World -> World
copierItemUpdate itm cr w = fromMaybe w $ do
x <- itm ^? itScroll . itsInt
invid <- itm ^? itLocation . ilInvID
ip <- itm ^? itType . ibtPathing
i <- getInventoryPath x ip invid cr
itm' <- cr ^? crInv . ix i
v <- getItemValue itm' w cr
return $ w & pointerToItem itm . itUse . uValue .~ v
cancelExamineInventory :: World -> World
cancelExamineInventory = hud . hudElement . subInventory %~ f