def transform_decks(decks): tokens = [] dfcs = [] for deck in decks: deck_tokens = [] deck_dfcs = [] for card in deck: if 'all_parts' in card: for related_entry in card['all_parts']: if (related_entry['component'] == 'token' or related_entry['component'] == 'combo_piece' and 'Emblem' in related_entry['name']): token = scryfall_tools.get_card( '', uri=related_entry['uri']) if token not in deck_tokens: deck_tokens.append(token) if related_entry['component'] == 'meld_result': meld_result = scryfall_tools.get_card( '', uri=related_entry['uri']) if meld_result not in deck_tokens: deck_tokens.append(meld_result) if card['layout'] == 'transform': deck_dfcs.append(card) for card in deck_dfcs: deck.remove(card) tokens.append(deck_tokens) dfcs.append(deck_dfcs) main_decks_as_ids = [collect_ids(deck) for deck in decks] token_decks_as_ids = [collect_ids(deck) for deck in tokens] dfc_decks_as_ids = [collect_ids(deck) for deck in dfcs] return main_decks_as_ids, token_decks_as_ids, dfc_decks_as_ids
def transform_decks(decks): tokens = {} dfcs = [] for deck in decks: deck_tokens = {} deck_dfcs = [] for card in deck: # Add related parts to the tokens deck. if 'all_parts' in card: for related_entry in card['all_parts']: if (related_entry['component'] == 'token' or related_entry['component'] == 'meld_result' or related_entry['component'] == 'combo_piece' and ('Emblem' in related_entry['name'] or 'Monarch' in related_entry['name'])): related_card = scryfall_tools.get_card( '', uri=related_entry['uri']) deck_tokens[related_card['oracle_id']] = related_card # Add double-faced cards to the DFCs deck. if card['layout'] in ('transform', 'modal_dfc'): deck_dfcs.append(card) for card in deck_dfcs: deck.remove(card) tokens = {**tokens, **deck_tokens} dfcs.append(deck_dfcs) main_decks_as_ids = [collect_ids(deck) for deck in decks] token_decks_as_ids = [collect_ids(tokens.values())] dfc_decks_as_ids = [collect_ids(deck) for deck in dfcs] return main_decks_as_ids, token_decks_as_ids, dfc_decks_as_ids
def get_cmr_pack(): # Commander Legends pack distribution pack = [] # Get 1 foil # Get a random card of weighted random rarity, found in booster packs. # If the rarity is mythic, the foil can also be # one of the 32 reprint commanders only found in foil etched versions. card = st.get_random_card( f's:cmr (is:booster or (is:reprint frame:etched))' f' r:{random.choices(["m", "r", "u", "c"], [1, 8, 23, 88])[0]}') # There is a 50% chance a legendary foil # will be replaced with a foil etched version. if 'Legendary' in card['type_line'] and \ 'Creature' in card['type_line']: if random.randint(0, 1) == 1: card = st.search_for_cards( f's:cmr {card["name"]} frame:etched')[0] pack += [card] # Add 2 legendary cards of any rarity rarities = random.choices(['m', 'r', 'u'], [1, 8, 23], k=2) legendary_card_1 = st.get_random_card( f'set:{set_code} t:legendary is:booster r:{rarities[0]}') pack += [ legendary_card_1, st.get_random_card(f'set:{set_code} t:legendary is:booster' f' -"{legendary_card_1["name"]}"' f' r:{rarities[1]}') ] # Add a non-legendary rare or mythic (~14% chance of Mythic) pack += [ st.get_random_card(f'set:{set_code} -t:legendary is:booster' f' r={random.choices(["m", "r"], [1, 6])[0]}') ] # Add 3 uncommons cards = st.search_for_cards( f'set:{set_code} r=u -t:legendary is:booster') pack += random.sample(list(cards), 3) # Add 13 commons cards = st.search_for_cards( f'set:{set_code} r=c is:booster -"Prismatic Piper"') # Prismatic Piper sometimes replaces one of the commons (~16.7% chance) if random.randint(1, 6) == 1: commons = random.sample(list(cards), 12) pack += [st.get_card("The Prismatic Piper")] else: commons = random.sample(list(cards), 13) pack += commons return pack
def get_limited_pool(set_code, number_of_players, packs_per_player): if number_of_players == 1: names = [ f'{set_code.upper()} - Pack {i + 1}' for i in range(packs_per_player) ] else: names = [ f'{set_code.upper()} - Player {j + 1}, Pack {i + 1}' for j in range(number_of_players) for i in range(packs_per_player) ] result = {name: get_pack(set_code) for name in names} result['Basics'] = [ st.get_card('Plains'), st.get_card('Island'), st.get_card('Swamp'), st.get_card('Mountain'), st.get_card('Forest'), ] return result