A super simple variant type over all possible game modes currently
supported. Allows us to take a sequence of cards and try to generate
a Hand of one of the modes based on it. Also uses Result instead of
Option to give us a bit more detail on the type of errors we can get.
The first stage of the game is collecting the relevant players who
want to play. We can't deal out any cards, nor do an election, till
this is done.
The way I've codified this is by having an opaque PlayerBuilder struct
with some helpers to add "new players" - essentially just empty decks
of cards. Once we're done, we "freeze" or "fix" this set of players
by returning a Boxed array representing the contents.
Ridiculously simple API.
- construct empty or decks composed of n "decks" of cards
- sort by standard ordering or suit ordering, and shuffle them using
an RNG
- get, add, remove
- deal from the tail of a deck, or from any sequence of indices
This API will be the cornerstone of how games are managed.
Painful. I hate testing with a passion. I find it so difficult to
not be exhaustive since single pattern's aren't enough, but at the
level of complexity for triples it's actually getting computationally
difficult (read: takes a few seconds) to do.
We know the sizes of the results of these functions beforehand.
Fitting it into an ESI was a code smell really. Just return the
arrays! Of course, now we need to do array::into_iter for iterator
use, but this is way better.
Excluding Card::iter_all since we can't know the size of it at compile
time. PITA that we can't make it an ESI either.
Essentially just encodes the flatmap of two iterators being tupled
together. Different to just a standard zip.
Unfortunately we do need the second iterator to implement Clone as we
clone it for each item of the first iterator to generate the flat_map.
Type tetris masturbation has reached a new high here.
Given an ExactSizedIterator and a compile time known size (N), we
should be able to generate stack allocated arrays of the contents of
an iterator as long as the iterator has at least the required size.