mirror of
https://github.com/ldericher/fftcgtool
synced 2025-01-15 15:02:59 +00:00
minor cleanup
This commit is contained in:
parent
8dda8db72f
commit
29ce4e6f24
4 changed files with 12 additions and 14 deletions
|
@ -48,9 +48,9 @@ class Book:
|
||||||
# width, height per card
|
# width, height per card
|
||||||
w, h = resolution
|
w, h = resolution
|
||||||
|
|
||||||
def paste_image(page: Image, index: int, image: Image) -> None:
|
def paste_card(index: int, card: Image) -> None:
|
||||||
x, y = (index % c) * w, (index // c) * h
|
x, y = (index % c) * w, (index // c) * h
|
||||||
page.paste(image, (x, y))
|
page.paste(card, (x, y))
|
||||||
|
|
||||||
self.__pages = []
|
self.__pages = []
|
||||||
for images in chunks(images, grid_capacity):
|
for images in chunks(images, grid_capacity):
|
||||||
|
@ -60,10 +60,10 @@ class Book:
|
||||||
|
|
||||||
# paste card faces onto page
|
# paste card faces onto page
|
||||||
for i, image in enumerate(images):
|
for i, image in enumerate(images):
|
||||||
paste_image(page, i, image)
|
paste_card(i, image)
|
||||||
|
|
||||||
# paste card back in last position
|
# paste card back in last position
|
||||||
paste_image(page, c * r - 1, back_image)
|
paste_card(c * r - 1, back_image)
|
||||||
|
|
||||||
self.__pages.append(page)
|
self.__pages.append(page)
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ class Cards(list[Card]):
|
||||||
# [array] type, element, cost, rarity, power, category_1, set
|
# [array] type, element, cost, rarity, power, category_1, set
|
||||||
# [int] exactmatch=0|1
|
# [int] exactmatch=0|1
|
||||||
|
|
||||||
|
if "text" not in params:
|
||||||
|
params["text"] = ""
|
||||||
|
|
||||||
req = requests.post(Cards.__API_URL, json=params)
|
req = requests.post(Cards.__API_URL, json=params)
|
||||||
self.extend([Card(card_data) for card_data in req.json()["cards"]])
|
self.extend([Card(card_data) for card_data in req.json()["cards"]])
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class ImageLoader(threading.Thread):
|
||||||
image.convert("RGB")
|
image.convert("RGB")
|
||||||
image = image.resize(self.__resolution, Image.BICUBIC)
|
image = image.resize(self.__resolution, Image.BICUBIC)
|
||||||
break
|
break
|
||||||
except:
|
except requests.exceptions.RequestException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# put image in correct position
|
# put image in correct position
|
||||||
|
|
|
@ -9,29 +9,24 @@ class Opus(Cards):
|
||||||
def __init__(self, opus_id: str):
|
def __init__(self, opus_id: str):
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
params: dict[str, any] = {
|
|
||||||
"text": "",
|
|
||||||
# "element": ["darkness"],
|
|
||||||
}
|
|
||||||
|
|
||||||
if opus_id.isnumeric():
|
if opus_id.isnumeric():
|
||||||
roman_opus_id = roman.toRoman(int(opus_id))
|
roman_opus_id = roman.toRoman(int(opus_id))
|
||||||
params |= {"set": [f"Opus {roman_opus_id.upper()}"]}
|
params = {"set": [f"Opus {roman_opus_id.upper()}"]}
|
||||||
self.__number = opus_id
|
self.__number = opus_id
|
||||||
self.__name = f"opus_{opus_id}"
|
self.__name = f"opus_{opus_id}"
|
||||||
|
|
||||||
elif opus_id == "chaos":
|
elif opus_id == "chaos":
|
||||||
params |= {"set": ["Boss Deck Chaos"]}
|
params = {"set": ["Boss Deck Chaos"]}
|
||||||
self.__number = "B"
|
self.__number = "B"
|
||||||
self.__name = "boss_deck_chaos"
|
self.__name = "boss_deck_chaos"
|
||||||
|
|
||||||
elif opus_id == "promo":
|
elif opus_id == "promo":
|
||||||
params |= {"rarity": ["pr"]}
|
params = {"rarity": ["pr"]}
|
||||||
self.__number = "PR"
|
self.__number = "PR"
|
||||||
self.__name = "promo"
|
self.__name = "promo"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
params |= {"set": ["?"]}
|
params = {"set": ["?"]}
|
||||||
self.__number = "?"
|
self.__number = "?"
|
||||||
self.__name = "?"
|
self.__name = "?"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue