Quests ~ Completing Item and Room Integration Into Quests - uchicago-cs/chiventure GitHub Wiki
The Problem
Currently, quests store pointers to items and rooms in struct mission
, but these pointers are never checked in any way, so the mission can never actually be verified. We need to add functionality so quests can actually check if missions of these kinds are complete and we also need to check completion in the functions that could theoretically complete these missions.
Also, we have a similar problem with NPCs, though that is primarily for a separate issue. For now though, we need to make it so NPCs can access quests.
Change 1: Allowing NPCs to access quests
Right now, the quest module imports the NPC module so a pointer to an NPC can be stored in the missions struct. The pointer currently isn't used for anything though, so we can just replace it with a string id of the NPC and remove the include. While doing this, we can actually replace all of the pointers in the missions struct with string ids instead. In that case, since missions can only store one pointer, we can just replace the individual pointers with a single string and an enum denoting which type of mission the string is an id for.
The new mission function should look like this:
typedef enum mission_types {
MEET_NPC,
MURDER_NPC,
COLLECT_ITEM,
ENTER_ROOM,
} mission_types_t;
typedef struct mission {
char * target_name;
mission_types_t *type;
} mission_t;
Change 2: Adding Item and Room Checks
We need to update is_task_completed()
to check if items are in the player's inventory through the item_in_inventory()
and by checking game->curr_room
. Additionally, we need to add calls to is_task_complete()
to add_item_to_player()
and move_room()
. Additionally, add_item_to_player()
needs to be moved to game.h
to fix circular dependencies.