Solo model architecture / Card Ordering #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to introduce solo's to the game logic.
The Idea is to use different card orderings, taking advantage of using the exact same approach of how cards are evaluated in the standard game.
This is achieved by dynamically replacing card order within the card object. As the
deck
object is handling card creation, it felt natural to provide a newrules
enum and pass on a list of rules to the deck.Going with this approach it's easy to dynamically change the rules, as is visible within the preview component, where it has been implemented for illustration purposes.
deck.refreshRules(rules)
is all it needs.I believe this approach is straightforward and is of good architecture considering coupling and cohesion.
Although it works out quite well, I dislike the fact that cards contain list of cards. On a technical side it's fine, since it's shallow copies - it just doesn't feel very natural to use it this way.
I couldn't come up with something better, so the whole approach stands for discussion.
Card ordering is something that might be done more decent too, currently it's either "calculating" or generating it by removing and adding cards.
What's missing: