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
|
|
|
|
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-23 11:36:19 +00:00
|
|
|
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(processName)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)
|
2021-08-17 15:37:28 +00:00
|
|
|
book = fftcg.Book(opus, "eg", args.num_threads)
|
2021-08-18 14:52:32 +00:00
|
|
|
book.save()
|
2021-08-16 12:45:15 +00:00
|
|
|
|
2021-08-18 11:49:34 +00:00
|
|
|
# load the current carddb
|
2021-08-17 15:37:28 +00:00
|
|
|
carddb = fftcg.CardDB.get()
|
|
|
|
carddb.load()
|
2021-08-16 12:45:15 +00:00
|
|
|
|
2021-08-18 11:49:34 +00:00
|
|
|
# create elemental decks for opus
|
2021-08-17 15:37:28 +00:00
|
|
|
for deck in opus.elemental_decks:
|
2021-08-18 15:38:58 +00:00
|
|
|
deck.save()
|
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()
|