uchicago-cs/chiventure

Implement a new action "view inventory"

Closed this issue · 6 comments

Our goal here is to allow the user to view the names of the items in their inventory. This way, when the player takes an item (i.e. table), they can view this new item in their inventory.

In order to implement this, we would have to create a display inventory function in the game-state/player module that we can call from the action_management/actionmanagement module. We would have to modify the logic within the if-statement of our do_self_action function to accommodate this.

Just updated the do_self_action function to include logic for view inventory and view inventory "[item-name]"

Added the functions to the player.h header file with definitions and descriptions.

Implemented a new display_inventory_item function in the game-state/player module that returns a string of a specific inventory item's long description when given the name of the item and the inventory hash table.

Implemented a new display_inventory function in the game-state/player module that takes in a player and returns a string of items in a player's inventory. The returned string consists of a maximum of 8 items per line.

Closing Statement:
We have changed do_self_action to be able to perform display_inventory and display_inventory_item. display_inventory is called if the target parameter (a list of strings) in do_self_action is a list of length 1. Otherwise, display_inventory_item is called to search for the second string in the target parameter.

display_inventory and display_inventory_item are both implemented within the game-state/player module (player.h and player.c). display_inventory simply accepts a player struct as a parameter and iterates through a list representation of the inventory. display_inventory_item accepts a player and an item name and uses HASH_FIND_STR to grab the corresponding item from the inventory and print its long description.

Kendrick worked on do_self_action.
Don worked on display_inventory_item.
Harrison helped on both of the new functions and implemented them into do_self_action.

Issue Score: Excellent

Comments:
Great job! Nice work updating this issue!