Add forge_cube_to_edition.py
This commit is contained in:
parent
2c71de733f
commit
1cc7c55578
2 changed files with 43 additions and 0 deletions
42
forge_cube_to_edition.py
Normal file
42
forge_cube_to_edition.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import pathlib
|
||||
|
||||
import cubecobra_csv
|
||||
|
||||
from cubecobra_csv import CubeCard
|
||||
|
||||
|
||||
OUT_FILE = pathlib.Path('forge') /'MyCube.txt'
|
||||
|
||||
HEADER = """[metadata]
|
||||
Code=CUB
|
||||
Date=2021-04-09
|
||||
Name=My Cube
|
||||
MciCode=cub
|
||||
Type=Expansion
|
||||
BoosterCovers=1
|
||||
Booster=10 Common, 1 Rare
|
||||
Foil=NotSupported
|
||||
|
||||
[cards]
|
||||
"""
|
||||
|
||||
if __name__ == '__main__':
|
||||
csv_path = cubecobra_csv.request_cube_csv('TheElegantCube_fetched', 'elegant')
|
||||
|
||||
cube_cards = cubecobra_csv.load_cube(csv_path)
|
||||
|
||||
with open(OUT_FILE, 'w') as outfile:
|
||||
outfile.write(HEADER)
|
||||
|
||||
i = 1
|
||||
card: CubeCard
|
||||
for card in cube_cards:
|
||||
if 'core' in card.tags:
|
||||
rarity = 'C'
|
||||
elif 'occasional' in card.tags:
|
||||
rarity = 'R'
|
||||
else:
|
||||
raise Exception(f'{card.name} has no module tags')
|
||||
outfile.write('%d %s %s\n' % (i, rarity, card.name))
|
||||
i += 1
|
||||
print(f'Finished writing {OUT_FILE} with {i - 1} cards')
|
||||
Loading…
Add table
Add a link
Reference in a new issue