luna
luna copied to clipboard
WalkingQueue redesign
The WalkingQueue
class does not test well due to the level of cognitive complexity of many methods within the class, which breaks a few SOLID principles.
A redesign of the class is necessary if we want to extend the functionality of mobile entities, without introducing more unstable code.
The current functionalities encompassed within this class include:
- Determine the walking direction
- Determine the running direction
- Calculating run-energy depletion based on a player's weight
- Calculating run-energy regeneration based on a player's agility level
- Monitoring a player's run-energy
- Prevents movement (incompleted)
To differentiate between walking and running, the best approach IMO would be to make use of the State Object design pattern. This also allows us to easily implement other movement states, such as Stunned
, Frozen
, and Snared
, without having to modifying existing states (in theory).