diff --git a/README.md b/README.md index 72d2840..2859ad5 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ If something doesn't work, please [open an issue on GitHub](https://github.com/a 1. Save your decklist as a .txt in the format `1 Cardname` or `1x Cardname`, one card per line. Currently only singleton formats are supported. 2. Optionally, put a grayscale/transparent png in `icons/`. You can use this in place of a set icon to indicate what cube or deck the cards are part of. +3. Optionally, you can put a flavor name (like the Godzilla cards) in square brackets after a card name. 3. Run `python3 makeProxies.py yourDeck.txt` (or `python3 makeProxies.py yourDeck.txt icons/yourIcon.png` if you want a set icon). 4. Print each page in `pages/yourDeck/` at full size/fit to page and cut just outside the border of each card. @@ -41,6 +42,6 @@ If you're sleeving your BWProxies, you can just use real basic lands. But if you Source code is available [here](https://github.com/a11ce/bwproxy). All contributions are welcome by pull request or issue. -Minor version numbers represent changes to the appearence of generated cards. Patch version numbers represent changes to the functionality of card generation. +Minor version numbers represent (possible) changes to the appearence of generated cards. Patch version numbers represent changes to the functionality of card generation. BWProxy is licensed under GNU General Public License v3.0. See [LICENSE](https://github.com/a11ce/bwproxy/blob/main/LICENSE) for full text. Fonts and mana symbols are excluded. diff --git a/makeProxies.py b/makeProxies.py index 97a14a6..b877046 100644 --- a/makeProxies.py +++ b/makeProxies.py @@ -22,12 +22,19 @@ def loadCards(fileLoc, deckName): with open(fileLoc) as f: cardsInDeck = [] + flavorNames = {} for line in tqdm(f): line = line.strip() cardCount = re.findall("^([0-9]+)x?", line) + flavorName = re.findall("\[(.*?)\]", line) cardName = line.split(cardCount[0])[1].strip() + if len(flavorName) > 0: + flavorName = flavorName[0] + cardName = (cardName.split(flavorName)[0])[:-1].strip() + flavorNames[cardName] = flavorName + if cardName in cardCache: cardDat = cardCache[cardName] @@ -61,10 +68,10 @@ def loadCards(fileLoc, deckName): with open(cacheLoc, "wb") as p: pickle.dump(cardCache, p) - return [card for card in cardsInDeck if card is not None] + return [card for card in cardsInDeck if card is not None], flavorNames -def makeImage(card, setSymbol): +def makeImage(card, setSymbol, flavorNames={}): cardImg, pen = drawUtil.blankCard() # mana cost TODO cleanup and fix phyrexian @@ -89,15 +96,26 @@ def makeImage(card, setSymbol): fill="black", anchor="ra") xPos -= 0 if c == "/" else 20 if c == "P" else 40 + #575 default width for name, default font 60 - nameFont = drawUtil.fitOneLine("matrixb.ttf", card.name, xPos - 100, 60) - pen.text((70, 85), card.name, font=nameFont, fill="black", anchor="lm") + if card.name in flavorNames: + nameFont = drawUtil.fitOneLine("matrixb.ttf", flavorNames[card.name], + xPos - 100, 60) + pen.text((70, 85), + flavorNames[card.name], + font=nameFont, + fill="black", + anchor="lm") + else: + nameFont = drawUtil.fitOneLine("matrixb.ttf", card.name, xPos - 100, + 60) + pen.text((70, 85), card.name, font=nameFont, fill="black", anchor="lm") # 600 width for typeline with symbol, default font 60 typeLine = drawUtil.makeTypeLine(card.supertypes, card.types, card.subtypes) typeFont = drawUtil.fitOneLine("matrixb.ttf", typeLine, 540, 60) - pen.text((70, 530), typeLine, font=typeFont, fill="black", achor="lm") + pen.text((70, 540), typeLine, font=typeFont, fill="black", anchor="lm") if setSymbol is not None: cardImg.paste(setSymbol, (620, 520), setSymbol) @@ -128,6 +146,13 @@ def makeImage(card, setSymbol): font=proxyFont, fill="black") + if card.name in flavorNames: + pen.text((375, 490), + card.name, + font=proxyFont, + fill="black", + anchor="md") + brushFont = ImageFont.truetype("MagicSymbols2008.ttf", 20) pen.text((70, 970), "L", font=brushFont, fill="black") @@ -143,9 +168,11 @@ def makeImage(card, setSymbol): setSymbol = Image.open(sys.argv[2]).convert("RGBA").resize( (60, 60)) if len(sys.argv) > 2 else None - allCards = loadCards(sys.argv[1], deckName) - - images = [makeImage(card, setSymbol) for card in tqdm(allCards)] + allCards, flavorNames = loadCards(sys.argv[1], deckName) + images = [ + makeImage(card, setSymbol, flavorNames=flavorNames) + for card in tqdm(allCards) + ] print(images) drawUtil.savePages(images, deckName)