Skip to content

Rooms ~ Conditional Connections Between Rooms Design Plan

Borja Sotomayor edited this page May 15, 2021 · 3 revisions

How Conditions will be Administered between Rooms

In order to make sure rooms can't be entered without pre-requisites, the attribute for the "OPEN" action must be false in the attribute_hash_t parameter of the door item struct that corresponds to the path that enters that room. Path structs have an item called through, which is for the door that the player must pass through to take that path. If the "OPEN" attribute is set to false for the door item in that path, then the player can't pass through that door.

The "OPEN" attribute of the door will always start out as false if there are pre-requisites for entering the next room. Otherwise, it will start as true. To change the false to true for the paths with pre-requisites, the pre-requisites must be cleared. The path struct's description in game-state/room.h states that there is a "list of conditions that must be fulfilled to move to the room." This list of conditions is not present in the actual struct, but it must be added. It should be made as a linked list.

The next step is to add a trigger to the actions. The trigger will be a char* trigger in the action_type_t struct that has the same value as the room_id in the room struct of the path. If the action isn't a pre-requisite for anything, then it doesn't require a trigger, so the trigger value will be 0. When one of the do functions in actionmanagement.c carries out the action, the trigger value has to be checked. If it is not NULL, then the linked list will be searched in a helper function that takes the trigger value and finds the according path, then takes the id of the path/item(s) and searches for it in the linked list. When the items and actions are found to be the same, that element will be removed from the linked list and the trigger value will be changed to the value 0 (if the player does the same exact action again then the function won't search for it again).

That helper function will check if removing the action produces a NULL linked list. If it does, then it will call the set_bool_attr function in game-state/item.c to change the "OPEN" attribute to true. The room will then be accessible.

Changes to be Made

  • Create a function that takes an action and removes it from any linked list that contains the action and changes the boolean for "OPEN" if it removes the only item of the list.
  • Apply the function to the do functions in action management.c
  • Add a linked list of conditions to the path struct.
  • Add the trigger value parameter to the action_type_t struct.

Framework for Possible Functions

/* goes into the list_action_type_t struct of path_t and removes the coinciding action_type_t */ Void remove_completed_action(path_t, action_type_t) {

}

/* checks if action has trigger value */ bool trigger_check(action_type_t) { Return false; }

/* checks if list of actions in path_t is empty */ bool conditions(path_t) { Return false; }

/* changes the door attribute to OPEN */ Void allow_path_access(item_t) {

}

Clone this wiki locally