Booster
in package
Opens booster packs from a set's MTGJSON booster configuration, as stored in the AllPrintings build's `setBooster*` tables.
A booster type (play, draft, collector, …) has weighted pack
layouts; each layout takes a number of picks from named sheets, and each
sheet holds weighted cards. Picks from one sheet do not repeat a card
unless the sheet runs out. A sheet asking for at least as many picks as
its total weight is fixed: every card comes as many times as its weight.
A color-balanced sheet (most common slots) first takes one mono-colored
card of each color, then fills the rest.
Tags
Table of Contents
Constants
- COLORS : array<string|int, string> = ['W', 'U', 'B', 'R', 'G']
- The colors a balanced sheet covers.
- PREFERENCE : array<string|int, string> = ['play', 'draft', 'default', 'set', 'collector']
- Booster types preferred when none is asked for, best first.
Properties
Methods
- __construct() : mixed
- fill() : array<string|int, string>
- Picks a sheet's cards for one pack.
- open() : array<string|int, array{uuid: string, foil: bool}>
- Opens one pack.
- types() : array<string|int, string>
- The booster types a set has, preferred first.
- weighted() : int|string
- Picks one key, with probability proportional to its weight.
Constants
COLORS
The colors a balanced sheet covers.
public
array<string|int, string>
COLORS
= ['W', 'U', 'B', 'R', 'G']
PREFERENCE
Booster types preferred when none is asked for, best first.
public
array<string|int, string>
PREFERENCE
= ['play', 'draft', 'default', 'set', 'collector']
Properties
$database
protected
Database
$database
Methods
__construct()
public
__construct(Database $database) : mixed
Parameters
- $database : Database
-
An open build.
fill()
Picks a sheet's cards for one pack.
public
static fill(array<string, array{weight: int, colors: string}> $cards, int $picks[, bool $balance = false ]) : array<string|int, string>
Parameters
- $cards : array<string, array{weight: int, colors: string}>
-
The sheet, by uuid.
- $picks : int
-
How many cards to take.
- $balance : bool = false
-
Whether to cover each color first.
Return values
array<string|int, string> —The picked uuids.
open()
Opens one pack.
public
open(string $setCode, string $type) : array<string|int, array{uuid: string, foil: bool}>
Parameters
- $setCode : string
-
The set code, upper case.
- $type : string
-
The booster type, from types().
Tags
Return values
array<string|int, array{uuid: string, foil: bool}> —The pack's cards, in MTGJSON's sheet order.
types()
The booster types a set has, preferred first.
public
types(string $setCode) : array<string|int, string>
Parameters
- $setCode : string
-
The set code, upper case.
Return values
array<string|int, string>weighted()
Picks one key, with probability proportional to its weight.
public
static weighted(array<int|string, int> $weights) : int|string
Parameters
- $weights : array<int|string, int>