about summary refs log tree commit diff
path: root/src/Xanthous/Entities/Character.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xanthous/Entities/Character.hs')
-rw-r--r--src/Xanthous/Entities/Character.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Xanthous/Entities/Character.hs b/src/Xanthous/Entities/Character.hs
index 955c94fc77c4..43d4f8a52942 100644
--- a/src/Xanthous/Entities/Character.hs
+++ b/src/Xanthous/Entities/Character.hs
@@ -27,6 +27,7 @@ module Xanthous.Entities.Character
   , WieldedItem(..)
   , wieldedItem
   , wieldableItem
+  , asWieldedItem
 
     -- *
   , mkCharacter
@@ -68,6 +69,12 @@ data WieldedItem = WieldedItem
            WieldedItem
 makeFieldsNoPrefix ''WieldedItem
 
+asWieldedItem :: Prism' Item WieldedItem
+asWieldedItem = prism' hither yon
+ where
+   yon item = WieldedItem item <$> item ^. itemType . wieldable
+   hither (WieldedItem item _) = item
+
 instance Brain WieldedItem where
   step ticks (Positioned p wi) =
     over positioned (\i -> WieldedItem i $ wi ^. wieldableItem)