uchicago-cs / chiventure

A text adventure game engine developed in UChicago's CMSC 22000 - Introduction to Software Development
40 stars 13 forks source link

Openworld: Convert room_generate() into a general purpose, single-room loading + connecting function #1033

Closed Justin08784 closed 3 years ago

Justin08784 commented 3 years ago

Currently, the room_generate() function is only able to generate rooms around the room_t* curr_room field specified in game_t–– the unusual specificity of room_generate() is restricting its widespread usage. room_generate() should be converted into a general-purpose function for generating a single room around any given room in the game–– a functionality needed by higher-level functions like recursive_generate() and multi_room_generate().

Subtasks include:

  1. Update all room_generate() function calls,
  2. Simplify recursive_generate() by replacing its redundant code with a call to room_generate().

A new branch (openworld/refactor-room-generate) will be created for these changes and merged into dev using a PR.

Justin08784 commented 3 years ago

Finished adding room_t *curr_room parameter to room_generate(). Modified dependent documentation, function calls, and tests.

wmingyan commented 3 years ago

Justin and I met on Zoom today. We discussed how to transform room_generate into a helper function that can be used by both multi_room_generate and recursive_generate to reduce redundant code. To achieve this, we will

Justin08784 commented 3 years ago

Summary of 28793b3:

Openworld library compiles fine.

To-do:

Justin08784 commented 3 years ago

Summary of ef2d4d9:

Modifications:

Bug Fixes:

  1. random_items() Passing a roomspec_t whose item_hash_t *items field is NULL (i.e. no items) to random_items() caused it to crash. cause + fix

  2. room_generate() In test room_generate_failure, trying to generate a room in a direction that is already full (full as in a path exists for that direction) crashed the program. cause + fix

  3. recursive_generate() recursive_gen tests for radii ≥ 2 were crashing and/or failing. cause + fix

Justin08784 commented 3 years ago

Tests for pick_random_dir() added.

Justin08784 commented 3 years ago

Closing Statement: The relevant pull request (#1077) has been approved, and the refactored room_generate() function as well as the new helper pick_random_direction() (along with relevant tests), has been merged into the dev branch. This marks the end of this issue.

Follow-ups:

Note: Please ignore the commits below. They were caused by a series of reverts/rollbacks relevant to another issue (#1035).

MaxineK36 commented 3 years ago

Issue Score: ✔️++

Comments: Excellent work! Your summary did a particularly good job noting the specific subtasks being accomplished in this issue.