Create core_alphabetical.py
This commit is contained in:
parent
fd10676706
commit
a0b29fc448
3 changed files with 62 additions and 22 deletions
31
core_alphabetical.py
Normal file
31
core_alphabetical.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Generate a draft pool for dr4ft.info
|
||||
|
||||
import csv
|
||||
|
||||
import cube_json
|
||||
import cubecobra_csv
|
||||
|
||||
CUBE_NAME = 'TheElegantCube_fetched'
|
||||
|
||||
|
||||
def main():
|
||||
csv_path = cube_json.request_cube_csv('TheElegantCube_fetched', 'elegant')
|
||||
|
||||
core_cards = []
|
||||
with open(csv_path) as f:
|
||||
reader = csv.reader(f)
|
||||
header_line = next(reader)
|
||||
cubecobra_csv.assert_header(header_line)
|
||||
for line in reader:
|
||||
card = line[cubecobra_csv.COLUMNS['Name']]
|
||||
tags = line[cubecobra_csv.COLUMNS['Tags']].split(', ')
|
||||
if 'core' in tags:
|
||||
core_cards.append(card)
|
||||
|
||||
core_cards.sort()
|
||||
for card in core_cards:
|
||||
print(card)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
27
cubecobra_csv.py
Normal file
27
cubecobra_csv.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# TODO: Make this an actual API
|
||||
|
||||
EXPECTED_HEADER = [
|
||||
'Name',
|
||||
'CMC',
|
||||
'Type',
|
||||
'Color',
|
||||
'Set',
|
||||
'Collector Number',
|
||||
'Rarity',
|
||||
'Color Category',
|
||||
'Status',
|
||||
'Finish',
|
||||
'Maybeboard',
|
||||
'Image URL',
|
||||
'Image Back URL',
|
||||
'Tags',
|
||||
'Notes',
|
||||
'MTGO ID'
|
||||
]
|
||||
|
||||
|
||||
COLUMNS = {column_name: i for i, column_name in enumerate(EXPECTED_HEADER)}
|
||||
|
||||
|
||||
def assert_header(header_line):
|
||||
assert header_line == EXPECTED_HEADER
|
||||
|
|
@ -4,6 +4,7 @@ import csv
|
|||
import random
|
||||
|
||||
import cube_json
|
||||
import cubecobra_csv
|
||||
|
||||
|
||||
OUTPUT_POOL_SIZE = 360
|
||||
|
|
@ -12,25 +13,6 @@ CARDS_FROM_CORE = OUTPUT_POOL_SIZE - CARDS_FROM_OCCASIONAL
|
|||
CUBE_NAME = 'TheElegantCube_fetched'
|
||||
|
||||
OUTPUT_FILENAME = 'cards_in_draft.txt'
|
||||
EXPECTED_HEADER = [
|
||||
'Name',
|
||||
'CMC',
|
||||
'Type',
|
||||
'Color',
|
||||
'Set',
|
||||
'Collector Number',
|
||||
'Rarity',
|
||||
'Color Category',
|
||||
'Status',
|
||||
'Finish',
|
||||
'Maybeboard',
|
||||
'Image URL',
|
||||
'Image Back URL',
|
||||
'Tags',
|
||||
'Notes',
|
||||
'MTGO ID'
|
||||
]
|
||||
COLUMNS = {column_name: i for i, column_name in enumerate(EXPECTED_HEADER)}
|
||||
|
||||
|
||||
def main():
|
||||
|
|
@ -41,10 +23,10 @@ def main():
|
|||
with open(csv_path) as f:
|
||||
reader = csv.reader(f)
|
||||
header_line = next(reader)
|
||||
assert header_line == EXPECTED_HEADER
|
||||
cubecobra_csv.assert_header(header_line)
|
||||
for line in reader:
|
||||
card = line[COLUMNS['Name']]
|
||||
tags = line[COLUMNS['Tags']].split(', ')
|
||||
card = line[cubecobra_csv.COLUMNS['Name']]
|
||||
tags = line[cubecobra_csv.COLUMNS['Tags']].split(', ')
|
||||
# print(f'{card} {tags}')
|
||||
if 'occasional' in tags:
|
||||
occasional_pool.append(card)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue