From 1fc85dc1a2b4cb4282a5ded796e1c09952975717 Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Sun, 29 Dec 2013 09:11:22 -0800 Subject: [PATCH] add base_cards_with_expansion option --- dominion_cards.txt | 32 ++++++++++++++++++++++++-------- dominion_tabs.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/dominion_cards.txt b/dominion_cards.txt index 1023de9..33570dc 100644 --- a/dominion_cards.txt +++ b/dominion_cards.txt @@ -23,6 +23,14 @@ 23 Mine Dominion Action $5 Trash a Treasure card from your hand. Gain a Treasure card costing up to 3 Coins more; put it into your hand. 24 Witch Dominion Action - Attack $5 +2 Cards, Each other player gains a Curse card. 25 Adventurer Dominion Action $6 Reveal cards from your deck until you reveal 2 Treasure cards. Put those Treasure cards in your hand and discard the other revealed cards. +26 Copper Dominion Treasure $0 Worth 1 Coin. +27 Silver Dominion Treasure $3 Worth 2 Coins. +28 Gold Dominion Treasure $6 Worth 3 Coins. +29 Curse Dominion Curse $0 -1 +30 Estate Dominion Victory $2 1 +31 Duchy Dominion Victory $5 3 +32 Province Dominion Victory $8 6 +33 Trash Dominion Action $0 Pile of trash. 1 Courtyard Intrigue Action $2 +3 Card, Put a card from your hand on top of your deck. 2 Pawn Intrigue Action $2 Choose two: +1 Card, +1 Action, +1 Buy, +1 Coin. (The choices must be different.). @@ -50,6 +58,14 @@ 24 Harem Intrigue Treasure - Victory $6 Worth 2 Coins, 2 25 Nobles Intrigue Action - Victory $6 2 Choose one: +3 Cards, or +2 Actions. +26 Copper Intrigue Treasure $0 Worth 1 Coin. +27 Silver Intrigue Treasure $3 Worth 2 Coins. +28 Gold Intrigue Treasure $6 Worth 3 Coins. +29 Curse Intrigue Curse $0 -1 +30 Estate Intrigue Victory $2 1 +31 Duchy Intrigue Victory $5 3 +32 Province Intrigue Victory $8 6 +33 Trash Intrigue Action $0 Pile of trash. 1 Embargo Seaside Action $2 +2 Coins, Trash this card. Put an Embargo token on top of a Supply pile. - When a player buys a card, he gains a Curse card per Embargo token on that pile. 2 Haven Seaside Action - Duration $2 +1 Card, +1 Action, Set aside a card from your hand face down. At the start of your next turn, put it into your hand. @@ -194,14 +210,14 @@ At the start of Clean-up, if you have this and no more than one other Action car Choose one; you get the version in parentheses: Each player gets +1 (+3) Cards; or each player gains a Silver (Gold); or each player may trash a card from his hand and gain a card costing exactly 1 Coin (2 Coins) more. 1 Copper Base Treasure $0 Worth 1 Coin. -2 Curse Base Curse $0 -1 -3 Estate Base Victory $2 1 -4 Silver Base Treasure $3 Worth 2 Coins. -5 Duchy Base Victory $5 3 -6 Gold Base Treasure $6 Worth 3 Coins. -7 Province Base Victory $8 6 -8 Potion Base Treasure $4 Worth 1 Potion. -9 Platinum Base Treasure $9 Worth 5 Coins. +2 Silver Base Treasure $3 Worth 2 Coins. +3 Gold Base Treasure $6 Worth 3 Coins. +4 Platinum Base Treasure $9 Worth 5 Coins. +5 Potion Base Treasure $4 Worth 1 Potion. +6 Curse Base Curse $0 -1 +7 Estate Base Victory $2 1 +8 Duchy Base Victory $5 3 +9 Province Base Victory $8 6 10 Colony Base Victory $11 10 11 Trash Base Action $0 Pile of trash. diff --git a/dominion_tabs.py b/dominion_tabs.py index a383d92..688ed23 100644 --- a/dominion_tabs.py +++ b/dominion_tabs.py @@ -645,6 +645,10 @@ class DominionTabs: help="sort order for the cards, whether by expansion or globally alphabetical") parser.add_option("--expansion_dividers", action="store_true", dest="expansion_dividers", help="add dividers describing each expansion set") + parser.add_option("--base_cards_with_expansion", action="store_true", + help='print the base cards as part of the expansion; ie, a divider for "Silver"' + 'will be printed as both a "Dominion" card and as an "Intrigue" card; if this' + 'option is not given, all base cards are placed in their own "Base" expansion') options, args = parser.parse_args(argstring) if not options.cost: @@ -787,6 +791,15 @@ class DominionTabs: cards = self.read_card_defs(os.path.join(self.filedir,"dominion_cards.txt")) self.read_card_extras(os.path.join(self.filedir,"dominion_card_extras.txt"),cards) + + baseCards = [card.name for card in cards if card.cardset.lower() == 'base'] + def isBaseExpansionCard(card): + return card.cardset.lower() != base and card.name in baseCards + if self.options.base_cards_with_expansion: + cards = [card for card in cards if card.cardset.lower() != 'base'] + else: + cards = [card for card in cards if not isBaseExpansionCard(card)] + if self.options.expansions: self.options.expansions = [o.lower() for o in self.options.expansions] filteredCards = [] @@ -805,6 +818,8 @@ class DominionTabs: if options.expansion_dividers: cardnamesByExpansion = {} for c in cards: + if isBaseExpansionCard(c): + continue cardnamesByExpansion.setdefault(c.cardset,[]).append(c.name.strip()) for exp,names in cardnamesByExpansion.iteritems(): c = Card(exp, exp, ("Expansion",), None, ' | '.join(sorted(names))) @@ -815,10 +830,21 @@ class DominionTabs: out = yaml.dump(cards) open('cards.yaml','w').write(out) + # When sorting cards, want to always put "base" cards after all + # kingdom cards, and order the base cards in a set order - the + # order they are listed in the database (ie, all normal treasures + # by worth, then potion, then all normal VP cards by worth, then + # trash) + def baseIndex(name): + try: + return baseCards.index(name) + except Exception: + return -1 + if options.order == "global": - sortKey = lambda x: x.name + sortKey = lambda x: (int(x.isExpansion()), baseIndex(x.name),x.name) else: - sortKey = lambda x: (x.cardset,x.name) + sortKey = lambda x: (x.cardset,int(x.isExpansion()),baseIndex(x.name),x.name) cards.sort(key=sortKey) if not f: