So, I'm trying to take a deck of cards, split it into piles, and then shuffle one each of another stack of cards into the piles. The split() function is perfect, as I want the piles to end up 90* to each other anyway. So the script works like this so far:
- Get the two decks from the zones they're sitting in (deck and discard zones)
- Count the cards in the "discard" deck
- Split the main deck by that count
- Move one each of the "discard" cards into each pile
- Shuffle the piles
So far so good. The game itself expects the "small" plies to be on the bottom. This, with the split() function, is behaving a bit weird though - the counts are a little bizarre. In my test setup (and how the game will start), I have 48 cards in the main deck, with 5 cards to split in from the "discard" deck. This results in splitting the main deck into 5 piles, of 10,10,10,9,9.
I get piles that size, but if I use a for loop to get which index of the resulting table has which counts, I get the following - indexes 1, 2, and 5 have 10 cards, while 3 and 4 have 9. Even more maddeningly, after a fair amount of testing, I find that Index 1 is the second pile from the bottom, while Index 5 is the bottom pile! The piles count UP from the second from the bottom, and wrap around from the top (which is index 4) back to the bottom!
Complicate matters with the fact that the number of cards in either deck could vary during the game (more "deck" cards to split, or more "discard" cards to force more piles to be made), so I'd like to TRY to avoid some sort of hacky solution.
Anyone have any idea what is going on? Any suggestions about how to get things the way I want them? Pastebin with the code: https://pastebin.com/Q7V0y1ET