Along with the recent work on Radial Menu Prototyping, I started work on a long awaited feature: Canceling Actions. I know it sounds like a pretty basic, standard issue feature. And you’re right, it is. There’s just a lot more to it than you would think, hence the reason why it’s been on the back burner for so long. Fun fact, in every current build, if you moved a unit to a tile and attempted to attack another unit and were out of range, there was no way to cancel that action, and you had to restart the game. Finally, those days are over 🙂

The crux of it all is saving the state of each previous action, so that if you need to cancel, you can just reload the state of the previous action. In theory, it’s pretty easy. The problem for me, as with most other things, is how to do it. There are some well known design patterns that have dealt with this common situation, such as the Command Pattern, as well as the one I will most likely go with, the Memento Pattern.

However, as I started looking into how I was going to implement the Memento Pattern, I realized I needed some other pieces before it would make sense. In lieu of the creation of those missing pieces, I decided to just hack it together. Even though it’s a bit of a hack, I learned a lot about what states I will need to keep track of, which will help when creating the overall system. There are actually a lot of states to keep track of, but there’s really no way to get around it.

But anyway, I’m glad where I’m at at the moment. No more having to reset the book when I make the wrong decision on the battlefield!

Till tomorrow…