Skip to content

Commit

Permalink
Fix --expansion-reset-tabs limitations (#369)
Browse files Browse the repository at this point in the history
The --expansion-reset-tabs option was previously incompatible with
--include-blanks because it handles low card counts specially, and
blanks leave the "extras" card count unset. I fixed the code by
defaulting to a count of 0 in this case.

The option was also previously dependent on --expansion-dividers, and
silently ignored if the latter was not set. As there wasn't a clear
technical reason for the limitation, I removed it and moved
--expansion-reset-tabs from the Expansion Dividers group to the Divider
Tab group.
  • Loading branch information
bszonye committed Feb 6, 2022
1 parent 8d04642 commit cde8b08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
11 changes: 3 additions & 8 deletions src/domdiv/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1905,20 +1905,15 @@ def setupCardPlots(self, options, cards=[]):
items = []
nextTabIndex = CardPlot.tabRestart()
lastCardSet = None
reset_expansion_tabs = (
options.expansion_dividers and options.expansion_reset_tabs
)

for card in cards:
# Check if tab needs to be reset to the start
if reset_expansion_tabs and not card.isExpansion():
if options.expansion_reset_tabs and not card.isExpansion():
if lastCardSet != card.cardset_tag:
# In a new expansion, so reset the tabs to start over
nextTabIndex = CardPlot.tabRestart()
if (
options.tab_number > Card.sets[card.cardset_tag]["count"]
and Card.sets[card.cardset_tag]["count"] > 0
):
cardset_count = Card.sets[card.cardset_tag].get("count", 0)
if options.tab_number > cardset_count and cardset_count > 0:

# Limit to the number of tabs to the number of dividers in the expansion
CardPlot.tabSetup(
Expand Down
14 changes: 7 additions & 7 deletions src/domdiv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,13 @@ def parse_opts(cmdline_args=None):
dest="use_set_icon",
help="Use set icon instead of a card icon. Applies to Promo cards.",
)
group_tab.add_argument(
"--expansion-reset-tabs",
action="store_true",
dest="expansion_reset_tabs",
help="When set, the tabs are restarted (left/right) at the beginning of each expansion. "
"If not set, the tab pattern will continue from one expansion to the next. ",
)

# Expanion Dividers
group_expansion = parser.add_argument_group(
Expand All @@ -382,13 +389,6 @@ def parse_opts(cmdline_args=None):
dest="full_expansion_dividers",
help="Full width expansion dividers.",
)
group_expansion.add_argument(
"--expansion-reset-tabs",
action="store_true",
dest="expansion_reset_tabs",
help="When set, the tabs are restarted (left/right) at the beginning of each expansion. "
"If not set, the tab pattern will continue from one expansion to the next. ",
)
group_expansion.add_argument(
"--expansion-dividers-long-name",
action="store_true",
Expand Down

0 comments on commit cde8b08

Please sign in to comment.