2021-08-03 00:22:00 +00:00
|
|
|
#!/usr/bin/env python3
|
2021-08-04 16:36:23 +00:00
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import os
|
2021-08-03 00:22:00 +00:00
|
|
|
|
2021-08-09 05:01:25 +00:00
|
|
|
import fftcg
|
2021-08-04 22:17:47 +00:00
|
|
|
|
|
|
|
# constants
|
2021-08-09 12:03:45 +00:00
|
|
|
GRID = 10, 7 # default in TTsim: 10 columns, 7 rows
|
2021-08-04 22:17:47 +00:00
|
|
|
RESOLUTION = 429, 600 # default in TTsim: 480x670 pixels per card
|
2021-08-16 12:45:15 +00:00
|
|
|
BOOK_YML_NAME = "book.yml"
|
2018-11-02 22:13:17 +00:00
|
|
|
|
|
|
|
|
2021-08-09 02:03:24 +00:00
|
|
|
def main() -> None:
|
2021-08-04 22:17:47 +00:00
|
|
|
# set up CLI
|
2021-08-04 16:36:23 +00:00
|
|
|
parser = argparse.ArgumentParser(
|
2021-08-09 04:18:56 +00:00
|
|
|
description="Imports FFTCG cards for TT-Sim.",
|
|
|
|
)
|
2018-11-02 22:13:17 +00:00
|
|
|
|
2021-08-04 16:36:23 +00:00
|
|
|
parser.add_argument(
|
2021-08-09 04:18:56 +00:00
|
|
|
"opus_id",
|
|
|
|
default="promo",
|
2021-08-04 22:54:15 +00:00
|
|
|
metavar="Opus_ID",
|
2021-08-04 16:36:23 +00:00
|
|
|
nargs="?",
|
2021-08-09 04:18:56 +00:00
|
|
|
help="the Opus to import",
|
|
|
|
)
|
2021-08-04 16:36:23 +00:00
|
|
|
|
|
|
|
parser.add_argument(
|
2021-08-09 04:18:56 +00:00
|
|
|
"-n", "--num_threads",
|
2021-08-04 16:36:23 +00:00
|
|
|
type=int,
|
|
|
|
default=20,
|
|
|
|
metavar="COUNT",
|
2021-08-09 04:18:56 +00:00
|
|
|
help="maximum number of concurrent requests",
|
|
|
|
)
|
2021-08-04 16:36:23 +00:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2021-08-04 22:17:47 +00:00
|
|
|
# set up logging
|
2021-08-09 04:18:56 +00:00
|
|
|
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(threadName)s %(message)s")
|
2021-08-04 16:36:23 +00:00
|
|
|
|
|
|
|
# output directory
|
|
|
|
if not os.path.exists("out"):
|
|
|
|
os.mkdir("out")
|
|
|
|
os.chdir("out")
|
|
|
|
|
2021-08-04 22:17:47 +00:00
|
|
|
# main program
|
2021-08-09 05:01:25 +00:00
|
|
|
opus = fftcg.Opus(args.opus_id)
|
|
|
|
book = fftcg.Book(opus, GRID, RESOLUTION, "eg", args.num_threads)
|
2021-08-16 12:45:15 +00:00
|
|
|
book.save(opus.filename, BOOK_YML_NAME)
|
|
|
|
|
|
|
|
# create elemental decks for opus
|
|
|
|
carddb = fftcg.CardDB(BOOK_YML_NAME)
|
|
|
|
|
|
|
|
def opus_filter(card: fftcg.Card):
|
|
|
|
return card.code.opus == opus.number
|
|
|
|
|
|
|
|
def element_filter(element: str):
|
|
|
|
return lambda card: card.elements == [element]
|
|
|
|
|
|
|
|
# simple cases: create lambdas for base elemental decks
|
|
|
|
base_elements = ["Fire", "Ice", "Wind", "Earth", "Lightning", "Water"]
|
|
|
|
element_filters = [element_filter(elem) for elem in base_elements]
|
|
|
|
|
|
|
|
element_filters += [
|
|
|
|
# light/darkness elemental deck
|
|
|
|
lambda card: card.elements == ["Light"] or card.elements == ["Darkness"],
|
|
|
|
# multi element deck
|
|
|
|
lambda card: len(card.elements) > 1,
|
|
|
|
]
|
|
|
|
|
|
|
|
# add in the opus_filter for all elemental decks
|
|
|
|
filters = list(zip([opus_filter]*len(element_filters), element_filters))
|
|
|
|
|
|
|
|
# make the decks
|
|
|
|
for f in filters:
|
|
|
|
print(carddb.make_deck(f))
|
2021-08-04 22:17:47 +00:00
|
|
|
|
|
|
|
# bye
|
|
|
|
logging.info("Done. Put the generated JSON files in your 'Saved Objects' Folder.")
|
|
|
|
logging.info("Thanks for using fftcgtool!")
|
2021-08-04 01:39:19 +00:00
|
|
|
|
2018-11-02 22:13:17 +00:00
|
|
|
|
2021-08-09 04:18:56 +00:00
|
|
|
if __name__ == "__main__":
|
2021-08-03 21:41:25 +00:00
|
|
|
main()
|