Skip to content

Commit

Permalink
Add the possibility to repeat multiple copies of all the cards of a deck
Browse files Browse the repository at this point in the history
  • Loading branch information
pablerass committed Nov 26, 2023
1 parent 382c53b commit 53aead1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cartuli/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def _load_deck(self, definition: dict, name: str) -> Deck:
if not cards:
logger.warning(f"No cards found for deck {name} with specified fiters")

cards = cards * definition.get('copies', 1)

default_back = None
if 'default_back' in definition:
default_back_file = definition['default_back']['image']
Expand Down
12 changes: 8 additions & 4 deletions tests/test_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,24 @@ def test_filters_definition():


def test_definition(random_image_file):
num_cards = 5

random_image_dir = random_image_file("front").parent
for _ in range(0, 4):
for _ in range(0, num_cards - 1):
random_image_file("front")

definition_dict = {
'decks': {
'cards': {
'size': 'STANDARD',
'front': {
'images': str(random_image_dir / "*.png"),
'bleed': '2*mm'
'bleed': '2*mm',
},
'default_back': {
'image': str(random_image_file("back"))
}
},
'copies': 2
}
},
'outputs': {
Expand All @@ -92,7 +96,7 @@ def test_definition(random_image_file):
definition = Definition(definition_dict)
assert definition.decks[0].name == 'cards'
assert definition.decks[0].size == STANDARD
assert len(definition.decks[0]) == 5
assert len(definition.decks[0]) == 2 * num_cards
assert definition.decks[0].two_sided
assert definition.decks[0].cards[0].front.bleed == 2*mm
assert definition.sheets['cards', ].cards == definition.decks[0].cards
Expand Down

0 comments on commit 53aead1

Please sign in to comment.