Action Management ~ Inventory Item Prerequisites - uchicago-cs/chiventure GitHub Wiki

Team Action Management - Inventory Item Prerequisites

Introduction

Currently, action conditions are checked only by matching item attributes to a condition's attribute; if they match, then the action is performed. A new condition that checks the player's inventory for a certain item will be added to the possible conditions. Since it is possible to have this kind of action prerequisite for all forms of actions, including path actions, game-state's conditions would likely be changed the most to keep abstraction. Also, since conditions are only in game-state's item module, a rework must be done to do_path_action because it currently does not check any prerequisites (see issue #453).

Reworked Modules

game-state item

  • Introduce condition types:
    • attribute: the condition type already implemented in the code
    • inventory: the condition to be added; passes only if the player has the item in inventory
    • Condition types will allow for other implementation-heavy conditions to be added as more are thought of
  • Add new structs attribute_condition and inventory_condition as new condition types
    • attribute_condition contains most of game_action_condition's variables:
      • item_t *item;
      • attribute_t* attribute_to_check;
      • attribute_value_t expected_value;
    • inventory_condition contains:
      • player_t* player_to_check; to quickly reference inventory
      • item_t *expected_item; the item to check
  • change game_action_condition to include (possibly) a union of attribute and inventory condition, and an enum condition_tag to let check_condition know which condition to check

game-state player

  • Add new function bool item_in_inventory(player_t *player, item_t *item)
    • Likely uses HASH_FIND function to check if item is in inventory

game-state room

  • Add the game_condition_list_t linkedlist (specified by item) to path struct
  • More will be worked out with other action management teammates

game-state game_action

  • Rewrite check_condition to determine whether the condition is attribute or inventory, and then include the necessary logic for testing if the item exists in the inventory through the player's item_in_inventory function
  • Add functions to construct each type of condition and add them to the action condition linkedlist
  • condition_new and add_action_condition should be updated to reflect the new condition types
    • Must decide on whether to add new functions or abstract each function further

action_management actionmanagement

  • do_path_action will check for conditions and possibly return CONDITIONS_NOT_MET
  • If all goes well, not many changes will be made to these files

Goals

  • Work with Action Management's Conditional Connections Between Rooms team to make sure item prerequisites supports their code
  • Implementation