diff --git a/magic/decklist.py b/magic/decklist.py index 4d4409e42..4f1b91ed0 100644 --- a/magic/decklist.py +++ b/magic/decklist.py @@ -107,7 +107,10 @@ def vivify(decklist: DecklistType) -> Deck: for section in ['maindeck', 'sideboard']: for name, n in decklist.get(section, {}).items(): try: - validated[section][oracle.valid_name(name)] = n + canonical_name = oracle.valid_name(name) + if validated[section].get(canonical_name): + raise InvalidDataException(f'More than one entry for {canonical_name} in {section}') + validated[section][canonical_name] = n except InvalidDataException: invalid_names.add(name) if invalid_names: diff --git a/magic/decklist_test.py b/magic/decklist_test.py index df638ff48..74426943b 100644 --- a/magic/decklist_test.py +++ b/magic/decklist_test.py @@ -802,3 +802,28 @@ def test_maindeck_not_sideboard() -> None: d = decklist.parse(s) assert sum(d['maindeck'].values()) == 60 assert sum(d['sideboard'].values()) == 0 + +def test_vivify_universes_beyond() -> None: + s = """ + 4 Negan, the Cold-Blooded + 56 Swamp + """ + s = textwrap.dedent(s) + d = decklist.parse(s) + v = decklist.vivify(d) + assert v.maindeck[0].name == 'Malik, Grim Manipulator' + assert v.maindeck[0].n == 4 + assert v.maindeck[1].name == 'Swamp' + assert v.maindeck[1].n == 56 + + s = """ + 4 Malik, Grim Manipulator + 56 Swamp + """ + s = textwrap.dedent(s) + d = decklist.parse(s) + v = decklist.vivify(d) + assert v.maindeck[0].name == 'Malik, Grim Manipulator' + assert v.maindeck[0].n == 4 + assert v.maindeck[1].name == 'Swamp' + assert v.maindeck[1].n == 56 diff --git a/magic/oracle.py b/magic/oracle.py index 7916d14fb..9d81de243 100644 --- a/magic/oracle.py +++ b/magic/oracle.py @@ -25,7 +25,7 @@ def init(force: bool = False) -> None: def valid_name(name: str) -> str: if name in CARDS_BY_NAME: - return name + return CARDS_BY_NAME[name].name try: front = name[0:name.index('/')].strip() except ValueError: