Simplify makeFace by moving os.path.join inside
This commit is contained in:
parent
a1859f4eff
commit
a2fa5f7bce
@ -72,8 +72,9 @@ def addCardToBase(svg, baseImg, baseX, cardNum):
|
|||||||
str(int(cardNum / baseX) * CARD_HEIGHT)))
|
str(int(cardNum / baseX) * CARD_HEIGHT)))
|
||||||
baseImg.getroot().append(svg.getroot())
|
baseImg.getroot().append(svg.getroot())
|
||||||
|
|
||||||
def makeFace(baseImage, baseX, cardNum, base, card):
|
def makeFace(baseImage, baseX, cardNum, deckType, cardFile, card):
|
||||||
fig = makeSVG(base, card)
|
path = os.path.join(bundle_dir, "images", deckType, cardFile)
|
||||||
|
fig = makeSVG(path, card)
|
||||||
addCardToBase(fig, baseImage, baseX, cardNum)
|
addCardToBase(fig, baseImage, baseX, cardNum)
|
||||||
|
|
||||||
def makeFaces(deckJson, outfile):
|
def makeFaces(deckJson, outfile):
|
||||||
@ -84,49 +85,38 @@ def makeFaces(deckJson, outfile):
|
|||||||
'version': "1.2",
|
'version': "1.2",
|
||||||
'xmlns': "http://www.w3.org/2000/svg"}))
|
'xmlns': "http://www.w3.org/2000/svg"}))
|
||||||
|
|
||||||
cardType = deckJson["type"]
|
deckType = deckJson["type"]
|
||||||
|
|
||||||
cardNum = 0
|
cardNum = 0
|
||||||
# Make a card for each hero character card
|
# Make a card for each hero character card
|
||||||
if cardType == "hero":
|
if deckType == "hero":
|
||||||
for card in deckJson['character']:
|
for card in deckJson['character']:
|
||||||
makeFace(baseImage, baseX, cardNum,
|
makeFace(baseImage, baseX, cardNum, deckType, "charFront.svg", card)
|
||||||
os.path.join("images", cardType, "charFront.svg"), card)
|
|
||||||
cardNum += 1
|
cardNum += 1
|
||||||
makeFace(baseImage, baseX, cardNum,
|
makeFace(baseImage, baseX, cardNum, deckType, "charBack.svg", card)
|
||||||
os.path.join("images", cardType, "charBack.svg"), card)
|
|
||||||
cardNum += 1
|
cardNum += 1
|
||||||
|
|
||||||
# Make a character and instructions card for each villain card
|
# Make a character and instructions card for each villain card
|
||||||
elif cardType == "villain":
|
elif deckType == "villain":
|
||||||
for card in deckJson['character']:
|
for card in deckJson['character']:
|
||||||
front = card["front"]
|
front = card["front"]
|
||||||
front["name"] = card["name"]
|
front["name"] = card["name"]
|
||||||
back = card["back"]
|
back = card["back"]
|
||||||
back["name"] = card["name"]
|
back["name"] = card["name"]
|
||||||
makeFace(baseImage, baseX, cardNum,
|
makeFace(baseImage, baseX, cardNum, deckType, "character.svg", front)
|
||||||
os.path.join("images", cardType, "character.svg"),
|
|
||||||
front)
|
|
||||||
cardNum += 1
|
cardNum += 1
|
||||||
makeFace(baseImage, baseX, cardNum,
|
makeFace(baseImage, baseX, cardNum, deckType, "character.svg", back)
|
||||||
os.path.join("images", cardType, "character.svg"),
|
|
||||||
back)
|
|
||||||
cardNum += 1
|
cardNum += 1
|
||||||
|
|
||||||
makeFace(baseImage, baseX, cardNum,
|
makeFace(baseImage, baseX, cardNum, deckType, "instructions.svg", front)
|
||||||
os.path.join("images", cardType, "instructions.svg"),
|
|
||||||
front)
|
|
||||||
cardNum += 1
|
cardNum += 1
|
||||||
makeFace(baseImage, baseX, cardNum,
|
makeFace(baseImage, baseX, cardNum, deckType, "instructions.svg", back)
|
||||||
os.path.join("images", cardType, "instructions.svg"),
|
|
||||||
back)
|
|
||||||
cardNum += 1
|
cardNum += 1
|
||||||
|
|
||||||
|
|
||||||
# Make a card for each card
|
# Make a card for each card
|
||||||
for card in deckJson['deck']:
|
for card in deckJson['deck']:
|
||||||
makeFace(baseImage, baseX, cardNum,
|
makeFace(baseImage, baseX, cardNum, deckType, "card.svg", card)
|
||||||
os.path.join("images", cardType, "card.svg"), card)
|
|
||||||
cardNum += 1
|
cardNum += 1
|
||||||
|
|
||||||
baseImage.write(outfile + ".svg")
|
baseImage.write(outfile + ".svg")
|
||||||
|
Reference in New Issue
Block a user