Page 1 of 1

Deck autoreshuffle in a deck builder

Posted: 23 July 2024, 20:04
by Swinkels
I'm implementing a 4-player deck builder, where each player has its own deck/discard pile.

There will be a lot of cards that trigger a reshuffle from a discard pile to a deck (e.g. draw 3 from a deck with < 3 cards). This is why I would like to use the "autoreshuffle" function of a php Deck. But even with the 'autoreshuffle_cusom' config, it seems that functionality is limited to shuffling 1 source to 1 destination.

Code: Select all

$this->cards->autoreshuffle_custom = array('deck' => 'discard');
Currently I see two solutions for this problem.

Approach 1
Make 4 decks, 1 for each player, each with their own deck/discard pile and autoshuffle.
The downside of this approach is that moving the cards between players will require moving the cards between different Deck instances (so also different tables in the db).

Approach 2
Make a single Deck for all the cards in the game, with a deck and discard pile location for each player ('deck'+$playerid and 'discard'+$playerid, e.g. 'deck101', 'discard101', ..., 'deck104', 'discard104').
The downside of this approach is that I need to implement my own autoreshuffle function.

Both seem reasonable to me, but I would love to hear some thoughts (or new idea's) on this before I commit to a decision.

(Also, is the source code or a more descriptive documentation of a php 'Deck' available? I would like to see when/how autoreshuffle_trigger callback function is called for example.)

Re: Deck autoreshuffle in a deck builder

Posted: 24 July 2024, 07:53
by thoun
If the cards can be exchanged between players and are off the same kind, I would definitely go to one Deck and custom reshuffle. Just make a custom pick cards function, that check the number of cards in players deck, take what's remaining, do the shuffle you want is needed, and pick the others cards.

Re: Deck autoreshuffle in a deck builder

Posted: 24 July 2024, 14:13
by Swinkels
thoun wrote: 24 July 2024, 07:53 If the cards can be exchanged between players and are off the same kind, I would definitely go to one Deck and custom reshuffle. Just make a custom pick cards function, that check the number of cards in players deck, take what's remaining, do the shuffle you want is needed, and pick the others cards.
Yeah, the cards can be exchanged between players and are of the same kind. Using a single deck seems like the best idea, I'll go for that. Thanks for your reply!