Report per color
This commit is contained in:
parent
2e4a3c9889
commit
2c71de733f
1 changed files with 21 additions and 7 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import cubecobra_csv
|
import cubecobra_csv
|
||||||
|
|
||||||
|
|
@ -39,6 +40,7 @@ ARCHETYPE_TAGS = [
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-a', '--archetype')
|
parser.add_argument('-a', '--archetype')
|
||||||
|
parser.add_argument('-c', '--category')
|
||||||
arguments = parser.parse_args()
|
arguments = parser.parse_args()
|
||||||
|
|
||||||
csv_path = cubecobra_csv.request_cube_csv('TheElegantCube_fetched', 'elegant')
|
csv_path = cubecobra_csv.request_cube_csv('TheElegantCube_fetched', 'elegant')
|
||||||
|
|
@ -52,26 +54,38 @@ def main():
|
||||||
if tag in ARCHETYPE_TAGS:
|
if tag in ARCHETYPE_TAGS:
|
||||||
archetype_counts_per_category[tag][cube_card.color_category].append(cube_card)
|
archetype_counts_per_category[tag][cube_card.color_category].append(cube_card)
|
||||||
|
|
||||||
if not arguments.archetype:
|
if not arguments.archetype and not arguments.category:
|
||||||
for tag in ARCHETYPE_TAGS:
|
for tag in ARCHETYPE_TAGS:
|
||||||
print(f'Archetype: {tag}')
|
print(f'Archetype: {tag}')
|
||||||
cards_per_category = archetype_counts_per_category[tag]
|
cards_per_category = archetype_counts_per_category[tag]
|
||||||
for category, cards in cards_per_category.items():
|
for category, cards in cards_per_category.items():
|
||||||
print(f'{category} {len(cards)}')
|
print(f'{category} {len(cards)}')
|
||||||
print()
|
print()
|
||||||
else:
|
elif arguments.archetype:
|
||||||
cards_per_category = archetype_counts_per_category[arguments.archetype]
|
cards_per_category = archetype_counts_per_category[arguments.archetype]
|
||||||
|
|
||||||
for category, cards in cards_per_category.items():
|
for category, cards in cards_per_category.items():
|
||||||
print(f'Category: {category} - {len(cards)} card{"s" if len(cards) != 1 else ""}')
|
_print_detailed(category, cards)
|
||||||
for i, card in enumerate(cards, 1):
|
|
||||||
intersection = [tag for tag in card.tags if tag != arguments.archetype and tag in ARCHETYPE_TAGS]
|
|
||||||
print(f'{i:2d} {card.name} ([{len(intersection) + 1}]: {intersection})')
|
|
||||||
print()
|
|
||||||
|
|
||||||
print()
|
print()
|
||||||
for category, cards in cards_per_category.items():
|
for category, cards in cards_per_category.items():
|
||||||
print(f'{category} {len(cards)}')
|
print(f'{category} {len(cards)}')
|
||||||
|
elif arguments.category:
|
||||||
|
cards = []
|
||||||
|
for cube_card in cube_cards:
|
||||||
|
if 'core' not in cube_card.tags:
|
||||||
|
continue
|
||||||
|
if cube_card.color_category == arguments.category:
|
||||||
|
cards.append(cube_card)
|
||||||
|
_print_detailed(arguments.category, cards)
|
||||||
|
|
||||||
|
|
||||||
|
def _print_detailed(category: str, cards: List[cubecobra_csv.CubeCard]) -> None:
|
||||||
|
print(f'Category: {category} | {len(cards)} card{"s" if len(cards) != 1 else ""}')
|
||||||
|
for i, card in enumerate(cards, 1):
|
||||||
|
intersection = [tag for tag in card.tags if tag in ARCHETYPE_TAGS]
|
||||||
|
print(f'{i:2d} {card.name} ([{len(intersection)}]: {intersection})')
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue