From 5b1c7799a76480335f838356ad78bed50715d4c0 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 22 Dec 2019 22:46:43 -0500 Subject: Add wielded, wieldable items Split the character's inventory up into wielded items (in one or both hands) and the backpack, and display wielded items when drawing the inventory panel. Currently there's no way to actually *wield* items though, so this is all unused/untested. Also, add the ability for items to be "wieldable", which gives specific descriptions for when attacking with them and also modified damage. --- src/Xanthous/Game/Draw.hs | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'src/Xanthous/Game/Draw.hs') diff --git a/src/Xanthous/Game/Draw.hs b/src/Xanthous/Game/Draw.hs index e2390c47bf15..09015d06884f 100644 --- a/src/Xanthous/Game/Draw.hs +++ b/src/Xanthous/Game/Draw.hs @@ -14,6 +14,7 @@ import Xanthous.Data.EntityMap (EntityMap, atPosition) import qualified Xanthous.Data.EntityMap as EntityMap import Xanthous.Game.State import Xanthous.Entities.Character +import Xanthous.Entities.Item (Item) import Xanthous.Game ( GameState(..) , entities @@ -105,16 +106,36 @@ drawPanel game panel . viewport (Resource.Panel panel) Vertical $ case panel of InventoryPanel -> - let items = game ^. character . inventory - in if null items - then txtWrap "Your inventory is empty right now." - else - txtWrap "You are currently carrying the following items:" - <=> txt " " - <=> foldl' (<=>) emptyWidget - (map - (txtWrap . ((bullet <| " ") <>) . description) - items) + drawWielded (game ^. character . inventory . wielded) + <=> drawBackpack (game ^. character . inventory . backpack) + where + drawWielded :: Wielded -> Widget Name + drawWielded (Hands Nothing Nothing) = emptyWidget + drawWielded (DoubleHanded i) = + txt $ "You are holding " <> description i <> " in both hands" + drawWielded (Hands l r) = + maybe + emptyWidget + (\i -> + txt $ "You are holding " <> description i <> " in your left hand") + l + <=> + maybe + emptyWidget + (\i -> + txt $ "You are holding " <> description i <> " in your right hand") + r + + drawBackpack :: Vector Item -> Widget Name + drawBackpack Empty = txtWrap "Your backpack is empty right now." + drawBackpack backpackItems + = txtWrap ( "You are currently carrying the following items in your " + <> "backpack:") + <=> txt " " + <=> foldl' (<=>) emptyWidget + (map + (txtWrap . ((bullet <| " ") <>) . description) + backpackItems) drawCharacterInfo :: Character -> Widget Name drawCharacterInfo ch = txt " " <+> charName <+> charHitpoints -- cgit 1.4.1