I've returned to Solitaire Online after a month or so.
This is interesting from a coding perspective.
Firstly, you think, what was I thinking and secondly how does this work? This is standard in the programming world.
After the initial shock, I spent several hours adding in an Undo button. I hadn't intended to do this, but in the end realised that if I was playing Solitaire with real playing cards, I would just physically move a card back from time to time.
This was fairly straight-forward to do. I had intentionally coded almost all the card movement to go through one function with Undo functionality in mind.
All that needed to be done was log the movements for later reversal.
There are, as is always the way, edge cases which still need to be fixed!
I think that my subconscious has been working on the structure of Solitaire, and in particular the animation of cards.
If anyone intends to write their own game (and it is an interesting exercise), I'd strongly recommend thinking about how cards are moved.
Although there are a limited number of movements, there are more than I originally considered, meaning that my animation functions somewhat sub-optimal in terms of parameters and readability.
Here' a non-exhaustive list:
Move a card from the top of one pile to another.
Move a card from the top of one pile to the bottom of another.
Move several cards from the top of one pile to the top of another.
Move a card from the top to bottom of the same pile, and vice versa.
The code would be a lot easier to understand/maintain if I had thought this through from the start.
So, what next?
I need to fully debug the Undo function and fix Pairs Solitaire before adding any more games to Solitaire Online .