예제 #1
0
def test_flavor_add_exclaimation():
    cards = [
        CardDescription({
            "multiverseid":
            3440,
            "name":
            "Dwarven Miner",
            "flavor":
            "\"Fetch the pestridder, Paka—we've got dwarves in the rutabagas\"\n—Jamul, Femeref farmer",
        })
    ]

    corrections = [{
        "match": {
            "name": [
                "Cerulean Wyvern", "Dwarven Miner", "Ekundu Cyclops",
                "Ether Well", "Floodgate", "Goblin Scouts", "Infernal Contract"
            ]
        },
        "flavorAddExclamation": True
    }]

    mtg_corrections.apply_corrections(corrections, cards)
    assert cards[0][
        'flavor'] == "\"Fetch the pestridder, Paka—we've got dwarves in the rutabagas!\"\n—Jamul, Femeref farmer"
예제 #2
0
async def apply_set_config_options(set_name: List[str], cards_dictionary: List[mtg_global.CardDescription],
                                   tokens_dictionary: List[mtg_global.TokenDescription]) -> Dict[str, Any]:
    """
    Take all options from set_config and add them to the final output product
    This will also add a version field, so it can be determined when it was last
    updated.
    """
    return_product = dict()

    # Will search the tree of set_configs to find the file
    with mtg_storage.open_set_config_json(set_name[1], 'r') as f:
        file_response = json.load(f)

    for key, value in file_response['SET'].items():
        return_product[key] = value

    # Declare the version of the build in the output file
    return_product['meta'] = {'version': mtg_global.__VERSION__, 'date': mtg_global.__VERSION_DATE__}

    if 'SET_CORRECTIONS' in file_response.keys():
        mtg_corrections.apply_corrections(file_response['SET_CORRECTIONS'], cards_dictionary)
    return_product['cards'] = cards_dictionary

    if tokens_dictionary:
        return_product['tokens'] = tokens_dictionary

    return return_product
예제 #3
0
def test_validate_corrections() -> None:
    all_sets = mtg_builder.determine_gatherer_sets({'all_sets': True})
    assert all_sets
    empty_card_list: List[CardDescription] = []
    for set_info in all_sets:
        with mtg_storage.open_set_config_json(set_info[1], 'r') as f:
            blob = json.load(f)
            if blob.get('SET_CORRECTIONS'):
                mtg_corrections.apply_corrections(blob['SET_CORRECTIONS'],
                                                  empty_card_list)
예제 #4
0
def test_fix_flavor_newline():
    cards = [
        CardDescription({
            "flavor":
            "\"The humans are useful in their way, but they must be commanded as the builder commands the stone. Be soft with them, and they will become soft.\"—Radiant, archangel",
            "multiverseid": 5707,
            "name": "Serra Zealot",
            "number": "46",
        })
    ]

    corrections = [{
        "match": {
            "name": "Serra Zealot"
        },
        "fixFlavorNewlines": True,
    }]
    mtg_corrections.apply_corrections(corrections, cards)
    assert cards[0][
        'flavor'] == "\"The humans are useful in their way, but they must be commanded as the builder commands the stone. Be soft with them, and they will become soft.\"\n—Radiant, archangel"
예제 #5
0
def test_flavor_add_dash():
    cards = [
        CardDescription({
            "multiverseid":
            3503,
            "name":
            "Mtenda Griffin",
            "flavor":
            "\"Unlike Zhalfir, the griffin needs no council to keep harmony among its parts.\"Asmira, Holy Avenger",
        })
    ]

    corrections = [{
        "match": {
            "name": ["Ersatz Gnomes", "Mtenda Griffin"]
        },
        "flavorAddDash": True
    }]

    mtg_corrections.apply_corrections(corrections, cards)
    assert cards[0][
        'flavor'] == "\"Unlike Zhalfir, the griffin needs no council to keep harmony among its parts.\"\n—Asmira, Holy Avenger"