Skip to content
22 changes: 22 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[submodule "TSSSF/Core Deck"]
path = TSSSF/Core Deck
url = https://github.com/secretshipfic/Core-Deck.git
[submodule "TSSSF/Card Art"]
path = TSSSF/Card Art
url = https://github.com/DieKatzchen/Card-Art.git
[submodule "TSSSF/Ponyville University"]
path = TSSSF/Ponyville University
url = https://github.com/secretshipfic/PonyvilleUniversity.git
[submodule "TSSSF/Mini Expansions"]
path = TSSSF/Mini Expansions
url = https://github.com/DieKatzchen/Mini-Expansions.git
branch = Multiplicity
[submodule "TSSSF/Expansions"]
path = TSSSF/Expansions
url = https://github.com/secretshipfic/Expansions.git
[submodule "TSSSF/Extra Credit"]
path = TSSSF/Extra Credit
url = https://github.com/secretshipfic/ExtraCredit.git
[submodule "TSSSF/resources"]
path = TSSSF/resources
url = https://github.com/DieKatzchen/TSSSFTemplates.git
45 changes: 33 additions & 12 deletions GameGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import json


def main(folder="TSSSF", filepath="Core Deck 1.1.6/cards.json"):
def main(folder="TSSSF", filepath="Core Deck/cards.json"):
'''
@param folder: The base game folder where we'll be working.
E.g. TSSSF, BaBOC
Expand All @@ -33,7 +33,7 @@ def main(folder="TSSSF", filepath="Core Deck 1.1.6/cards.json"):
else:
file_type = 'pon'
if first_line == "TSSSF_CardGen":
print 'Warning: .pon files are DEPRECATED for TSSSF. Support for this format may be removed soon. Please use the pontojson.py converter to convert this file to JSON format.'
print('Warning: .pon files are DEPRECATED for TSSSF. Support for this format may be removed soon. Please use the pontojson.py converter to convert this file to JSON format.')
module_name = first_line
# Load Card File and strip out comments
cards = [line for line in CardFile if not line[0] in ('#', ';', '/')]
Expand All @@ -42,7 +42,7 @@ def main(folder="TSSSF", filepath="Core Deck 1.1.6/cards.json"):
try:
module = __import__(module_name.strip())
except ValueError:
print "Failed to load module: " + str(ValueError)
print("Failed to load module: " + str(ValueError))
return
card_set = os.path.dirname(filepath)
if file_type == 'json':
Expand Down Expand Up @@ -70,7 +70,10 @@ def main(folder="TSSSF", filepath="Core Deck 1.1.6/cards.json"):
module.CropPath = cropped_path
vassal_path = CleanDirectory(path=folder + "/" + card_set, mkdir="vassal-images", rmstring="*.*")
module.VassalPath = vassal_path

TGC_path = CleanDirectory(path=folder+"/"+card_set, mkdir="TGC-images",rmstring="*.*")
module.TGCPath = TGC_path


# Create output directory
output_folder = CleanDirectory(path=folder, mkdir=card_set, rmstring="*.pdf")

Expand All @@ -85,7 +88,7 @@ def main(folder="TSSSF", filepath="Core Deck 1.1.6/cards.json"):
# do that now, and set the card list to empty again
if len(card_list) >= module.TOTAL_CARDS:
page_num += 1
print "Building Page {}...".format(page_num)
print("Building Page {}...".format(page_num))
BuildPage(card_list, page_num, module.PAGE_WIDTH, module.PAGE_HEIGHT, workspace_path)
BuildBack(back_list, page_num, module.PAGE_WIDTH, module.PAGE_HEIGHT, workspace_path)
card_list = []
Expand All @@ -99,18 +102,18 @@ def main(folder="TSSSF", filepath="Core Deck 1.1.6/cards.json"):
card_list.append(module.BuildCard("BLANK"))
back_list.append(module.BuildCard("BLANK"))
page_num += 1
print "Building Page {}...".format(page_num)
print("Building Page {}...".format(page_num))
BuildPage(card_list, page_num, module.PAGE_WIDTH, module.PAGE_HEIGHT, workspace_path)
BuildBack(back_list, page_num, module.PAGE_WIDTH, module.PAGE_HEIGHT, workspace_path)

# Build Vassal
module.CompileVassalModule()

print "\nCreating PDF..."
os.system(r'convert "{}/page_*.png" "{}/{}.pdf"'.format(workspace_path, output_folder, card_set))
print "\nCreating PDF of backs..."
os.system(r'convert "{}/backs_*.png" "{}/backs_{}.pdf"'.format(workspace_path, output_folder, card_set))
print "Done!"
print("\nCreating PDF...")
os.system(r'magick convert "{}/page_*.png" "{}/{}.pdf"'.format(workspace_path, output_folder, os.path.basename(card_set)))
print("\nCreating PDF of backs...")
os.system(r'magick convert "{}/backs_*.png" "{}/backs_{}.pdf"'.format(workspace_path, output_folder, os.path.basename(card_set)))
print("Done!")


if __name__ == '__main__':
Expand All @@ -132,4 +135,22 @@ def main(folder="TSSSF", filepath="Core Deck 1.1.6/cards.json"):

args = parser.parse_args()

main(args.basedir, args.set_file)
#main(args.basedir, args.set_file)
#main('TSSSF', 'Core Deck/cards.pon')
main('TSSSF', 'Mini Expansions/Multiplicity 0.0.1a/cards.json')
#main('TSSSF', '1.1.0 Patch/cards.pon')
#main('TSSSF', '2014 Con Exclusives/cards.pon')
#main('TSSSF', 'BABScon 2015/cards.pon')
#main('TSSSF', 'Core 1.0.5/cards.pon')
#main('TSSSF', 'Core 1.0.5 Delta/cards.pon')
#main('TSSSF', 'Core 1.1.0/cards.pon')
#main('TSSSF', 'Core 1.1.0 Test/cards.pon')
#main('TSSSF', 'Custom Card for/cards.pon')
#main('TSSSF', 'Extra Credit 0.10.4/cards.pon')
#main('TSSSF', 'Indiegogo/cards.pon')
#main('TSSSF', 'Patreon Expansion 1/cards.pon')
#main('TSSSF', 'Ponycon Panel 2015/cards.pon')
#main('TSSSF', 'Ponyville University 1.0.1/cards.pon')
#main('TSSSF', 'Ponyville University 0.0.2/cards.pon')
#main('TSSSF', 'Ponyville University 1.0.2/cards.pon')
#main('TSSSF', 'Thank You/cards.pon')
12 changes: 6 additions & 6 deletions PIL_Helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def AddText(image, text, font, fill=(0,0,0), anchor=(0,0),
coords_y = anchor_y - height

image.paste(ImageOps.colorize(layer, (255,255,255), fill),
(coords_x, coords_y), layer)
(int(coords_x), int(coords_y)), layer)

return total_text_size

Expand All @@ -171,11 +171,11 @@ def BuildPage(card_list, grid_width, grid_height, filename,
w,h = card_list[0].size
bg = Image.new("RGB", (w*grid_width, h*grid_height))
# Add cards to the grid, top down, left to right
for y in xrange(grid_height):
for x in xrange(grid_width):
for y in range(grid_height):
for x in range(grid_width):
card = card_list.pop(0)
coords = (x*(w+cut_line_width),
y*(h+cut_line_width))
coords = (int(x*(w+cut_line_width)),
int(y*(h+cut_line_width)))
bg.paste(card, coords)
# If there's a margin defined, add extra whitespace around the page
# if h_margin > 0:
Expand All @@ -195,7 +195,7 @@ def BuildPage(card_list, grid_width, grid_height, filename,
w,h = bg.size
# TODO Add code that shrinks the bg if it's bigger than any dimension
# of the Paper image
paper_image.paste(bg, ((paper_width - w)/2, (paper_height - h)/2))
paper_image.paste(bg, (int((paper_width - w)/2), int((paper_height - h)/2)))
paper_image.save(filename, dpi=(300, 300))

def BlankImage(w, h, color=(255,255,255), image_type="RGBA"):
Expand Down
59 changes: 32 additions & 27 deletions TSSSF_CardGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
BleedsPath = DIRECTORY + "/bleed-images/"
CropPath = DIRECTORY + "/cropped-images/"
VassalPath = DIRECTORY + "/vassal-images/"
TGCPath = DIRECTORY+"/TGC-images/"

BleedTemplatesPath = ResourcePath + "/bleed templates/"
SymbolsPath = ResourcePath + "/symbols/"
Expand All @@ -33,17 +34,19 @@
VASSAL_SCALE = (260, 359)

VassalCard = [0]
ART_WIDTH = 600
ART_WIDTH = 602
base_w = 889
base_h = 1215
base_h = 1214
base_w_center = base_w / 2
base_h_center = base_h / 2
w_marg = 31
h_marg = 36
baserect = [(w_marg, h_marg), (base_w - w_marg, base_h - h_marg)]
textmaxwidth = 689

croprect = (50, 63, 788 + 50, 1088 + 63)
TGC_SCALE = (825,1125)

croprect=(50,63,788+50,1088+63)

TextHeightThresholds = [363, 378, 600]
TitleWidthThresholds = [50] # This is in #characters, fix later plox
Expand All @@ -63,7 +66,7 @@

Anchors = {
"Blank": (base_w_center, 300),
"PonyArt": (173, 225),
"PonyArt": (172, 224),
"ShipArt": (173, 226),
"GoalArt": (174, 224),
"Symbol1": (58 + 50, 56 + 63),
Expand Down Expand Up @@ -132,30 +135,30 @@
TIMELINE_SYMBOL_LIST = ["Dystopian"]

Expansions = {
"Everfree14": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-Everfree14.png"),
#"Everfree14": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-Everfree14.png"),
"Indiegogo": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-Indiegogo.png"),
"Birthday": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-birthday.png"),
"Bronycon": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-Bronycon14.png"),
#"Birthday": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-birthday.png"),
#"Bronycon": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-Bronycon14.png"),
"Summer": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-summer-lovin.png"),
"Apricity": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-apricity.png"),
"BronyCAN": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-Bronycan14.png"),
#"Apricity": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-apricity.png"),
#"BronyCAN": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-Bronycan14.png"),
"Xtra": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-extracredit.png"),
"Xtra-dark": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-extracredit-black.png"),
"NMND": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-nightmarenights.png"),
"Ciderfest": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-ponyvilleciderfest.png"),
"Adventure": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-adventure.png"),
"Custom": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-custom.png"),
#"Xtra-dark": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-extracredit-black.png"),
#"NMND": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-nightmarenights.png"),
#"Ciderfest": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-ponyvilleciderfest.png"),
#"Adventure": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-adventure.png"),
#"Custom": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-custom.png"),
"Power": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-power.png"),
"Multiplicity": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-multiplicity.png"),
"Canon": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-canon.png"),
"Dungeon": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-dungeon.png"),
#"Dungeon": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-dungeon.png"),
"50": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-50.png"),
"2014": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-2014.png"),
"Hearthswarming": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-hearthswarming.png"),
"Ponycon 2015": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-ponynyc.png"),
"Patreon": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-Patreon.png"),
"Gameshow": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-gameshow.png"),
"BABScon": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-BABScon.png")
#"2014": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-2014.png"),
#"Hearthswarming": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-hearthswarming.png"),
#"Ponycon 2015": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-ponynyc.png"),
#"Patreon": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-Patreon.png"),
#"Gameshow": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-gameshow.png"),
#"BABScon": PIL_Helper.LoadImage(ExpansionIconsPath + "symbol-BABScon.png")
}

ColorDict = {
Expand Down Expand Up @@ -288,15 +291,17 @@ def BuildCard(data):
else:
filename = FixFileName(card_type + "_" + picture)
SaveCard(os.path.join(BleedsPath, filename), im)
im_crop = im.crop(croprect)
im_TGC=PIL_Helper.ResizeImage(im, TGC_SCALE)
SaveCard(os.path.join(TGCPath, filename), im_TGC)
im_crop=im.crop(croprect)
SaveCard(os.path.join(CropPath, filename), im_crop)
im_vassal = PIL_Helper.ResizeImage(im_crop, VASSAL_SCALE)
SaveCard(os.path.join(VassalPath, filename), im_vassal)
else:
im_crop = im.crop(croprect)

except Exception as e:
print "Warning, Bad Card: {0}".format(data)
print("Warning, Bad Card: {0}".format(data))
traceback.print_exc()
im_crop = MakeBlankCard().crop(croprect)
return im_crop
Expand Down Expand Up @@ -383,7 +388,7 @@ def TitleText(image, text, color):
if len(text) > TitleWidthThresholds[0]:
anchor = Anchors["TitleSmall"]
font = fonts["TitleSmall"]
print repr(text)
print(repr(text))
PIL_Helper.AddText(
image=image,
text=text,
Expand Down Expand Up @@ -671,7 +676,7 @@ def MakeSpecialCard(card):


def MakeSpecialCardJSON(data):
print repr(data['picture'])
print(repr(data['picture']))
image = GetFrame(data['picture'])
if data['picture'] in special_cards_with_copyright:
CopyrightText(data, image, ColorDict["Copyright"], data.get('artist', ARTIST))
Expand All @@ -681,7 +686,7 @@ def MakeSpecialCardJSON(data):


def MakeSpecialCardPON(data):
print repr(data[PICTURE])
print(repr(data[PICTURE]))
image = GetFrame(data[PICTURE])
if data[PICTURE] in special_cards_with_copyright:
CopyrightText(data, image, ColorDict["Copyright"], ARTIST)
Expand All @@ -704,4 +709,4 @@ def CompileVassalModule():


if __name__ == "__main__":
print "Not a main module. Run GameGen.py"
print("Not a main module. Run GameGen.py")