Skip to content

$this->bga->deckFactory

Create a Deck component that stores cards or other pieces in a game database table.

API

createDeck(string $tableName): Deck

Return a Bga\GameFramework\Components\Deck configured for the specified database table. The factory creates the PHP component; define its database table in your database model.

Create the component after calling parent::__construct() in the Game constructor:

$this->cards = $this->bga->deckFactory->createDeck('card');

Declare a corresponding Deck property on your Game class. Populate the deck in setupNewGame, then use it to create, shuffle, pick, and move cards.

For the component API and required database columns, see the Deck reference.

For typed game objects and automatic table creation, see itemManagerFactory.