canary
canary copied to clipboard
enhance: Monster::getDanceStep code duplication
Description
Refactored the getDanceStep
function to avoid code duplication by introducing a helper function tryAddDirection
. This change improves code readability and maintainability by reducing repetitive logic.
Changed: • From push_back to emplace_back • From std::shuffle to std::ranges::shuffle
Behaviour
Actual
The getDanceStep
function had repetitive logic for adding directions to the dirList
.
Expected
The getDanceStep
function uses a helper function to encapsulate the repetitive logic, making the code more concise and easier to maintain.
Type of change
- [x] Code refactoring (non-breaking change which improves the code structure)
Checklist
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I checked the PR checks reports
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works