Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-architect the generation module to use a builder pattern #249

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

JackAshwell11
Copy link
Owner

@JackAshwell11 JackAshwell11 commented Oct 3, 2024

Description of Changes

This PR re-architects the generation module (specifically the map.hpp file) to use a builder pattern allowing create_map() to become less complicated and adding the option for future expandability. It also introduces a bunch of other refactors to improve the overall code quality and make it simpler to understand and use.

Type of Changes

Type
🐛 Bug Fix
✨ New Feature
🔨 Refactoring
📝 Miscellaneous

Tasks

  • Introduce a builder pattern to map.hpp.
  • Refactor the rest of the generation module where possible to simplify its API.

Simplified `dijkstra.cpp` to be more readable and easier to understand.
…y construction of a dungeon using the `MapGenerator` class. This re-architect also introduced a bunch of other refactors massively simplifying various parts of the codebase and extracting out common functionality.

Removed `Neighbour` and replaced it with `Connection` (a renamed version of `Edge`) allowing `Connection` to work for `map.hpp` and `dijkstra.hpp`. This also simplified the backtracking as we didn't have to find the source.

Added `Grid::convert_position(int)` allowing the conversion of a 1D index into a 2D `Position`.

Changed `Leaf::create_room()` so that `rooms` is now the center `Rect` position by default instead of the whole `Rect` object.

Stopped `pathfind()` throwing an error as this caused a crash with `std::transform` if the grid is empty.

Removed `LevelConstants::level`.
@JackAshwell11 JackAshwell11 merged commit 95fce06 into main Oct 4, 2024
13 checks passed
@JackAshwell11 JackAshwell11 deleted the generation_refactor branch October 4, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant