Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the possibility to repeat multiple copies of all the cards of a deck #7

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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