pub struct BoosterSimulator<'a> { /* private fields */ }Expand description
Simulates opening MTG booster packs using the MTGJSON booster configuration data.
The simulator reads from the set booster parquet tables (content weights, contents, sheet cards, and sheet metadata) to faithfully reproduce the distribution of cards in sealed product.
Implementations§
Source§impl<'a> BoosterSimulator<'a>
impl<'a> BoosterSimulator<'a>
Sourcepub fn new(conn: &'a Connection) -> Self
pub fn new(conn: &'a Connection) -> Self
Create a new BoosterSimulator bound to the given connection.
Sourcepub fn available_types(&self, set_code: &str) -> Result<Vec<String>>
pub fn available_types(&self, set_code: &str) -> Result<Vec<String>>
Return the available booster type names for a set (e.g. ["draft", "collector"]).
Returns an empty vector if the set has no booster configuration data.
Sourcepub fn open_pack(
&self,
set_code: &str,
booster_type: &str,
) -> Result<Vec<Value>>
pub fn open_pack( &self, set_code: &str, booster_type: &str, ) -> Result<Vec<Value>>
Open a single booster pack and return the card data for every card in the pack.
Performs weighted random selection of a pack template and then weighted
random selection of cards from each sheet in the template. Returns a
vector of card JSON objects fetched from the cards view.