diff options
author | Griffin Smith <root@gws.fyi> | 2019-12-23T03·46-0500 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-12-23T03·46-0500 |
commit | 5b1c7799a76480335f838356ad78bed50715d4c0 (patch) | |
tree | 65c9e863e31da7400bba1c11770d06ed69e9b2b3 /src/Xanthous/App.hs | |
parent | 0f754eb2a07062e8490ae3af04e7c7ff4d94cc55 (diff) |
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.
Diffstat (limited to 'src/Xanthous/App.hs')
-rw-r--r-- | src/Xanthous/App.hs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Xanthous/App.hs b/src/Xanthous/App.hs index f663186a308d..c7d9e3935e0a 100644 --- a/src/Xanthous/App.hs +++ b/src/Xanthous/App.hs @@ -143,8 +143,8 @@ handleCommand PickUp = do uses entities (entitiesAtPositionWithType @Item pos) >>= \case [] -> say_ ["pickUp", "nothingToPickUp"] [item] -> pickUpItem item - items -> - menu_ ["pickUp", "menu"] Cancellable (entityMenu_ items) + items' -> + menu_ ["pickUp", "menu"] Cancellable (entityMenu_ items') $ \(MenuResult item) -> pickUpItem item continue where @@ -185,7 +185,7 @@ handleCommand Look = do handleCommand Wait = stepGame >> continue handleCommand Eat = do - uses (character . inventory) + uses (character . inventory . backpack) (V.mapMaybe (\item -> (item,) <$> item ^. Item.itemType . edible)) >>= \case Empty -> say_ ["eat", "noFood"] @@ -197,7 +197,7 @@ handleCommand Eat = do menuItems = mkMenuItems $ imap foodMenuItem food in menu_ ["eat", "menuPrompt"] Cancellable menuItems $ \(MenuResult (idx, item, edibleItem)) -> do - character . inventory %= \inv -> + character . inventory . backpack %= \inv -> let (before, after) = V.splitAt idx inv in before <> fromMaybe Empty (tailMay after) let msg = fromMaybe (Messages.lookup ["eat", "eat"]) @@ -231,7 +231,7 @@ handleCommand Read = do in readAndContinue msgs continue -handleCommand Inventory = showPanel InventoryPanel >> continue +handleCommand ShowInventory = showPanel InventoryPanel >> continue handleCommand Save = do -- TODO default save locations / config file? @@ -280,8 +280,8 @@ handlePromptEvent _ (Prompt _ SDirectionPrompt _ _ _) _ = continue handlePromptEvent _ (Prompt _ SContinue _ _ _) _ = continue -handlePromptEvent _ (Prompt _ SMenu _ items cb) (VtyEvent (EvKey (KChar chr) [])) - | Just (MenuOption _ res) <- items ^. at chr +handlePromptEvent _ (Prompt _ SMenu _ items' cb) (VtyEvent (EvKey (KChar chr) [])) + | Just (MenuOption _ res) <- items' ^. at chr = cb (MenuResult res) >> clearPrompt | otherwise = continue @@ -350,9 +350,9 @@ menu :: forall (a :: Type) (params :: Type). -> Map Char (MenuOption a) -- ^ Menu items -> (PromptResult ('Menu a) -> AppM ()) -- ^ Menu promise handler -> AppM () -menu msgPath params cancellable items cb = do +menu msgPath params cancellable items' cb = do msg <- Messages.message msgPath params - let p = mkMenu cancellable items cb + let p = mkMenu cancellable items' cb promptState .= WaitingPrompt msg p menu_ :: forall (a :: Type). @@ -419,7 +419,8 @@ attackAt pos = say ["combat", "killed"] msgParams entities . at creatureID .= Nothing else do - say ["combat", "hit"] msgParams + -- TODO attack messages + say ["combat", "hit", "generic"] msgParams entities . ix creatureID . positioned .= SomeEntity creature' stepGame -- TODO |