about summary refs log tree commit diff
path: root/src/Xanthous/Entities/Character.hs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-12-23T04·22-0500
committerGriffin Smith <root@gws.fyi>2019-12-23T04·22-0500
commit6622dd301860765ed16f29f74c9d1348d3aa0d41 (patch)
treec8936207422e9ae884ba73ce0309603b0a6004f8 /src/Xanthous/Entities/Character.hs
parent5b1c7799a76480335f838356ad78bed50715d4c0 (diff)
Add a wield command
Add a Wield command, which prompts for a wieldable item, if any, to take
out of the character's inventory and put in their right hand.

Eventually we should support other hands, but for now hardcoding the
right hand should be fine.
Diffstat (limited to 'src/Xanthous/Entities/Character.hs')
-rw-r--r--src/Xanthous/Entities/Character.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Xanthous/Entities/Character.hs b/src/Xanthous/Entities/Character.hs
index 5ddf33c29434..8a3e7c452082 100644
--- a/src/Xanthous/Entities/Character.hs
+++ b/src/Xanthous/Entities/Character.hs
@@ -20,6 +20,8 @@ module Xanthous.Entities.Character
   , hands
   , leftHand
   , rightHand
+  , inLeftHand
+  , inRightHand
   , doubleHanded
   , wieldedItems
   , WieldedItem(..)
@@ -100,9 +102,15 @@ hands = prism' (uncurry Hands) $ \case
 leftHand :: Traversal' Wielded WieldedItem
 leftHand = hands . _1 . _Just
 
+inLeftHand :: WieldedItem -> Wielded
+inLeftHand wi = Hands (Just wi) Nothing
+
 rightHand :: Traversal' Wielded WieldedItem
 rightHand = hands . _2 . _Just
 
+inRightHand :: WieldedItem -> Wielded
+inRightHand wi = Hands Nothing (Just wi)
+
 doubleHanded :: Prism' Wielded WieldedItem
 doubleHanded = prism' DoubleHanded $ \case
   DoubleHanded i -> Just i